-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
67 lines (54 loc) · 4.04 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
TITLE_COLOR = \033[33m
NO_COLOR = \033[0m
# when executing make, compile all exe's
all: sensor_gateway sensor_node file_creator
test_datamgr:main.c datamgr.c sbuffer.c lib/libdplist.so
gcc -c main.c -Wall -std=c11 -Werror -DSET_MIN_TEMP=10 -DSET_MAX_TEMP=15 -DTIMEOUT=5 -o main.o -fdiagnostics-color=auto
gcc -c datamgr.c -Wall -std=c11 -Werror -DSET_MIN_TEMP=10 -DSET_MAX_TEMP=15 -DTIMEOUT=5 -o datamgr.o -fdiagnostics-color=auto
gcc -c connmgr.c -Wall -std=c11 -Werror -DSET_MIN_TEMP=10 -DSET_MAX_TEMP=20 -DTIMEOUT=5 -o connmgr.o -fdiagnostics-color=auto
gcc -c sbuffer.c -Wall -std=c11 -Werror -DSET_MIN_TEMP=10 -DSET_MAX_TEMP=15 -DTIMEOUT=5 -o sbuffer.o -fdiagnostics-color=auto
gcc main.o connmgr.o datamgr.o sbuffer.o -ldplist -ltcpsock -lpthread -o test -Wall -L./lib -Wl,-rpath=./lib -fdiagnostics-color=auto
# When trying to compile one of the executables, first look for its .c files
# Then check if the libraries are in the lib folder
sensor_gateway : main.c connmgr.c datamgr.c sensor_db.c sbuffer.c lib/libdplist.so lib/libtcpsock.so
@echo "$(TITLE_COLOR)\n***** CPPCHECK *****$(NO_COLOR)"
cppcheck --enable=all --suppress=missingIncludeSystem main.c connmgr.c datamgr.c sensor_db.c sbuffer.c
@echo "$(TITLE_COLOR)\n***** COMPILING sensor_gateway *****$(NO_COLOR)"
gcc -c main.c -Wall -std=c11 -Werror -DSET_MIN_TEMP=10 -DSET_MAX_TEMP=20 -DTIMEOUT=5 -DDEBUG_MODE=1 -o main.o -fdiagnostics-color=auto
gcc -c connmgr.c -Wall -std=c11 -Werror -DSET_MIN_TEMP=10 -DSET_MAX_TEMP=20 -DTIMEOUT=5 -DDEBUG_MODE=1 -o connmgr.o -fdiagnostics-color=auto
gcc -c datamgr.c -Wall -std=c11 -Werror -DSET_MIN_TEMP=10 -DSET_MAX_TEMP=20 -DTIMEOUT=5 -DDEBUG_MODE=1 -o datamgr.o -fdiagnostics-color=auto
gcc -c sensor_db.c -Wall -std=c11 -Werror -DSET_MIN_TEMP=10 -DSET_MAX_TEMP=20 -DTIMEOUT=5 -DDEBUG_MODE=1 -o sensor_db.o -fdiagnostics-color=auto
gcc -c sbuffer.c -Wall -std=c11 -Werror -DSET_MIN_TEMP=10 -DSET_MAX_TEMP=20 -DTIMEOUT=5 -DDEBUG_MODE=1 -o sbuffer.o -fdiagnostics-color=auto
@echo "$(TITLE_COLOR)\n***** LINKING sensor_gateway *****$(NO_COLOR)"
gcc main.o connmgr.o datamgr.o sensor_db.o sbuffer.o -ldplist -ltcpsock -lpthread -o sensor_gateway -Wall -L./lib -Wl -lsqlite3 -fdiagnostics-color=auto
file_creator : file_creator.c
@echo "$(TITLE_COLOR)\n***** COMPILE & LINKING file_creator *****$(NO_COLOR)"
gcc file_creator.c -o file_creator -Wall -fdiagnostics-color=auto
sensor_node : sensor_node.c lib/libtcpsock.so
@echo "$(TITLE_COLOR)\n***** COMPILING sensor_node *****$(NO_COLOR)"
gcc -c sensor_node.c -Wall -std=c11 -Werror -DLOOPS=1 -o sensor_node.o -fdiagnostics-color=auto
@echo "$(TITLE_COLOR)\n***** LINKING sensor_node *****$(NO_COLOR)"
gcc sensor_node.o -ltcpsock -o sensor_node -Wall -L./lib -Wl -fdiagnostics-color=auto
# If you only want to compile one of the libs, this target will match (e.g. make liblist)
libdplist : lib/libdplist.so
libtcpsock : lib/libtcpsock.so
lib/libdplist.so : lib/dplist.c
@echo "$(TITLE_COLOR)\n***** COMPILING LIB dplist *****$(NO_COLOR)"
gcc -c lib/dplist.c -Wall -std=c11 -Werror -fPIC -o lib/dplist.o -fdiagnostics-color=auto
@echo "$(TITLE_COLOR)\n***** LINKING LIB dplist< *****$(NO_COLOR)"
gcc lib/dplist.o -o lib/libdplist.so -Wall -shared -lm -fdiagnostics-color=auto
lib/libtcpsock.so : lib/tcpsock.c
@echo "$(TITLE_COLOR)\n***** COMPILING LIB tcpsock *****$(NO_COLOR)"
gcc -c lib/tcpsock.c -Wall -std=c11 -Werror -fPIC -o lib/tcpsock.o -fdiagnostics-color=auto
@echo "$(TITLE_COLOR)\n***** LINKING LIB tcpsock *****$(NO_COLOR)"
gcc lib/tcpsock.o -o lib/libtcpsock.so -Wall -shared -lm -fdiagnostics-color=auto
# do not look for files called clean, clean-all or this will be always a target
.PHONY : clean clean-all run zip
clean:
rm -rf *.o sensor_gateway sensor_node file_creator *~
clean-all: clean
rm -rf lib/*.so
run : sensor_gateway sensor_node
@echo "Add your own implementation here..."
zip:
zip lab_final.zip main.c errmacros.h connmgr.c connmgr.h datamgr.c datamgr.h sbuffer.c sbuffer.h sensor_db.c sensor_db.h config.h lib/dplist.c lib/dplist.h lib/tcpsock.c lib/tcpsock.h