- new folder src/ to hold the source code for main project applications
- main.c is in src/
- all core files are subfolder are in src/core/
- modules are in src/modules/
- libs are in src/lib/
- application Makefiles are in src/
- application binary is built in src/ (src/kamailio)
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,162 @@ |
1 |
+# Kamailio build system |
|
2 |
+# |
|
3 |
+# module Makefile |
|
4 |
+#(to be included from each library makefile) |
|
5 |
+# |
|
6 |
+# NAME, MAJOR_VER and MINOR_VER should be pre-defined in the library |
|
7 |
+# makefile |
|
8 |
+# |
|
9 |
+ |
|
10 |
+ifneq ($(makefile_defs_included), 1) |
|
11 |
+$(error "the local makefile does not include Makefile.defs!") |
|
12 |
+endif |
|
13 |
+ |
|
14 |
+ifneq (,$(filter install% %install install, $(MAKECMDGOALS))) |
|
15 |
+compile_for_install:=yes |
|
16 |
+ifeq ($(quiet),verbose) |
|
17 |
+$(info install mode) |
|
18 |
+endif # verbose |
|
19 |
+endif |
|
20 |
+ |
|
21 |
+ifeq ($(NAME),) |
|
22 |
+$(error NAME, MAJOR_VER and MINOR_VER must be defined in the library Makefile) |
|
23 |
+endif |
|
24 |
+ifeq ($(MAJOR_VER),) |
|
25 |
+$(error NAME, MAJOR_VER and MINOR_VER must be defined in the library Makefile) |
|
26 |
+endif |
|
27 |
+ifeq ($(MINOR_VER),) |
|
28 |
+$(error NAME, MAJOR_VER and MINOR_VER must be defined in the library Makefile) |
|
29 |
+endif |
|
30 |
+ifeq ($(BUGFIX_VER),) |
|
31 |
+ BUGFIX_VER:=0 |
|
32 |
+endif |
|
33 |
+ |
|
34 |
+# if config was not loaded (makefile_defs!=1) ignore |
|
35 |
+# the rest of makefile and try only to remake the config |
|
36 |
+ifeq ($(makefile_defs),1) |
|
37 |
+ |
|
38 |
+ |
|
39 |
+ifeq ($(OS), darwin) |
|
40 |
+ LIB_NAME:= \ |
|
41 |
+ $(LIB_PREFIX)$(NAME).$(MAJOR_VER).$(MINOR_VER).$(BUGFIX_VER)$(LIB_SUFFIX) |
|
42 |
+ LIB_RUNTIME_NAME:=$(LIB_PREFIX)$(NAME).$(MAJOR_VER)$(LIB_SUFFIX) |
|
43 |
+ LIB_LINK_NAME:=$(LIB_PREFIX)$(NAME)$(LIB_SUFFIX) |
|
44 |
+ # on darwin we add an extra dependency on a file containing the install |
|
45 |
+ # name (we want to rebuild the library if the install path changed) |
|
46 |
+ # this is needed because instead of a rpath link option, on darwin the |
|
47 |
+ # path to a linked library is taken from the library itself (the path |
|
48 |
+ # is built-in the library) |
|
49 |
+ LIBINAME_F:=libiname.lst |
|
50 |
+ NAME_LD_FLAGS= -compatibility_version $(MAJOR_VER).$(MINOR_VER) \ |
|
51 |
+ -current_version $(MAJOR_VER).$(MINOR_VER).$(BUGFIX_VER) \ |
|
52 |
+ -install_name $(LIB_INSTALL_NAME) |
|
53 |
+ |
|
54 |
+else |
|
55 |
+ LIB_NAME:=$(LIB_PREFIX)$(NAME)$(LIB_SUFFIX).$(MAJOR_VER).$(MINOR_VER) |
|
56 |
+ LIB_RUNTIME_NAME:=$(LIB_PREFIX)$(NAME)$(LIB_SUFFIX).$(MAJOR_VER) |
|
57 |
+ LIB_LINK_NAME:=$(LIB_PREFIX)$(NAME)$(LIB_SUFFIX) |
|
58 |
+ NAME_LD_FLAGS= $(LIB_SONAME)$(LIB_RUNTIME_NAME) |
|
59 |
+ LIBINAME_F:= |
|
60 |
+endif |
|
61 |
+ |
|
62 |
+ifeq ($(strip $(compile_for_install)),yes) |
|
63 |
+ LIB_INSTALL_NAME:=$(lib_target)/$(LIB_RUNTIME_NAME) |
|
64 |
+else |
|
65 |
+ LIB_INSTALL_NAME:=$(shell pwd)/$(LIB_RUNTIME_NAME) |
|
66 |
+endif |
|
67 |
+ |
|
68 |
+ |
|
69 |
+COREPATH ?=../.. |
|
70 |
+ |
|
71 |
+ALLDEP=Makefile $(COREPATH)/Makefile.sources $(COREPATH)/Makefile.rules \ |
|
72 |
+ $(COREPATH)/Makefile.libs $(COREPATH)/config.mak |
|
73 |
+ |
|
74 |
+ |
|
75 |
+ifeq ($(MAKELEVEL), 0) |
|
76 |
+# make called directly in the library dir! |
|
77 |
+else |
|
78 |
+# called by the main Makefile |
|
79 |
+ |
|
80 |
+ALLDEP+=$(COREPATH)/Makefile $(COREPATH)/Makefile.defs |
|
81 |
+ |
|
82 |
+endif |
|
83 |
+ |
|
84 |
+include $(COREPATH)/Makefile.sources |
|
85 |
+ |
|
86 |
+ |
|
87 |
+CFLAGS:=$(LIB_CFLAGS) |
|
88 |
+LDFLAGS:=$(LIB_LDFLAGS) $(NAME_LD_FLAGS) |
|
89 |
+NAME:=$(LIB_NAME) |
|
90 |
+ |
|
91 |
+ |
|
92 |
+include $(COREPATH)/Makefile.targets |
|
93 |
+include $(COREPATH)/Makefile.rules |
|
94 |
+ |
|
95 |
+ifeq (,$(filter clean %clean clean% proper %proper proper%, $(MAKECMDGOALS))) |
|
96 |
+ifneq ($(strip $(LIBINAME_F)),) |
|
97 |
+-include $(LIBINAME_F) |
|
98 |
+ifneq ($(strip $(LIB_INSTALL_NAME)), $(strip $(COMPILED_INAME))) |
|
99 |
+$(shell rm -f $(LIBINAME_F)) |
|
100 |
+endif |
|
101 |
+endif |
|
102 |
+endif |
|
103 |
+ |
|
104 |
+$(NAME): $(LIB_RUNTIME_NAME) $(LIB_LINK_NAME) $(LIBINAME_F) |
|
105 |
+ |
|
106 |
+$(LIB_RUNTIME_NAME): |
|
107 |
+ -@ln -s $(LIB_NAME) $(LIB_RUNTIME_NAME) |
|
108 |
+ |
|
109 |
+$(LIB_LINK_NAME): |
|
110 |
+ifeq ($(OS), freebsd) |
|
111 |
+ -@ln -s $(LIB_RUNTIME_NAME) $(LIB_LINK_NAME) |
|
112 |
+else |
|
113 |
+ -@ln -s $(LIB_NAME) $(LIB_LINK_NAME) |
|
114 |
+endif |
|
115 |
+ |
|
116 |
+.PHONY: link_clean |
|
117 |
+link_clean: |
|
118 |
+ -@rm -f $(LIB_RUNTIME_NAME) |
|
119 |
+ -@rm -f $(LIB_LINK_NAME) |
|
120 |
+ |
|
121 |
+local-clean: link_clean |
|
122 |
+ |
|
123 |
+.PHONY: libiname_clean |
|
124 |
+libiname_clean: |
|
125 |
+ -@rm -f libiname.lst |
|
126 |
+ |
|
127 |
+local-clean: libiname_clean |
|
128 |
+ |
|
129 |
+$(lib_prefix)/$(lib_dir): |
|
130 |
+ mkdir -p $(lib_prefix)/$(lib_dir) |
|
131 |
+ |
|
132 |
+.PHONY: install |
|
133 |
+install: $(LIB_NAME) $(lib_prefix)/$(lib_dir) $(LIBINAME_F) |
|
134 |
+ifeq ($(OS), freebsd) |
|
135 |
+ $(INSTALL_TOUCH) $(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME) |
|
136 |
+ $(INSTALL_LIB) $(LIB_NAME) $(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME) |
|
137 |
+ rm -f $(lib_prefix)/$(lib_dir)/$(LIB_LINK_NAME) |
|
138 |
+ cd $(lib_prefix)/$(lib_dir) ; ln -s $(LIB_RUNTIME_NAME) $(LIB_LINK_NAME) |
|
139 |
+else |
|
140 |
+ $(INSTALL_TOUCH) $(lib_prefix)/$(lib_dir)/$(LIB_NAME) |
|
141 |
+ $(INSTALL_LIB) $(LIB_NAME) $(lib_prefix)/$(lib_dir) |
|
142 |
+ rm -f $(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME) \ |
|
143 |
+ $(lib_prefix)/$(lib_dir)/$(LIB_LINK_NAME) |
|
144 |
+ cd $(lib_prefix)/$(lib_dir) ; ln -s $(LIB_NAME) $(LIB_RUNTIME_NAME) |
|
145 |
+ cd $(lib_prefix)/$(lib_dir) ; ln -s $(LIB_NAME) $(LIB_LINK_NAME) |
|
146 |
+endif |
|
147 |
+ |
|
148 |
+ |
|
149 |
+.PHONY:install-if-newer |
|
150 |
+install-if-newer: $(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME) |
|
151 |
+ |
|
152 |
+$(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME): $(LIB_NAME) $(LIBINAME_F) |
|
153 |
+ @$(MAKE) install |
|
154 |
+ |
|
155 |
+ |
|
156 |
+ifneq ($(strip $(LIBINAME_F)),) |
|
157 |
+$(LIBINAME_F): $(ALLDEP) |
|
158 |
+ @echo "COMPILED_INAME:=$(LIB_INSTALL_NAME)" > $(LIBINAME_F) |
|
159 |
+endif |
|
160 |
+ |
|
161 |
+endif # ifeq ($(makefile_defs),1) |
|
162 |
+include $(COREPATH)/Makefile.cfg |