aboutsummaryrefslogtreecommitdiff
path: root/makefile
diff options
context:
space:
mode:
authorpacien2018-02-20 23:40:06 +0100
committerpacien2018-02-20 23:40:06 +0100
commit5a30c608fd311c8ce05760335d88208982efc4a5 (patch)
treec9fe41f03ec5ce7967ad2f81bca428c7aefdfd4b /makefile
parentb45155c92dbff32510c9cad8b684376e115da086 (diff)
downloadtpc-compiler-5a30c608fd311c8ce05760335d88208982efc4a5.tar.gz
Bootstrap project
Diffstat (limited to 'makefile')
-rw-r--r--makefile58
1 files changed, 58 insertions, 0 deletions
diff --git a/makefile b/makefile
new file mode 100644
index 0000000..9bcb33a
--- /dev/null
+++ b/makefile
@@ -0,0 +1,58 @@
1# UPEM / Compilation / Projet
2# Pacien TRAN-GIRARD, Adam NAILI
3
4# DIRECTORIES
5SRC_DIR := src
6OUT_DIR := out
7DOC_DIR := doc
8
9# INPUT
10LEX_SRC := tpc.lex
11YACC_SRC := tpc.y
12PDF_SRC := rapport.md
13
14# INTERMEDIATE
15LEX_GEN := tpc.yy
16YACC_GEN := tpc.tab
17
18# OUTPUT
19PARSER_BIN := tparser
20COMPIL_BIN := tcompil
21COMMIT_LOG := commits.log
22REPORT_PDF := rapport.pdf
23
24# CC PARAMS
25CC := gcc
26LEX := flex
27YACC := bison
28CFLAGS := -ansi -pedantic -Wall -std=gnu99 -O2
29LFLAGS := -lfl -ly
30IFLAGS += -I$(SRC_DIR) -I$(OUT_DIR)
31
32# RULES
33all: clean $(OUT_DIR)/$(PARSER_BIN)
34
35$(OUT_DIR)/$(LEX_GEN).c: $(SRC_DIR)/$(LEX_SRC)
36 $(LEX) -o $@ $^
37
38$(OUT_DIR)/$(YACC_GEN).c $(OUT_DIR)/$(YACC_GEN).h: $(SRC_DIR)/$(YACC_SRC)
39 $(YACC) --output=$(OUT_DIR)/$(YACC_GEN).c --defines=$(OUT_DIR)/$(YACC_GEN).h -v $^
40
41$(OUT_DIR)/$(LEX_GEN).o: $(OUT_DIR)/$(LEX_GEN).c $(OUT_DIR)/$(YACC_GEN).h
42 $(CC) -o $@ -c $< $(IFLAGS) $(LFLAGS) $(CFLAGS)
43
44$(OUT_DIR)/$(YACC_GEN).o: $(OUT_DIR)/$(YACC_GEN).c
45 $(CC) -o $@ -c $^ $(IFLAGS) $(LFLAGS) $(CFLAGS)
46
47$(OUT_DIR)/$(PARSER_BIN): $(OUT_DIR)/$(LEX_GEN).o $(OUT_DIR)/$(YACC_GEN).o
48 $(CC) -o $@ $^ $(IFLAGS) $(LFLAGS) $(CFLAGS)
49
50$(OUT_DIR)/$(REPORT_PDF): $(DOC_DIR)/$(PDF_SRC)
51 pandoc --template $(DOC_DIR)/report-template.tex --number-sections --listings --output $@ $^
52
53$(OUT_DIR)/$(COMMIT_LOG):
54 git log > $@
55
56clean:
57 rm -rf $(OUT_DIR)/*
58