From a9ef917a6cd1fe342a8efdee90df62bed1a0cfb1 Mon Sep 17 00:00:00 2001 From: pacien Date: Thu, 28 Dec 2017 15:27:29 +0100 Subject: Update make files recipes, add mock output binary Signed-off-by: pacien --- makefile | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) (limited to 'makefile') diff --git a/makefile b/makefile index b4cc66a..7726d33 100644 --- a/makefile +++ b/makefile @@ -6,6 +6,13 @@ DOC_DIR := doc BIN_DIR := bin +##### OUTPUT FILES +BIN := morph +ARCHIVE := upem-c-morphing-adam-pacien.tar.gz +LOG := commits.log +REPORT := project-report.pdf + + ##### CC PARAMS CC := gcc CFLAGS := -ansi -Wall -pedantic -std=gnu99 -O2 @@ -18,21 +25,23 @@ PERCENT := % ##### MAIN TARGETS -.PHONY: all check build report clean +.PHONY: all check build objects report clean all: build check api-doc report; +build: objects $(BIN_DIR)/$(BIN); + .SECONDEXPANSION: -build: $$(patsubst $(SRC_DIR)/$$(PERCENT).c,$(BIN_DIR)/$$(PERCENT).o,$$(wildcard $(SRC_DIR)/**/*.c)); +objects: $$(patsubst $(SRC_DIR)/$$(PERCENT).c,$(BIN_DIR)/$$(PERCENT).o,$$(wildcard $(SRC_DIR)/**/*.c)); .SECONDEXPANSION: check: $$(patsubst $(TEST_DIR)/$$(PERCENT).c,$(BIN_DIR)/$$(PERCENT).test,$$(wildcard $(TEST_DIR)/**/*.c)); -report: $(DOC_DIR)/project-report.pdf $(DOC_DIR)/commits.log; +report: $(DOC_DIR)/$(REPORT) $(DOC_DIR)/$(LOG); clean: clean-bin clean-api-doc clean-report clean-archive; -archive: upem-c-morphing-adam-pacien.tar.gz; +archive: $(ARCHIVE); ##### BINARIES GENERATION @@ -44,10 +53,13 @@ $(BIN_DIR)/%.o: $$(patsubst $(BIN_DIR)/$$(PERCENT).o,$(SRC_DIR)/$$(PERCENT).c,$$ $(CC) $(CFLAGS) $(IFLAGS) -c $< -o $@ .SECONDEXPANSION: -$(BIN_DIR)/%.test: $$(patsubst $(BIN_DIR)/$$(PERCENT).test,$(TEST_DIR)/$$(PERCENT).c,$$@) build | $$(@D)/ +$(BIN_DIR)/%.test: $$(patsubst $(BIN_DIR)/$$(PERCENT).test,$(TEST_DIR)/$$(PERCENT).c,$$@) objects | $$(@D)/ $(CC) $(CFLAGS) $(IFLAGS) $(BIN_DIR)/**/*.o $< -o $@ $(LFLAGS) ./$@ +$(BIN_DIR)/$(BIN): $(SRC_DIR)/main.c + $(CC) $(CFLAGS) $(IFLAGS) $(BIN_DIR)/**/*.o $< -o $@ $(LFLAGS) + $(BIN_DIR)/%/: mkdir -p $(@D) @@ -68,28 +80,28 @@ clean-api-doc: ##### REPORT -.PRECIOUS: $(DOC_DIR)/%.pdf $(DOC_DIR)/commits.log +.PRECIOUS: $(DOC_DIR)/%.pdf $(DOC_DIR)/$(LOG) .PHONY: clean-report .SECONDEXPANSION: $(DOC_DIR)/%.pdf: $$(patsubst $$(PERCENT).pdf,$$(PERCENT).md,$$@) pandoc --template $(DOC_DIR)/report-template.tex --number-sections --listings --output $@ $< -$(DOC_DIR)/commits.log: +$(DOC_DIR)/$(LOG): git log > $@ clean-report: - $(RM) -r $(DOC_DIR)/project-report.pdf - $(RM) -r $(DOC_DIR)/commits.log + $(RM) $(DOC_DIR)/$(REPORT) + $(RM) $(DOC_DIR)/$(LOG) ##### ARCHIVE -.PRECIOUS: upem-c-morphing-adam-pacien.tar.gz +.PRECIOUS: $(ARCHIVE) .PHONY: clean-archive -upem-c-morphing-adam-pacien.tar.gz: build check clean report +$(ARCHIVE): check clean report touch $@ tar --exclude-vcs --exclude=./$@ -zcvf ./$@ . clean-archive: - $(RM) upem-c-morphing-adam-pacien.tar.gz + $(RM) $(ARCHIVE) -- cgit v1.2.3