diff options
-rw-r--r-- | doc/topics/Build.txt | 31 | ||||
-rw-r--r-- | makefile | 77 |
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 @@ | |||
1 | Title: Build | ||
2 | |||
3 | List of the make targets. The global `make all` and `make clean` are also defined. | ||
4 | |||
5 | |||
6 | About: Compiling | ||
7 | |||
8 | > make source | ||
9 | |||
10 | Compiles all modules. | ||
11 | |||
12 | |||
13 | About: Automatic tests | ||
14 | |||
15 | > make test | ||
16 | |||
17 | Compiles and runs all unit tests. | ||
18 | |||
19 | |||
20 | About: API documentation | ||
21 | |||
22 | > make api-doc | ||
23 | |||
24 | Generates the HTML API documentation with Natural Docs v1.5. | ||
25 | |||
26 | |||
27 | About: Project report | ||
28 | |||
29 | > make report | ||
30 | |||
31 | Generates the project report using Pandoc. | ||
@@ -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 | ||