summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpacien2017-12-02 01:06:20 +0100
committerpacien2017-12-02 01:06:20 +0100
commit1c75b9dca56f4879798d9c9a5b9c48428e117448 (patch)
tree19f07dce18795b466a83cef4e0bf355aaf6cf600
parent144b1236f43ccb126415a1a2d518675c00f9f778 (diff)
downloadmorpher-1c75b9dca56f4879798d9c9a5b9c48428e117448.tar.gz
Add makefile and its doc
Signed-off-by: pacien <pacien.trangirard@pacien.net>
-rw-r--r--doc/topics/Build.txt31
-rw-r--r--makefile77
2 files changed, 104 insertions, 4 deletions
diff --git a/doc/topics/Build.txt b/doc/topics/Build.txt
new file mode 100644
index 0000000..c461434
--- /dev/null
+++ b/doc/topics/Build.txt
@@ -0,0 +1,31 @@
1Title: Build
2
3List of the make targets. The global `make all` and `make clean` are also defined.
4
5
6About: Compiling
7
8> make source
9
10Compiles all modules.
11
12
13About: Automatic tests
14
15> make test
16
17Compiles and runs all unit tests.
18
19
20About: API documentation
21
22> make api-doc
23
24Generates the HTML API documentation with Natural Docs v1.5.
25
26
27About: Project report
28
29> make report
30
31Generates the project report using Pandoc.
diff --git a/makefile b/makefile
index 83f52fb..bc61f45 100644
--- a/makefile
+++ b/makefile
@@ -1,8 +1,77 @@
1##### DIRECTORIES
2SRC_DIR := src
3TEST_DIR := test
4INCL_DIR := include
5DOC_DIR := doc
6BIN_DIR := bin
7
8
9##### CC PARAMS
10CC := gcc
11CFLAGS := -ansi -Wall -pedantic -std=gnu99 -O2
12IFLAGS := -I$(INCL_DIR)
13LFLAGS := $(LLFLAGS) -lMLV
14
15
16##### UTILS
17PERCENT := %
18
19
20##### MAIN TARGETS
21.PHONY: all test source api-doc report clean
22
23all: source test report;
24
25.SECONDEXPANSION:
26source: $$(patsubst $(SRC_DIR)/$$(PERCENT).c,$(BIN_DIR)/$$(PERCENT).o,$$(wildcard $(SRC_DIR)/**/*.c));
27
28.SECONDEXPANSION:
29test: $$(patsubst $(TEST_DIR)/$$(PERCENT).c,$(BIN_DIR)/$$(PERCENT).test,$$(wildcard $(TEST_DIR)/**/*.c))
30 $(foreach test,$(filter-out $<,$^),./$(test))
31
32report: $(DOC_DIR)/project-report.pdf;
33
34clean: 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
52clean-bin:
53 $(RM) -r $(BIN_DIR)/*
54
55
56##### API DOC
57.PHONY: api-doc clean-api-doc
58
1api-doc: 59api-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
6report: 64clean-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
76clean-report:
77 $(RM) -r $(DOC_DIR)/project-report.pdf