-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
48 lines (41 loc) · 1.47 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
src=src
include=include
lib=lib
tests=tests
CC=clang
cflags= -Wall -pedantic -I$(include) -g
ldflags= -L$(lib) -lreadline -llang
ldtestflags= -L$(lib) -llang -lcunit -ltests
comp: $(src)/comp.o $(lib)/liblang.a
$(CC) $(ldflags) -o comp $^
tests: $(tests)/testMain.o $(lib)/libtests.a $(lib)/liblang.a
$(CC) $(ldtestflags) -o testMain $^
$(lib)/libtests.a: $(tests)/LinkedList_tests.o $(tests)/Stack_tests.o $(tests)/Parse_tests.o
ar -r $@ $^
$(lib)/liblang.a: $(src)/Parse.o $(src)/LinkedList.o $(src)/Stack.o $(src)/Identifiers.o $(src)/Eval.o $(src)/Vars.o $(src)/BalancedBinaryTree.o $(src)/Type.o $(src)/stdlib/calc.o $(src)/stdlib/ctrl.o $(src)/stdlib/io.o $(src)/stdlib/string.o
ar -r $@ $^
$(src)/%.o : $(src)/%.c
$(CC) $(cflags) -o $@ -c $^
$(src)/stdlib/%.o : $(src)/%.c
$(CC) $(cflags) -o $@ -c $^
$(tests)/%.o : $(tests)/%.c
$(CC) $(cflags) -o $@ -c $^
clean:
@echo "Removing objects files in $(src)..."
#@if [ -e $(src)/**/*.o ]; then rm $(src)/**/*.o; fi
rm $(src)/*.o
rm $(src)/stdlib/*.o
@echo "done."
@echo "Removing libraries files in $(lib)..."
@if [ -e $(lib)/*.a ]; then rm $(lib)/*.a; fi
@echo "done."
@echo "Removing objects files in $(tests)..."
@if [ -e $(tests)/*.o ]; then rm $(tests)/*.o; fi
@echo "done."
@echo "Removing libraries files in $(tests)..."
@if [ -e $(tests)/*.a ]; then rm $(tests)/*.a; fi
@echo "done."
@echo "Removing executables files ..."
@if [ -e comp ]; then rm comp; fi
@if [ -e testMain ]; then rm testMain; fi
@echo "done."