diff options
author | pacien | 2017-12-02 01:06:20 +0100 |
---|---|---|
committer | pacien | 2017-12-02 01:06:20 +0100 |
commit | 1c75b9dca56f4879798d9c9a5b9c48428e117448 (patch) | |
tree | 19f07dce18795b466a83cef4e0bf355aaf6cf600 /makefile | |
parent | 144b1236f43ccb126415a1a2d518675c00f9f778 (diff) | |
download | morpher-1c75b9dca56f4879798d9c9a5b9c48428e117448.tar.gz |
Add makefile and its doc
Signed-off-by: pacien <pacien.trangirard@pacien.net>
Diffstat (limited to 'makefile')
-rw-r--r-- | makefile | 77 |
1 files changed, 73 insertions, 4 deletions
@@ -1,8 +1,77 @@ | |||
1 | ##### DIRECTORIES | ||
2 | SRC_DIR := src | ||
3 | TEST_DIR := test | ||
4 | INCL_DIR := include | ||
5 | DOC_DIR := doc | ||
6 | BIN_DIR := bin | ||
7 | |||
8 | |||
9 | ##### CC PARAMS | ||
10 | CC := gcc | ||
11 | CFLAGS := -ansi -Wall -pedantic -std=gnu99 -O2 | ||
12 | IFLAGS := -I$(INCL_DIR) | ||
13 | LFLAGS := $(LLFLAGS) -lMLV | ||
14 | |||
15 | |||
16 | ##### UTILS | ||
17 | PERCENT := % | ||
18 | |||
19 | |||
20 | ##### MAIN TARGETS | ||
21 | .PHONY: all test source api-doc report clean | ||
22 | |||
23 | all: source test report; | ||
24 | |||
25 | .SECONDEXPANSION: | ||
26 | source: $$(patsubst $(SRC_DIR)/$$(PERCENT).c,$(BIN_DIR)/$$(PERCENT).o,$$(wildcard $(SRC_DIR)/**/*.c)); | ||
27 | |||
28 | .SECONDEXPANSION: | ||
29 | test: $$(patsubst $(TEST_DIR)/$$(PERCENT).c,$(BIN_DIR)/$$(PERCENT).test,$$(wildcard $(TEST_DIR)/**/*.c)) | ||
30 | $(foreach test,$(filter-out $<,$^),./$(test)) | ||
31 | |||
32 | report: $(DOC_DIR)/project-report.pdf; | ||
33 | |||
34 | clean: clean-bin clean-api-doc clean-report; | ||
35 | |||
36 | |||
37 | ##### BINARIES GENERATION | ||
38 | .PRECIOUS: $(BIN_DIR)/%.o $(BIN_DIR)/%/ | ||
39 | .PHONY: clean-bin | ||
40 | |||
41 | .SECONDEXPANSION: | ||
42 | $(BIN_DIR)/%.o: $$(patsubst $(BIN_DIR)/$$(PERCENT).o,$(SRC_DIR)/$$(PERCENT).c,$$@) | $$(@D)/ | ||
43 | $(CC) $(CFLAGS) $(IFLAGS) -c $< -o $@ | ||
44 | |||
45 | .SECONDEXPANSION: | ||
46 | $(BIN_DIR)/%.test: $$(patsubst $(BIN_DIR)/$$(PERCENT).test,$(TEST_DIR)/$$(PERCENT).c,$$@) source | $$(@D)/ | ||
47 | $(CC) $(CFLAGS) $(IFLAGS) $(BIN_DIR)/**/*.o $< -o $@ $(LFLAGS) | ||
48 | |||
49 | $(BIN_DIR)/%/: | ||
50 | mkdir -p $(@D) | ||
51 | |||
52 | clean-bin: | ||
53 | $(RM) -r $(BIN_DIR)/* | ||
54 | |||
55 | |||
56 | ##### API DOC | ||
57 | .PHONY: api-doc clean-api-doc | ||
58 | |||
1 | api-doc: | 59 | api-doc: |
2 | $(eval TMPDIR := $(shell mktemp -d)) | 60 | $(eval TMPDIR := $(shell mktemp -d)) |
3 | naturaldocs --project $(TMPDIR) --input include/ --input doc/topics/ --output HTML doc/api/ | 61 | naturaldocs --project $(TMPDIR) --input $(INCLUDE_DIR) --input $(DOC_DIR)/topics/ --output HTML $(DOC_DIR)/api/ |
4 | $(RM) -r $(TMPDIR) | 62 | $(RM) -r $(TMPDIR) |
5 | 63 | ||
6 | report: | 64 | clean-api-doc: |
7 | pandoc --template doc/report-template.tex --number-sections --listings \ | 65 | $(RM) -r $(DOC_DIR)/api/* |
8 | --output doc/project-report.pdf doc/project-report.md | 66 | |
67 | |||
68 | ##### REPORT | ||
69 | .PRECIOUS: $(DOC_DIR)/%.pdf | ||
70 | .PHONY: clean-report | ||
71 | |||
72 | .SECONDEXPANSION: | ||
73 | $(DOC_DIR)/%.pdf: $$(patsubst $$(PERCENT).pdf,$$(PERCENT).md,$$@) | ||
74 | pandoc --template $(DOC_DIR)/report-template.tex --number-sections --listings --output $@ $< | ||
75 | |||
76 | clean-report: | ||
77 | $(RM) -r $(DOC_DIR)/project-report.pdf | ||