forked from goToMain/libosdp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
83 lines (63 loc) · 1.63 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
#
# Copyright (c) 2021-2024 Siddharth Chandrasekaran <[email protected]>
#
# SPDX-License-Identifier: Apache-2.0
#
ifeq ($(wildcard config.make),)
$(error run ./configure.sh first. See ./configure.sh -h)
endif
include config.make
O ?= $(BUILD_DIR)
OBJ_LIBOSDP := $(SRC_LIBOSDP:%.c=$(O)/%.o)
OBJ_TEST := $(SRC_TEST:%.c=$(O)/%.o)
CCFLAGS += -Wall -Wextra -O3
ifeq ($(V),)
MAKE := make -s
Q := @
else
Q :=
MAKE := make
endif
.PHONY: all
all: libosdp $(TARGETS)
.PHONY: libosdp
libosdp: $(O)/utils/libutils.a
.PHONY: pd_app
pd_app: $(O)/pd_app.elf
.PHONY: cp_app
cp_app: $(O)/cp_app.elf
.PHONY: libutils
libutils: $(O)/utils/libutils.a
$(O)/%.o: %.c
@echo " CC $<"
@mkdir -p $(@D)
$(Q)$(CC) -c $< $(CCFLAGS) $(CCFLAGS_EXTRA) -o $@
$(O)/libosdp.a: CCFLAGS_EXTRA=-Iutils/include -Iinclude -Isrc -I$(O)
$(O)/libosdp.a: $(OBJ_LIBOSDP)
@echo " AR $(@F)"
$(Q)$(AR) qc $@ $^
$(O)/utils/libutils.a:
$(Q)make -C utils Q=$(Q) O=$(O)/utils CC=$(CC)
## Samples
$(O)/cp_app.elf: $(O)/libosdp.a
@echo "LINK $(@F)"
$(Q)$(CC) $(CCFLAGS) examples/c/cp_app.c -o $@ -Iinclude -L$(O) -losdp
$(O)/pd_app.elf: $(O)/libosdp.a
@echo "LINK $(@F)"
$(Q)$(CC) $(CCFLAGS) examples/c/pd_app.c -o $@ -Iinclude -L$(O) -losdp
## Tests
.PHONY: check
check: CCFLAGS_EXTRA=-DUNIT_TESTING -Iutils/include -Iinclude -Isrc -I$(O)
check: clean $(OBJ_TEST)
@echo "LINK $@"
$(Q)$(CC) $(CCFLAGS) $(OBJ_TEST) -o $(O)/unit-test
$(Q)$(O)/unit-test
## Clean
.PHONY: clean
clean:
$(Q)rm -f $(O)/src/*.o $(O)/src/crypto/*.o $(OBJ_TEST)
$(Q)rm -f $(O)/*.a $(O)/*.elf
$(Q)make -C utils Q=$(Q) O=$(O)/utils clean
.PHONY: distclean
distclean: clean
$(Q)rm -rf config.make $(O)