-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
170 lines (142 loc) · 4.52 KB
/
Makefile
File metadata and controls
170 lines (142 loc) · 4.52 KB
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#!/usr/bin/make -f
CC ?= gcc
CFLAGS += -Wall -Wextra
BIN_NAME ?= build/lltdResponder
TEST_DIR := build/tests
TEST_CFLAGS := $(CFLAGS) -Itests -IlltdResponder -DLLTD_TESTING
TEST_LDFLAGS :=
ifneq ($(SANITIZE),)
TEST_CFLAGS += -fsanitize=address,undefined -fno-omit-frame-pointer -g
TEST_LDFLAGS += -fsanitize=address,undefined
endif
ifneq ($(COVERAGE),)
TEST_CFLAGS += --coverage -O0 -g
TEST_LDFLAGS += --coverage
endif
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
CFLAGS += -D LINUX
PLATFORM ?= linux-systemd
ifeq ($(PLATFORM),linux-systemd)
LLTD_SRC_FILES = os/linux/daemon/linux-main.c \
os/linux/daemon/linux-ops.c \
lltdResponder/lltdBlock.c \
lltdResponder/lltdTlvOps.c \
lltdResponder/lltdAutomata.c \
lltdResponder/lltdWire.c \
os/linux/lltd_port.c
LLTD_CFLAGS += -DLLTD_BACKEND_SYSTEMD -DLLTD_USE_SYSTEMD
LLTD_LDFLAGS += -lsystemd
else ifeq ($(PLATFORM),linux-embedded)
LLTD_SRC_FILES = os/linux/daemon/linux-embedded-main.c \
os/linux/daemon/linux-ops.c \
lltdResponder/lltdBlock.c \
lltdResponder/lltdTlvOps.c \
lltdResponder/lltdAutomata.c \
lltdResponder/lltdWire.c \
os/linux/lltd_port.c
LLTD_CFLAGS += -DLLTD_BACKEND_EMBEDDED -DLLTD_USE_CONSOLE
else
$(error Unsupported PLATFORM '$(PLATFORM)'; use linux-systemd or linux-embedded)
endif
endif
ifeq ($(UNAME_S),Darwin)
CFLAGS += -D OSX
endif
ifeq ($(UNAME_S),SunOS)
CFLAGS += -D SunOS
endif
ifeq ($(UNAME_S),FreeBSD)
CFLAGS += -D FreeBSD
endif
UNAME_P := $(shell uname -p)
ifeq ($(UNAME_P),x86_64)
CFLAGS += -D AMD64
endif
ifeq ($(UNAME_P),amd64)
CFLAGS += -D AMD64
endif
ifeq ($(UNAME_P),sparc)
CFLAGS += -D SPARC
endif
ifeq ($(UNAME_P),sparc64)
CFLAGS += -D AMD64
endif
ifeq ($(UNAME_P),mips)
CFLAGS += -D MIPS
endif
ifeq ($(UNAME_P),ppc)
CFLAGS += -D PPC
endif
ifeq ($(UNAME_P),powerpc)
CFLAGS += -D PPC
endif
ifeq ($(UNAME_P),ppc64)
CFLAGS += -D PPC
endif
ifneq ($(filter %86,$(UNAME_P)),)
CFLAGS += -D IA32
endif
ifneq ($(filter arm%,$(UNAME_P)),)
CFLAGS += -D ARM
endif
all: $(BIN_NAME)
$(BIN_NAME): $(LLTD_SRC_FILES)
mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(LLTD_CFLAGS) -o $@ $(LLTD_SRC_FILES) $(LLTD_LDFLAGS)
test-check:
@pkg-config --exists cmocka || (echo "cmocka not found (pkg-config cmocka). Install cmocka to run tests." >&2; exit 1)
$(TEST_DIR):
mkdir -p $(TEST_DIR)
test-unit: test-check $(TEST_DIR)
$(CC) $(TEST_CFLAGS) $$(pkg-config --cflags cmocka) \
lltdResponder/lltdWire.c lltdResponder/lltdTlvOps.c tests/lltd_test_port.c tests/test_lltd_tlv_ops.c \
$(TEST_LDFLAGS) $$(pkg-config --libs cmocka) -o $(TEST_DIR)/unit_tests
$(TEST_DIR)/unit_tests
test-integration: test-check $(TEST_DIR)
$(CC) $(TEST_CFLAGS) $$(pkg-config --cflags cmocka) \
lltdResponder/lltdWire.c lltdResponder/lltdTlvOps.c tests/lltd_test_port.c tests/test_lltd_integration.c \
$(TEST_LDFLAGS) $$(pkg-config --libs cmocka) -o $(TEST_DIR)/integration_tests
$(TEST_DIR)/integration_tests
test-privileged: test-check $(TEST_DIR)
$(CC) $(TEST_CFLAGS) $$(pkg-config --cflags cmocka) \
tests/lltd_test_port.c tests/test_lltd_privileged.c \
$(TEST_LDFLAGS) $$(pkg-config --libs cmocka) -o $(TEST_DIR)/privileged_tests
$(TEST_DIR)/privileged_tests
test: test-unit test-integration
ifeq ($(UNAME_S),Linux)
integration-helper: $(TEST_DIR)
$(CC) $(TEST_CFLAGS) \
lltdResponder/lltdWire.c lltdResponder/lltdTlvOps.c tests/lltd_test_port.c \
tests/integration/lltd_integration_smoke.c \
$(TEST_LDFLAGS) -o $(TEST_DIR)/lltd_integration_smoke
integration-test: integration-helper
./tests/integration/linux_veth.sh $(TEST_DIR)/lltd_integration_smoke ./$(BIN_NAME)
else
integration-helper:
@echo "integration-helper is Linux-only; skipping."
integration-test:
@echo "integration-test is Linux-only; skipping."
endif
coverage: COVERAGE=1
coverage: test
clean-tests:
-rm -rf $(TEST_DIR)
-rm -f *.gcda *.gcno *.gcov os/daemon/*.gcda os/daemon/*.gcno os/daemon/*.gcov tests/*.gcda tests/*.gcno tests/*.gcov
clean:
-rm -f $(BIN_NAME)
-rm -rf $(TEST_DIR)
win9x-vxd:
./scripts/build-win9x-vxd.sh
./scripts/gen-inf.py
win16:
./scripts/build-win16.sh
./scripts/gen-inf.py
windows-infs:
./scripts/gen-inf.py
windows-openwatcom: win16 win9x-vxd
macos-universal:
./scripts/macos-build.sh
%: %.c
$(CC) $(CFLAGS) -o $@ $<
.PHONY: all linux clean test test-unit test-integration test-privileged test-check coverage clean-tests win9x-vxd win16 windows-infs windows-openwatcom macos-universal