.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)"