-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
290 lines (257 loc) · 12.6 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
#*********************************************************************************************************
# libexosip Makefile
# target -> libexosip.a
# libexosip.so
# sip_reg
#*********************************************************************************************************
#*********************************************************************************************************
# include config.mk
#*********************************************************************************************************
CONFIG_MK_EXIST = $(shell if [ -f ../config.mk ]; then echo exist; else echo notexist; fi;)
ifeq ($(CONFIG_MK_EXIST), exist)
include ../config.mk
else
CONFIG_MK_EXIST = $(shell if [ -f config.mk ]; then echo exist; else echo notexist; fi;)
ifeq ($(CONFIG_MK_EXIST), exist)
include config.mk
else
CONFIG_MK_EXIST =
endif
endif
#*********************************************************************************************************
# check configure
#*********************************************************************************************************
check_defined = \
$(foreach 1,$1,$(__check_defined))
__check_defined = \
$(if $(value $1),, \
$(error Undefined $1$(if $(value 2), ($(strip $2)))))
$(call check_defined, CONFIG_MK_EXIST, Please configure this project in RealCoder or \
create a config.mk file!)
$(call check_defined, SYLIXOS_BASE_PATH, SylixOS base project path)
$(call check_defined, TOOLCHAIN_PREFIX, the prefix name of toolchain)
$(call check_defined, DEBUG_LEVEL, debug level(debug or release))
#*********************************************************************************************************
# configure area you can set the following config to you own system
# FPUFLAGS (-mfloat-abi=softfp -mfpu=vfpv3 ...)
# CPUFLAGS (-mcpu=arm920t ...)
# NOTICE: libsylixos, BSP and other kernel modules projects CAN NOT use vfp!
#*********************************************************************************************************
FPUFLAGS =
CPUFLAGS = -mcpu=arm920t $(FPUFLAGS)
#*********************************************************************************************************
# toolchain select
#*********************************************************************************************************
CC = $(TOOLCHAIN_PREFIX)gcc
CXX = $(TOOLCHAIN_PREFIX)g++
AS = $(TOOLCHAIN_PREFIX)gcc
AR = $(TOOLCHAIN_PREFIX)ar
LD = $(TOOLCHAIN_PREFIX)g++
#*********************************************************************************************************
# do not change the following code
# buildin internal application source
#*********************************************************************************************************
#*********************************************************************************************************
# libexosip src(s) file
#*********************************************************************************************************
LIB_SRCS = \
exosip/src/eXcall_api.c \
exosip/src/eXconf.c \
exosip/src/eXinsubscription_api.c \
exosip/src/eXmessage_api.c \
exosip/src/eXoptions_api.c \
exosip/src/eXosip.c \
exosip/src/eXpublish_api.c \
exosip/src/eXrefer_api.c \
exosip/src/eXregister_api.c \
exosip/src/eXsubscription_api.c \
exosip/src/eXtl_dtls.c \
exosip/src/eXtl_tcp.c \
exosip/src/eXtl_tls.c \
exosip/src/eXtl_udp.c \
exosip/src/eXtransport.c \
exosip/src/eXutils.c \
exosip/src/inet_ntop.c \
exosip/src/jauth.c \
exosip/src/jcall.c \
exosip/src/jcallback.c \
exosip/src/jdialog.c \
exosip/src/jevents.c \
exosip/src/jnotify.c \
exosip/src/jpipe.c \
exosip/src/jpublish.c \
exosip/src/jreg.c \
exosip/src/jrequest.c \
exosip/src/jresponse.c \
exosip/src/jsubscribe.c \
exosip/src/milenage.c \
exosip/src/misc.c \
exosip/src/rijndael.c \
exosip/src/sdp_offans.c \
exosip/src/udp.c \
#*********************************************************************************************************
# sip_reg src(s) file
#*********************************************************************************************************
EXE_SRCS = \
exosip/tools/sip_reg.c
#*********************************************************************************************************
# build path
#*********************************************************************************************************
ifeq ($(DEBUG_LEVEL), debug)
OUTDIR = Debug
else
OUTDIR = Release
endif
OUTPATH = ./$(OUTDIR)
OBJPATH = $(OUTPATH)/obj
DEPPATH = $(OUTPATH)/dep
#*********************************************************************************************************
# target
#*********************************************************************************************************
LIB = $(OUTPATH)/libexosip.a
DLL = $(OUTPATH)/libexosip.so
EXE = $(OUTPATH)/sip_reg
#*********************************************************************************************************
# libexosip objects
#*********************************************************************************************************
LIB_OBJS = $(addprefix $(OBJPATH)/, $(addsuffix .o, $(basename $(LIB_SRCS))))
LIB_DEPS = $(addprefix $(DEPPATH)/, $(addsuffix .d, $(basename $(LIB_SRCS))))
#*********************************************************************************************************
# sip_reg objects
#*********************************************************************************************************
EXE_OBJS = $(addprefix $(OBJPATH)/, $(addsuffix .o, $(basename $(EXE_SRCS))))
EXE_DEPS = $(addprefix $(DEPPATH)/, $(addsuffix .d, $(basename $(EXE_SRCS))))
#*********************************************************************************************************
# include path
#*********************************************************************************************************
INCDIR = -I"$(SYLIXOS_BASE_PATH)/libsylixos/SylixOS"
INCDIR += -I"$(SYLIXOS_BASE_PATH)/libsylixos/SylixOS/include"
INCDIR += -I"$(SYLIXOS_BASE_PATH)/libsylixos/SylixOS/include/inet"
INCDIR += -I"../libosip/osip/include"
INCDIR += -I"./exosip/include"
#*********************************************************************************************************
# compiler preprocess
#*********************************************************************************************************
DSYMBOL = -DSYLIXOS
DSYMBOL += -DSYLIXOS_LIB
#*********************************************************************************************************
# depend dynamic library
#*********************************************************************************************************
DEPEND_DLL = -losip -lcextern
EXE_DEPEND_DLL = -lexosip -losip -lcextern -lvpmpdm
#*********************************************************************************************************
# depend dynamic library search path
#*********************************************************************************************************
DEPEND_DLL_PATH = -L"$(SYLIXOS_BASE_PATH)/libcextern/$(OUTDIR)"
DEPEND_DLL_PATH += -L"../libosip/$(OUTDIR)"
EXE_DEPEND_DLL_PATH = -L"$(SYLIXOS_BASE_PATH)/libcextern/$(OUTDIR)"
EXE_DEPEND_DLL_PATH += -L"$(SYLIXOS_BASE_PATH)/libsylixos/$(OUTDIR)"
EXE_DEPEND_DLL_PATH += -L"../libosip/$(OUTDIR)"
EXE_DEPEND_DLL_PATH += -L$(OUTPATH)
#*********************************************************************************************************
# compiler optimize
#*********************************************************************************************************
ifeq ($(DEBUG_LEVEL), debug)
OPTIMIZE = -O0 -g3 -gdwarf-2
else
OPTIMIZE = -O2 -g1 -gdwarf-2 # Do NOT use -O3 and -Os
endif # -Os is not align for function
# loop and jump.
#*********************************************************************************************************
# depends and compiler parameter (cplusplus in kernel MUST NOT use exceptions and rtti)
#*********************************************************************************************************
DEPENDFLAG = -MM
CXX_EXCEPT = -fno-exceptions -fno-rtti
COMMONFLAGS = $(CPUFLAGS) $(OPTIMIZE) -Wall -fmessage-length=0 -fsigned-char -fno-short-enums
ASFLAGS = -x assembler-with-cpp $(DSYMBOL) $(INCDIR) $(COMMONFLAGS) -c
CFLAGS = $(DSYMBOL) $(INCDIR) $(COMMONFLAGS) -fPIC -c
CXXFLAGS = $(DSYMBOL) $(INCDIR) $(CXX_EXCEPT) $(COMMONFLAGS) -fPIC -c
ARFLAGS = -r
#*********************************************************************************************************
# define some useful variable
#*********************************************************************************************************
DEPEND = $(CC) $(DEPENDFLAG) $(CFLAGS)
DEPEND.d = $(subst -g ,,$(DEPEND))
COMPILE.S = $(AS) $(ASFLAGS)
COMPILE_VFP.S = $(AS) $(ASFLAGS)
COMPILE.c = $(CC) $(CFLAGS)
COMPILE.cxx = $(CXX) $(CXXFLAGS)
#*********************************************************************************************************
# target
#*********************************************************************************************************
all: $(LIB) $(DLL) $(EXE)
@echo create "$(LIB) $(DLL) $(EXE)" success.
#*********************************************************************************************************
# include depends
#*********************************************************************************************************
ifneq ($(MAKECMDGOALS), clean)
ifneq ($(MAKECMDGOALS), clean_project)
sinclude $(LIB_DEPS) $(EXE_DEPS)
endif
endif
#*********************************************************************************************************
# create depends files
#*********************************************************************************************************
$(DEPPATH)/%.d: %.c
@echo creating $@
@if [ ! -d "$(dir $@)" ]; then mkdir -p "$(dir $@)"; fi
@rm -f $@; \
echo -n '$@ $(addprefix $(OBJPATH)/, $(dir $<))' > $@; \
$(DEPEND.d) $< >> $@ || rm -f $@; exit;
$(DEPPATH)/%.d: %.cpp
@echo creating $@
@if [ ! -d "$(dir $@)" ]; then mkdir -p "$(dir $@)"; fi
@rm -f $@; \
echo -n '$@ $(addprefix $(OBJPATH)/, $(dir $<))' > $@; \
$(DEPEND.d) $< >> $@ || rm -f $@; exit;
#*********************************************************************************************************
# compile source files
#*********************************************************************************************************
$(OBJPATH)/%.o: %.S
@if [ ! -d "$(dir $@)" ]; then mkdir -p "$(dir $@)"; fi
$(COMPILE.S) $< -o $@
$(OBJPATH)/%.o: %.c
@if [ ! -d "$(dir $@)" ]; then mkdir -p "$(dir $@)"; fi
$(COMPILE.c) $< -o $@
$(OBJPATH)/%.o: %.cpp
@if [ ! -d "$(dir $@)" ]; then mkdir -p "$(dir $@)"; fi
$(COMPILE.cxx) $< -o $@
#*********************************************************************************************************
# link libexosip.a object files
#*********************************************************************************************************
$(LIB): $(LIB_OBJS)
$(AR) $(ARFLAGS) $(LIB) $(LIB_OBJS)
#*********************************************************************************************************
# link libexosip.so object files
#*********************************************************************************************************
$(DLL): $(LIB_OBJS)
$(LD) $(CPUFLAGS) -nostdlib -fPIC -shared -o $(DLL) $(LIB_OBJS) \
$(DEPEND_DLL_PATH) $(DEPEND_DLL) -lm -lgcc
#*********************************************************************************************************
# link sip_reg object files
#*********************************************************************************************************
$(EXE): $(EXE_OBJS)
$(LD) $(CPUFLAGS) -nostdlib -fPIC -shared -o $(EXE) $(EXE_OBJS) \
$(EXE_DEPEND_DLL_PATH) $(EXE_DEPEND_DLL) -lm -lgcc
#*********************************************************************************************************
# clean
#*********************************************************************************************************
.PHONY: clean
.PHONY: clean_project
#*********************************************************************************************************
# clean objects
#*********************************************************************************************************
clean:
-rm -rf $(LIB)
-rm -rf $(DLL)
-rm -rf $(EXE)
-rm -rf $(OBJPATH)
-rm -rf $(DEPPATH)
#*********************************************************************************************************
# clean project
#*********************************************************************************************************
clean_project:
-rm -rf $(OUTPATH)
#*********************************************************************************************************
# END
#*********************************************************************************************************