-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
86 lines (69 loc) · 2.21 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# The name of the source files
SOURCES := main.c
SOURCES += action.c
SOURCES += expr.c
SOURCES += option.c
SOURCES += setter.c
SOURCES += when.c
SOURCES += slow_posix.c
SOURCES += strtable.c
SOURCES += symtable.c
SOURCES += text.c
SOURCES += utf8nop.c
SOURCES += lex_yy.c
SOURCES += y_tab.c
# The name of the executable
EXE = noematic
# Flags for compilation (adding warnings are always good)
CFLAGS := -Wall -Wno-unused-function -g
# Flags for linking (none for the moment)
LDFLAGS =
# Flags for lexer
LEXFLAGS =
# Libraries to link with (none for the moment)
LIBS =
# Use the GCC frontend program when linking
LD = gcc
ifeq ($(DEBUG), 1)
CFLAGS += -DYYDEBUG=1
LEXFLAGS += -d
endif
# This creates a list of object files from the source files
OBJECTS = $(SOURCES:%.c=%.o)
# The first target, this will be the default target if none is specified
# This target tells "make" to make the "all" target
default: all
# Having an "all" target is customary, so one could write "make all"
# It depends on the executable program
all: $(EXE)
# This will link the executable from the object files
$(EXE): $(OBJECTS)
$(LD) $(LDFLAGS) $(OBJECTS) -o $(EXE) $(LIBS)
# This is a target that will compiler all needed source files into object files
# We don't need to specify a command or any rules, "make" will handle it automatically
%.o: %.c
$(CC) $(CFLAGS) -c $<
y_tab.c y_tab.h &: dlg.y
yacc -d $< -Wcounterexamples -o y_tab.c
lex_yy.c: dlg.l
$(LEX) $(LEXFLAGS) -t $< > $@
# Target to clean up after us
clean:
-rm -f $(EXE) # Remove the executable file
-rm -f $(OBJECTS) # Remove the object files
-rm -f y_tab.c y_tab.h # Remove yacc files
-rm -f lex_yy.c # Remove lex file
# Finally we need to tell "make" what source and header file each object file depends on
main.o: main.c strtable.h symtable.h y_tab.h
action.o: action.h option.h setter.h text.h when.h
expr.o: expr.c expr.h
option.o: option.c option.h action.h
setter.o: setter.c setter.h expr.h
when.o: when.c when.h action.h expr.h option.h
slow_posix.o: slow_posix.c slow.h
strtable.o: strtable.c strtable.h
symtable.o: symtable.c symtable.h
text.o: slow.h strtable.h symtable.h text.h
utf8nop.o: utf8.h
lex_yy.c: y_tab.h strtable.h symtable.h utf8.h
y_tab.c: when.h symtable.h