Skip to content

Give the Makefile a subtle massage #479

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@ all:

## Build ameba
## $ make
##
## Run tests
## $ make test
##
## Install ameba
## $ sudo make install

-include Makefile.local # for optional local options

BUILD_TARGET := bin/ameba

DESTDIR ?= ## Install destination dir
PREFIX ?= /usr/local## Install path prefix
DESTDIR ?= ## Install destination dir
PREFIX ?= /usr/local ## Install path prefix
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: This change breaks behaviour.
Unfortunately, GNU make does not chop off trailing whitespace from string values in assignments. So the default BINDIR is now /usr/local /bin

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh... I'll revert that, thanks for noticing.

BINDIR ?= $(DESTDIR)$(PREFIX)/bin

# The crystal command to use
Expand All @@ -29,7 +31,6 @@ SHARD_BIN ?= ../../bin
CRFLAGS ?= -Dpreview_mt

SRC_SOURCES := $(shell find src -name '*.cr' 2>/dev/null)
DOC_SOURCE := src/cli.cr

.PHONY: all
all: build
Expand All @@ -43,10 +44,10 @@ $(BUILD_TARGET): $(SRC_SOURCES)

docs: ## Generate API docs
docs: $(SRC_SOURCES)
$(CRYSTAL_BIN) docs -o docs $(DOC_SOURCE)
$(CRYSTAL_BIN) docs

.PHONY: lint
lint: ## Run ameba on ameba's code base
lint: ## Run ameba on its own code base
lint: $(BUILD_TARGET)
$(BUILD_TARGET)

Expand All @@ -56,9 +57,10 @@ spec:
$(CRYSTAL_BIN) spec

.PHONY: clean
clean: ## Remove application binary
clean: ## Remove application binary and API docs
clean:
@rm -f "$(BUILD_TARGET)" "$(BUILD_TARGET).dwarf"
@rm -rf docs

.PHONY: install
install: ## Install application binary into $DESTDIR
Expand All @@ -68,15 +70,14 @@ install: $(BUILD_TARGET)
.PHONY: bin
bin: build
mkdir -p $(SHARD_BIN)
cp $(BUILD_TARGET) $(SHARD_BIN)
cp "$(BUILD_TARGET)" $(SHARD_BIN)

.PHONY: test
test: ## Run the spec suite and linter
test: spec lint

.PHONY: help
help: ## Show this help
@echo
@printf '\033[34mtargets:\033[0m\n'
@grep -hE '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) |\
sort |\
Expand Down
Loading