added makefile

This commit is contained in:
Stefan Friese 2024-12-10 23:43:52 +01:00
parent 85b57ef9aa
commit 56f75e2783
3 changed files with 61 additions and 0 deletions

53
Makefile Normal file
View File

@ -0,0 +1,53 @@
.DEFAULT_GOAL := build
PACKAGE_NAME := based
CABAL := cabal
BUILD_FLAGS := --builddir=dist-newstyle
BUILD_DEV_FLAGS := --enable-tests --enable-benchmarks
# STATIC_FLAGS := --ghc-options="-optl-static"
STATIC_FLAGS := --enable-executable-static -O2
STRIP := strip
STRIP_FLAGS := --strip-all
INSTALL_DIR := /usr/local/bin
INSTALL_FLAGS := --overwrite-policy=always
BIN_NAME := $(PACKAGE_NAME)
.PHONY: test
build:
$(CABAL) v2-build $(BUILD_FLAGS)
static-build:
$(CABAL) v2-build $(BUILD_FLAGS) $(STATIC_FLAGS)
dev-build:
$(CABAL) v2-build $(BUILD_FLAGS) $(BUILD_DEV_FLAGS)
strip:
$(STRIP) $(STRIP_FLAGS) $(realpath $(which $(PACKAGE_NAME)))
user-install:
$(CABAL) v2-install $(BUILD_FLAGS) $(INSTALL_FLAGS)
$(STRIP) $(STRIP_FLAGS) $(realpath $(which $(PACKAGE_NAME)))
install: user-install
install -m 755 $(shell cabal v2-exec which $(BIN_NAME)) $(INSTALL_DIR)/$(BIN_NAME)
$(STRIP) $(STRIP_FLAGS) $(realpath $(which $(PACKAGE_NAME)))
echo "$(BIN_NAME) installed to $(INSTALL_DIR)"
static-install: static-build user-install
install -m 755 $(shell cabal v2-exec which $(BIN_NAME)) $(INSTALL_DIR)/$(BIN_NAME)
$(STRIP) $(STRIP_FLAGS) $(realpath $(which $(PACKAGE_NAME)))
echo "$(BIN_NAME) installed to $(INSTALL_DIR)"
test:
$(CABAL) v2-test $(BUILD_FLAGS)
clean-artifacts:
$(CABAL) v2-clean
clean: clean-artifacts
rm -f $(INSTALL_DIR)/$(BIN_NAME) \
&& echo "$(BIN_NAME) removed from $(INSTALL_DIR)" \
|| echo "$(BIN_NAME) cannot be found in $(INSTALL_DIR)"

View File

@ -5,6 +5,7 @@
module Main where
import System.Console.CmdArgs
import qualified Data.ByteString as B
import Encoding.Unary (encunary, decunary)
import Encoding.Base2 (enc2, dec2)
import Encoding.Base8 (enc8, dec8)
import Encoding.Base10 (enc10, dec10)
@ -42,6 +43,7 @@ data Based = Decode {
b10 :: Bool,
b8 :: Bool,
b2 :: Bool,
unary :: Bool,
qp :: Bool,
uu :: Bool,
xx :: Bool,
@ -66,6 +68,7 @@ data Based = Decode {
b10 :: Bool,
b8 :: Bool,
b2 :: Bool,
unary :: Bool,
qp :: Bool,
uu :: Bool,
xx :: Bool,
@ -105,6 +108,8 @@ optionHandler Decode{b8=True} = dec8
optionHandler Encode{b8=True} = enc8
optionHandler Decode{b2=True} = dec2
optionHandler Encode{b2=True} = enc2
optionHandler Decode{unary=True} = decunary
optionHandler Encode{unary=True} = encunary
optionHandler Decode{qp=True} = decqp
optionHandler Encode{qp=True} = encqp
optionHandler Encode{uu=True} = encuu
@ -138,6 +143,7 @@ decodeMode = Decode {
b10 = def &= help "decode decimal",
b8 = def &= help "decode octal",
b2 = def &= help "decode base2",
unary = def &= help "decode unary (8 bit) a.k.a. Chuck Norris",
qp = def &= help "decode quoted-printable",
uu = def &= help "decode UnixToUnix",
xx = def &= help "decode xx, without padding",
@ -164,6 +170,7 @@ encodeMode = Encode {
b10 = def &= help "encode decimal",
b8 = def &= help "encode octal",
b2 = def &= help "encode base2",
unary = def &= help "encode unary (8 bit) a.k.a. Chuck Norris",
qp = def &= help "encode quoted-printable",
uu = def &= help "encode UnixToUnix",
xx = def &= help "encode xx, without padding",

View File

@ -8,6 +8,7 @@ author: Stefan Friese
library
hs-source-dirs: src
exposed-modules:
Encoding.Unary
Encoding.Base2
Encoding.Base8
Encoding.Base10