-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathmakefile
91 lines (67 loc) · 1.78 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
# Makefile for Wirepas C Mesh API Lib
# Toolchain
CC := gcc
AS := as
LD := ld
AR := ar
# Paths, including trailing path separator
SOURCEPREFIX :=
BUILDPREFIX := build/
# General compiler flags
CFLAGS := -std=gnu99 -Wall -Werror -Wenum-conversion
# Uncomment the following line only if running with an old stack
#CFLAGS += -DLEGACY_APP_CONFIG
# Uncomment the following line if you want the per endoint data reception
#CFLAGS += -DREGISTER_DATA_PER_ENDPOINT
# Targets definition
LIB_NAME := mesh_api_lib.a
TARGET_LIB := $(BUILDPREFIX)$(LIB_NAME)
SOURCES :=
# Add Api header (including logger)
CFLAGS += -Iapi/
# Include platform module sources
include platform/makefile
# Include WPC generic sources
include wpc/makefile
ifeq ($(proto_api_support),yes)
include wpc_proto/makefile
endif
OBJECTS := $(patsubst $(SOURCEPREFIX)%, \
$(BUILDPREFIX)%, \
$(SOURCES:.c=.o))
# Functions
# Use GCC to automatically generate dependency files for C files.
# Also create the target directory if it does not exist
define COMPILE
echo " CC $(2)"
mkdir -p $(dir $(1))
$(CC) $(CFLAGS) -c -o $(1) $(2)
endef
define LINK_LIB
echo " Linking $(1)"
$(AR) rc -o $(1) $(2)
endef
define CLEAN
echo " Cleaning up"
$(RM) -r $(BUILDPREFIX)
endef
# Target rules
# Use dependency files automatically generated by GCC.
# First collect all C source files
AUTODEPS := $(patsubst $(SOURCEPREFIX)%.c, $(BUILDPREFIX)%.d, $(SOURCES))
ifeq ($(V),1)
# "V=1" on command line, print commands.
else
# Default, do not print commands.
.SILENT:
endif
.PHONY: all
all: lib
lib: $(TARGET_LIB)
.PHONY: clean
clean:
$(call CLEAN)
$(BUILDPREFIX)%.o: $(SOURCEPREFIX)%.c
$(call COMPILE,$@,$<)
$(TARGET_LIB): $(OBJECTS)
$(call LINK_LIB,$@,$^)