Skip to content

Commit

Permalink
Refactor the Makefile
Browse files Browse the repository at this point in the history
The previous version of the Makefile used features which are specific to
GNU Make and therefore does not works on BSD systems. This new version,
which is much more simpler, works both on GNU Make and BSD Make (tested
on FreeBSD 12.1).
  • Loading branch information
breard-r committed Aug 2, 2020
1 parent f2e23b2 commit a5b59e7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [Unreleased]

### Fixed
- The Makefile now works on FreeBSD. It should also work on other BSD although it has not been tested.


## [0.9.0] - 2020-08-01

### Added
Expand Down
35 changes: 14 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,27 @@ DATAROOTDIR = $(PREFIX)/share
DATADIR = $(DATAROOTDIR)
SYSCONFDIR = /etc
TARGET_DIR = ./target/release
EXE_NAMES = acmed \
tacd
EXE_FILES = $(foreach name,$(EXE_NAMES),$(TARGET_DIR)/$(name))
MAN_SRC_DIR = ./man/en
MAN_DST_DIR = $(TARGET_DIR)/man
MAN_SRC = acmed.8 \
acmed.toml.5 \
tacd.8
MAN_FILES = $(foreach name,$(MAN_SRC),$(MAN_DST_DIR)/$(name).gz)

all: update $(EXE_FILES) man
all: update acmed tacd man

man: $(MAN_DST_DIR) $(MAN_FILES)
update:
cargo update

$(EXE_NAMES): %: $(TARGET_DIR)/%
acmed:
cargo build --release --bin acmed
strip "$(TARGET_DIR)/acmed"

$(EXE_FILES): $(TARGET_DIR)/%: %/Cargo.toml
cargo build --release --bin $(subst /Cargo.toml,,$<)
strip $@
tacd:
cargo build --release --bin tacd
strip "$(TARGET_DIR)/tacd"

$(MAN_DST_DIR):
man:
@mkdir -p $(MAN_DST_DIR)

$(MAN_DST_DIR)/%.gz: $(MAN_SRC_DIR)/%
gzip <"$<" >"$@"

update:
cargo update
gzip <"$(MAN_SRC_DIR)/acmed.8" >"$(MAN_DST_DIR)/acmed.8.gz"
gzip <"$(MAN_SRC_DIR)/acmed.toml.5" >"$(MAN_DST_DIR)/acmed.toml.5.gz"
gzip <"$(MAN_SRC_DIR)/tacd.8" >"$(MAN_DST_DIR)/tacd.8.gz"

install:
install -D -m 0755 $(TARGET_DIR)/acmed $(DESTDIR)$(BINDIR)/acmed
Expand All @@ -48,4 +41,4 @@ install:
clean:
cargo clean

.PHONY: $(EXE_NAMES) all clean install man update
.PHONY: all update acmed tacd man install clean

0 comments on commit a5b59e7

Please sign in to comment.