-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathMakefile
148 lines (101 loc) · 2.73 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
ifndef DEBUG
# Default: compile for debug
DEBUG=1
endif
#PROFILE=1
valgrind_include_file=/usr/include/valgrind/valgrind.h
ifeq ($(wildcard $(valgrind_include_file)), )
# disable valgrind support
$(info Disabling valgrind support because $(valgrind_include_file) is not found. To enable \
valgrind, install it by running 'sudo apt install valgrind')
VALGRIND_FLAG=-DNVALGRIND
else
VALGRIND_FLAG=
endif
CC = gcc
BASICFLAGS= -pthread -std=c11 -fno-builtin-printf $(VALGRIND_FLAG)
DEBUGFLAGS= -g3
OPTFLAGS= -g3 -finline -march=native -O3 -DNDEBUG
ifeq ($(PROFILE),1)
PROFFLAGS= -g -pg
PLFLAGS= -g -pg
else
PROFFLAGS=
PLFLAGS=
endif
INCLUDE_PATH=-I.
CFLAGS= -Wall -D_GNU_SOURCE $(BASICFLAGS)
ifeq ($(DEBUG),1)
CFLAGS+= $(DEBUGFLAGS) $(PROFFLAGS) $(INCLUDE_PATH)
else
CFLAGS+= $(OPTFLAGS) $(PROFFLAGS) $(INCLUDE_PATH)
endif
LDFLAGS= $(PLFLAGS) $(BASICFLAGS)
LIBS=-lpthread -lrt -lm
C_PROG= test_util.c \
mtask.c tinyos_shell.c terminal.c \
validate_api.c \
$(EXAMPLE_PROG)
EXAMPLE_PROG= $(wildcard *_example*.c)
#
# Add kernel source files here
#
C_SRC= bios.c $(wildcard kernel_*.c) tinyoslib.c symposium.c unit_testing.c console.c
C_OBJ=$(C_SRC:.c=.o)
C_SOURCES= $(C_PROG) $(C_SRC)
C_OBJECTS=$(C_SOURCES:.c=.o)
FIFOS= con0 con1 con2 con3 kbd0 kbd1 kbd2 kbd3
.PHONY: all tests clean distclean doc shorthelp help depend
all: shorthelp mtask tinyos_shell terminal tests fifos examples
tests: test_util validate_api test_example
examples: $(EXAMPLE_PROG:.c=)
#
# Normal apps
#
mtask: mtask.o $(C_OBJ)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
tinyos_shell: tinyos_shell.o $(C_OBJ)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
terminal: terminal.o
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
#
# Tests
#
test_util: test_util.o unit_testing.o $(C_OBJ)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
test_example: test_example.o unit_testing.o $(C_OBJ)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
test_kernel: test_kernel.o unit_testing.o $(C_OBJ)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
validate_api: validate_api.o $(C_OBJ)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
bios_example%: bios_example%.o bios.o
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
# fifos
fifos: $(FIFOS)
$(FIFOS):
mkfifo $@
doc: tinyos3.cfg $(wildcard *.h)
doxygen tinyos3.cfg
distclean: realclean
-touch .depend
-rm *~
realclean:
-rm $(C_PROG:.c=) $(C_OBJECTS) .depend
-rm $(FIFOS)
depend: $(C_SOURCES)
$(CC) $(CFLAGS) -MM $(C_SOURCES) > .depend
clean: realclean depend
ifeq ($(wildcard .depend),)
$(warning No .depend file found. Running recursive make to create it')
$(info $(shell touch .depend && make depend))
include .depend
else
include .depend
endif
shorthelp:
@echo Type \'make help\' to get information on running make
help: manhelp.man
man -l manhelp.man
manhelp.man: manhelp.md
pandoc manhelp.md -s -t man > manhelp.man