Browse code

core, lib, modules: restructured source code tree

- 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)

Daniel-Constantin Mierla authored on 07/12/2016 11:03:51
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,162 +0,0 @@
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
Browse code

build system: Remove SVN ID and history

Olle E. Johansson authored on 10/01/2015 07:57:18
Showing 1 changed files
... ...
@@ -1,15 +1,8 @@
1
-#
2
-# $Id$
1
+# Kamailio build system
3 2
 #
4 3
 # module Makefile
5 4
 #(to be included from each library makefile)
6 5
 #
7
-# History:
8
-# --------
9
-#  2007-03-16  created by andrei
10
-#  2007-05-19  rebuild on changed install name on darwin  (andrei)
11
-#  2008-06-27  make cfg / config.mak support (andrei)
12
-
13 6
 # NAME, MAJOR_VER and MINOR_VER should be pre-defined in the library 
14 7
 # makefile
15 8
 #
Browse code

makefile: even more quiet

Andrei Pelinescu-Onciul authored on 09/10/2009 19:03:03
Showing 1 changed files
... ...
@@ -20,7 +20,9 @@ endif
20 20
 
21 21
 ifneq	(,$(filter install% %install install, $(MAKECMDGOALS)))
22 22
 compile_for_install:=yes
23
+ifeq ($(quiet),verbose)
23 24
 $(info install mode)
25
+endif # verbose
24 26
 endif
25 27
 
26 28
 ifeq ($(NAME),)
Browse code

makefile: libs install-if-newer minor fix

- install-if-newer did re-install the library every time

Andrei Pelinescu-Onciul authored on 01/10/2009 11:47:05
Showing 1 changed files
... ...
@@ -152,9 +152,10 @@ endif
152 152
 
153 153
 
154 154
 .PHONY:install-if-newer
155
-install-if-newer: $(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME) 
155
+install-if-newer: $(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME)
156 156
 
157
-$(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME): $(LIB_NAME) $(LIBINAME_F) install
157
+$(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME): $(LIB_NAME) $(LIBINAME_F)
158
+	@$(MAKE) install
158 159
 
159 160
 
160 161
 ifneq ($(strip $(LIBINAME_F)),)
Browse code

makefiles: fixes and speed-ups

- make clean, proper, realclean, distclean and maintainer-clean
will work on all the libs in the lib/ directory.
- clean, proper, realclean, distclean and maintainer-clean targets
split into more specific targets: local-clean, clean-modules,
clean-libs, clean-utils (and the same for the others) => make
proper & friends depend now only on the really needed parts =>
much faster.
- doc directories are entered only if a Makefile is present.
- make maintainer-clean properly deletes the config and the
modules list at the end (it doesn't recreate it).

Andrei Pelinescu-Onciul authored on 22/04/2009 13:46:30
Showing 1 changed files
... ...
@@ -123,16 +123,13 @@ link_clean:
123 123
 	-@rm -f $(LIB_RUNTIME_NAME)
124 124
 	-@rm -f $(LIB_LINK_NAME)
125 125
 
126
-clean: link_clean
126
+local-clean: link_clean
127 127
 
128
-ifneq ($(strip $(LIBINAME_F)),)
129 128
 .PHONY: libiname_clean
130
-
131 129
 libiname_clean:
132
-	-@rm -f "$(LIBINAME_F)"
130
+	-@rm -f libiname.lst
133 131
 
134
-clean: libiname_clean
135
-endif
132
+local-clean: libiname_clean
136 133
 
137 134
 $(lib_prefix)/$(lib_dir):
138 135
 	mkdir -p $(lib_prefix)/$(lib_dir)
Browse code

make install: avoid re-linking lib dependent modules

- install doesn't try first to build everything, it will build as
it installs. This will avoid re-linking ser-lib dependent
modules (the normal "make all" would use a local rpath, while "make
install" would change rpath to the install destination dir => the
module needs to be relinked with a different rpath or on Darwin
the lib has to be rebuilt)
- avoid an extra make call on lib install

Andrei Pelinescu-Onciul authored on 19/03/2009 14:32:36
Showing 1 changed files
... ...
@@ -20,7 +20,7 @@ endif
20 20
 
21 21
 ifneq	(,$(filter install% %install install, $(MAKECMDGOALS)))
22 22
 compile_for_install:=yes
23
-$(info install mode => compile_for_install=$(compile_for_install))
23
+$(info install mode)
24 24
 endif
25 25
 
26 26
 ifeq ($(NAME),)
... ...
@@ -157,8 +157,7 @@ endif
157 157
 .PHONY:install-if-newer
158 158
 install-if-newer: $(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME) 
159 159
 
160
-$(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME): $(LIB_NAME) $(LIBINAME_F)
161
-	@$(MAKE) install
160
+$(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME): $(LIB_NAME) $(LIBINAME_F) install
162 161
 
163 162
 
164 163
 ifneq ($(strip $(LIBINAME_F)),)
Browse code

- experimental make cfg /config support: make cfg fore regeneration of the "build" config, saved in config.mak. This config is used instead of including Makefile.defs each time. The config is also automatically generated if missing. The speed improvements are dramatic in most cases: make proper 15 times faster, make clean 8 times, make with generated config 2.6 times faster then before, make rebuilding only one file 9 times faster. E.g.: make cfg include_modules=mysql CPU=pentium-m BASEDIR=/tmp/ser make install # builds default ser + mysql, optimized for pentium-m # and installs in /tmp/ser/usr/local/* make clean # cleans default modules + mysql

Andrei Pelinescu-Onciul authored on 28/06/2008 00:35:25
Showing 1 changed files
... ...
@@ -8,14 +8,19 @@
8 8
 # --------
9 9
 #  2007-03-16  created by andrei
10 10
 #  2007-05-19  rebuild on changed install name on darwin  (andrei)
11
+#  2008-06-27  make cfg / config.mak support (andrei)
11 12
 
12 13
 # NAME, MAJOR_VER and MINOR_VER should be pre-defined in the library 
13 14
 # makefile
14 15
 #
15 16
 
17
+ifneq ($(makefile_defs_included), 1)
18
+$(error "the local makefile does not include Makefile.defs!")
19
+endif
20
+
16 21
 ifneq	(,$(filter install% %install install, $(MAKECMDGOALS)))
17 22
 compile_for_install:=yes
18
-$(warning install mode => compile_for_install=$(compile_for_install))
23
+$(info install mode => compile_for_install=$(compile_for_install))
19 24
 endif
20 25
 
21 26
 ifeq ($(NAME),)
... ...
@@ -31,6 +36,11 @@ ifeq ($(BUGFIX_VER),)
31 36
 	BUGFIX_VER:=0
32 37
 endif
33 38
 
39
+# if config was not loaded (makefile_defs!=1) ignore
40
+# the rest of makefile and try only to remake the config
41
+ifeq ($(makefile_defs),1)
42
+
43
+
34 44
 ifeq ($(OS), darwin)
35 45
 	LIB_NAME:= \
36 46
 	$(LIB_PREFIX)$(NAME).$(MAJOR_VER).$(MINOR_VER).$(BUGFIX_VER)$(LIB_SUFFIX)
... ...
@@ -64,15 +74,11 @@ endif
64 74
 COREPATH ?=../..
65 75
 
66 76
 ALLDEP=Makefile $(COREPATH)/Makefile.sources $(COREPATH)/Makefile.rules \
67
- $(COREPATH)/Makefile.libs
77
+ $(COREPATH)/Makefile.libs $(COREPATH)/config.mak
68 78
 
69 79
 
70 80
 ifeq ($(MAKELEVEL), 0)
71 81
 # make called directly in the library dir!
72
-ifneq ($(makefile_defs), 1)
73
-$(error "the local makefile does not include Makefile.defs!")
74
-endif
75
-
76 82
 else
77 83
 # called by the main Makefile
78 84
 
... ...
@@ -159,3 +165,6 @@ ifneq ($(strip $(LIBINAME_F)),)
159 165
 $(LIBINAME_F): $(ALLDEP)
160 166
 	@echo "COMPILED_INAME:=$(LIB_INSTALL_NAME)" > $(LIBINAME_F)
161 167
 endif
168
+
169
+endif # ifeq ($(makefile_defs),1)
170
+include $(COREPATH)/Makefile.cfg
Browse code

- missing include Makefile.targets

Andrei Pelinescu-Onciul authored on 26/06/2008 10:08:03
Showing 1 changed files
... ...
@@ -88,6 +88,7 @@ LDFLAGS:=$(LIB_LDFLAGS) $(NAME_LD_FLAGS)
88 88
 NAME:=$(LIB_NAME)
89 89
 
90 90
 
91
+include $(COREPATH)/Makefile.targets
91 92
 include $(COREPATH)/Makefile.rules
92 93
 
93 94
 ifeq	(,$(filter clean %clean clean% proper %proper proper%, $(MAKECMDGOALS)))
Browse code

FreeBSD ELF shared library naming convention only allows using names such as libname.so.X, not libname.so.X.Y. Obey it.

Maxim Sobolev authored on 21/05/2008 00:23:41
Showing 1 changed files
... ...
@@ -105,7 +105,11 @@ $(LIB_RUNTIME_NAME):
105 105
 	-@ln -s $(LIB_NAME) $(LIB_RUNTIME_NAME)
106 106
 
107 107
 $(LIB_LINK_NAME):
108
+ifeq ($(OS), freebsd)
109
+	-@ln -s $(LIB_RUNTIME_NAME) $(LIB_LINK_NAME)
110
+else
108 111
 	-@ln -s $(LIB_NAME) $(LIB_LINK_NAME)
112
+endif
109 113
 
110 114
 .PHONY: link_clean
111 115
 link_clean:
... ...
@@ -128,12 +132,19 @@ $(lib_prefix)/$(lib_dir):
128 132
 
129 133
 .PHONY: install
130 134
 install: $(LIB_NAME) $(lib_prefix)/$(lib_dir) $(LIBINAME_F)
135
+ifeq ($(OS), freebsd)
136
+	$(INSTALL_TOUCH) $(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME)
137
+	$(INSTALL_LIB) $(LIB_NAME) $(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME)
138
+	rm -f $(lib_prefix)/$(lib_dir)/$(LIB_LINK_NAME)
139
+	cd $(lib_prefix)/$(lib_dir) ; ln -s $(LIB_RUNTIME_NAME) $(LIB_LINK_NAME)
140
+else
131 141
 	$(INSTALL_TOUCH) $(lib_prefix)/$(lib_dir)/$(LIB_NAME)
132 142
 	$(INSTALL_LIB) $(LIB_NAME) $(lib_prefix)/$(lib_dir)
133 143
 	rm -f $(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME) \
134 144
 			$(lib_prefix)/$(lib_dir)/$(LIB_LINK_NAME) 
135 145
 	cd $(lib_prefix)/$(lib_dir) ; ln -s $(LIB_NAME) $(LIB_RUNTIME_NAME) 
136 146
 	cd $(lib_prefix)/$(lib_dir) ; ln -s $(LIB_NAME) $(LIB_LINK_NAME) 
147
+endif
137 148
 
138 149
 
139 150
 .PHONY:install-if-newer
Browse code

- more darwin build with libs fixes (works now) - sercmd is no longer force-rebuilt every time

Andrei Pelinescu-Onciul authored on 25/05/2007 15:50:11
Showing 1 changed files
... ...
@@ -31,12 +31,6 @@ ifeq ($(BUGFIX_VER),)
31 31
 	BUGFIX_VER:=0
32 32
 endif
33 33
 
34
-ifeq	($(strip $(compile_for_install)),yes)
35
-	LIB_INSTALL_NAME:=$(lib_target)/$(LIB_RUNTIME_NAME)
36
-else
37
-	LIB_INSTALL_NAME:=$(shell pwd)/$(LIB_RUNTIME_NAME)
38
-endif
39
-
40 34
 ifeq ($(OS), darwin)
41 35
 	LIB_NAME:= \
42 36
 	$(LIB_PREFIX)$(NAME).$(MAJOR_VER).$(MINOR_VER).$(BUGFIX_VER)$(LIB_SUFFIX)
... ...
@@ -48,7 +42,7 @@ ifeq ($(OS), darwin)
48 42
 	# path to a linked library is taken from the library itself (the path
49 43
 	# is built-in the library)
50 44
 	LIBINAME_F:=libiname.lst
51
-	NAME_LD_FLAGS:= -compatibility_version $(MAJOR_VER).$(MINOR_VER) \
45
+	NAME_LD_FLAGS= -compatibility_version $(MAJOR_VER).$(MINOR_VER) \
52 46
 					-current_version $(MAJOR_VER).$(MINOR_VER).$(BUGFIX_VER) \
53 47
 					-install_name $(LIB_INSTALL_NAME)
54 48
 
... ...
@@ -56,10 +50,16 @@ else
56 50
 	LIB_NAME:=$(LIB_PREFIX)$(NAME)$(LIB_SUFFIX).$(MAJOR_VER).$(MINOR_VER)
57 51
 	LIB_RUNTIME_NAME:=$(LIB_PREFIX)$(NAME)$(LIB_SUFFIX).$(MAJOR_VER)
58 52
 	LIB_LINK_NAME:=$(LIB_PREFIX)$(NAME)$(LIB_SUFFIX)
59
-	NAME_LD_FLAGS:= $(LIB_SONAME)$(LIB_RUNTIME_NAME)
53
+	NAME_LD_FLAGS= $(LIB_SONAME)$(LIB_RUNTIME_NAME)
60 54
 	LIBINAME_F:=
61 55
 endif
62 56
 
57
+ifeq	($(strip $(compile_for_install)),yes)
58
+	LIB_INSTALL_NAME:=$(lib_target)/$(LIB_RUNTIME_NAME)
59
+else
60
+	LIB_INSTALL_NAME:=$(shell pwd)/$(LIB_RUNTIME_NAME)
61
+endif
62
+
63 63
 
64 64
 COREPATH ?=../..
65 65
 
Browse code

creating links with relative path instead of absolute - helps when installed into other directory than used for run

Vaclav Kubart authored on 24/05/2007 07:47:25
Showing 1 changed files
... ...
@@ -132,10 +132,8 @@ install: $(LIB_NAME) $(lib_prefix)/$(lib_dir) $(LIBINAME_F)
132 132
 	$(INSTALL_LIB) $(LIB_NAME) $(lib_prefix)/$(lib_dir)
133 133
 	rm -f $(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME) \
134 134
 			$(lib_prefix)/$(lib_dir)/$(LIB_LINK_NAME) 
135
-	ln -s $(lib_prefix)/$(lib_dir)/$(LIB_NAME) \
136
-			$(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME) 
137
-	ln -s $(lib_prefix)/$(lib_dir)/$(LIB_NAME) \
138
-			$(lib_prefix)/$(lib_dir)/$(LIB_LINK_NAME) 
135
+	cd $(lib_prefix)/$(lib_dir) ; ln -s $(LIB_NAME) $(LIB_RUNTIME_NAME) 
136
+	cd $(lib_prefix)/$(lib_dir) ; ln -s $(LIB_NAME) $(LIB_LINK_NAME) 
139 137
 
140 138
 
141 139
 .PHONY:install-if-newer
Browse code

- generic build libs fixes - untested darwin support for automatically setting the library path / rebuilding the lib on changed install path (on darwin the library install path is stored in the library itself and from there it is copied in the linked object => if the library path is changed we have to re-link the library instead of re-linking the object that links it)

Andrei Pelinescu-Onciul authored on 21/05/2007 13:55:51
Showing 1 changed files
... ...
@@ -7,11 +7,17 @@
7 7
 # History:
8 8
 # --------
9 9
 #  2007-03-16  created by andrei
10
+#  2007-05-19  rebuild on changed install name on darwin  (andrei)
10 11
 
11 12
 # NAME, MAJOR_VER and MINOR_VER should be pre-defined in the library 
12 13
 # makefile
13 14
 #
14 15
 
16
+ifneq	(,$(filter install% %install install, $(MAKECMDGOALS)))
17
+compile_for_install:=yes
18
+$(warning install mode => compile_for_install=$(compile_for_install))
19
+endif
20
+
15 21
 ifeq ($(NAME),)
16 22
 $(error NAME, MAJOR_VER and MINOR_VER must be defined in the library Makefile)
17 23
 endif
... ...
@@ -25,20 +31,33 @@ ifeq ($(BUGFIX_VER),)
25 31
 	BUGFIX_VER:=0
26 32
 endif
27 33
 
34
+ifeq	($(strip $(compile_for_install)),yes)
35
+	LIB_INSTALL_NAME:=$(lib_target)/$(LIB_RUNTIME_NAME)
36
+else
37
+	LIB_INSTALL_NAME:=$(shell pwd)/$(LIB_RUNTIME_NAME)
38
+endif
39
+
28 40
 ifeq ($(OS), darwin)
29 41
 	LIB_NAME:= \
30 42
 	$(LIB_PREFIX)$(NAME).$(MAJOR_VER).$(MINOR_VER).$(BUGFIX_VER)$(LIB_SUFFIX)
31 43
 	LIB_RUNTIME_NAME:=$(LIB_PREFIX)$(NAME).$(MAJOR_VER)$(LIB_SUFFIX)
32 44
 	LIB_LINK_NAME:=$(LIB_PREFIX)$(NAME)$(LIB_SUFFIX)
45
+	# on darwin we add an extra dependency on a file containing the install 
46
+	# name (we want to rebuild the library if the install path changed)
47
+	# this is needed because instead of a rpath link option, on darwin the
48
+	# path to a linked library is taken from the library itself (the path
49
+	# is built-in the library)
50
+	LIBINAME_F:=libiname.lst
33 51
 	NAME_LD_FLAGS:= -compatibility_version $(MAJOR_VER).$(MINOR_VER) \
34 52
 					-current_version $(MAJOR_VER).$(MINOR_VER).$(BUGFIX_VER) \
35
-					-install_name $(lib_target)/$(LIB_RUNTIME_NAME)
53
+					-install_name $(LIB_INSTALL_NAME)
36 54
 
37 55
 else
38 56
 	LIB_NAME:=$(LIB_PREFIX)$(NAME)$(LIB_SUFFIX).$(MAJOR_VER).$(MINOR_VER)
39 57
 	LIB_RUNTIME_NAME:=$(LIB_PREFIX)$(NAME)$(LIB_SUFFIX).$(MAJOR_VER)
40 58
 	LIB_LINK_NAME:=$(LIB_PREFIX)$(NAME)$(LIB_SUFFIX)
41 59
 	NAME_LD_FLAGS:= $(LIB_SONAME)$(LIB_RUNTIME_NAME)
60
+	LIBINAME_F:=
42 61
 endif
43 62
 
44 63
 
... ...
@@ -71,7 +90,16 @@ NAME:=$(LIB_NAME)
71 90
 
72 91
 include $(COREPATH)/Makefile.rules
73 92
 
74
-$(NAME): $(LIB_RUNTIME_NAME) $(LIB_LINK_NAME)
93
+ifeq	(,$(filter clean %clean clean% proper %proper proper%, $(MAKECMDGOALS)))
94
+ifneq ($(strip $(LIBINAME_F)),)
95
+-include $(LIBINAME_F)
96
+ifneq ($(strip $(LIB_INSTALL_NAME)), $(strip $(COMPILED_INAME)))
97
+$(shell rm -f $(LIBINAME_F))
98
+endif
99
+endif
100
+endif
101
+
102
+$(NAME): $(LIB_RUNTIME_NAME) $(LIB_LINK_NAME) $(LIBINAME_F)
75 103
 
76 104
 $(LIB_RUNTIME_NAME):
77 105
 	-@ln -s $(LIB_NAME) $(LIB_RUNTIME_NAME)
... ...
@@ -86,11 +114,20 @@ link_clean:
86 114
 
87 115
 clean: link_clean
88 116
 
117
+ifneq ($(strip $(LIBINAME_F)),)
118
+.PHONY: libiname_clean
119
+
120
+libiname_clean:
121
+	-@rm -f "$(LIBINAME_F)"
122
+
123
+clean: libiname_clean
124
+endif
125
+
89 126
 $(lib_prefix)/$(lib_dir):
90 127
 	mkdir -p $(lib_prefix)/$(lib_dir)
91 128
 
92 129
 .PHONY: install
93
-install: $(LIB_NAME) $(lib_prefix)/$(lib_dir)
130
+install: $(LIB_NAME) $(lib_prefix)/$(lib_dir) $(LIBINAME_F)
94 131
 	$(INSTALL_TOUCH) $(lib_prefix)/$(lib_dir)/$(LIB_NAME)
95 132
 	$(INSTALL_LIB) $(LIB_NAME) $(lib_prefix)/$(lib_dir)
96 133
 	rm -f $(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME) \
... ...
@@ -104,5 +141,11 @@ install: $(LIB_NAME) $(lib_prefix)/$(lib_dir)
104 141
 .PHONY:install-if-newer
105 142
 install-if-newer: $(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME) 
106 143
 
107
-$(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME): $(LIB_NAME)
144
+$(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME): $(LIB_NAME) $(LIBINAME_F)
108 145
 	@$(MAKE) install
146
+
147
+
148
+ifneq ($(strip $(LIBINAME_F)),)
149
+$(LIBINAME_F): $(ALLDEP)
150
+	@echo "COMPILED_INAME:=$(LIB_INSTALL_NAME)" > $(LIBINAME_F)
151
+endif
Browse code

- fix: s/-/_/ in exported Makefile vars (some shells don't support '-' in variables)

Andrei Pelinescu-Onciul authored on 08/05/2007 09:03:11
Showing 1 changed files
... ...
@@ -86,23 +86,23 @@ link_clean:
86 86
 
87 87
 clean: link_clean
88 88
 
89
-$(lib-prefix)/$(lib-dir):
90
-	mkdir -p $(lib-prefix)/$(lib-dir)
89
+$(lib_prefix)/$(lib_dir):
90
+	mkdir -p $(lib_prefix)/$(lib_dir)
91 91
 
92 92
 .PHONY: install
93
-install: $(LIB_NAME) $(lib-prefix)/$(lib-dir)
94
-	$(INSTALL-TOUCH) $(lib-prefix)/$(lib-dir)/$(LIB_NAME)
95
-	$(INSTALL-LIB) $(LIB_NAME) $(lib-prefix)/$(lib-dir)
96
-	rm -f $(lib-prefix)/$(lib-dir)/$(LIB_RUNTIME_NAME) \
97
-			$(lib-prefix)/$(lib-dir)/$(LIB_LINK_NAME) 
98
-	ln -s $(lib-prefix)/$(lib-dir)/$(LIB_NAME) \
99
-			$(lib-prefix)/$(lib-dir)/$(LIB_RUNTIME_NAME) 
100
-	ln -s $(lib-prefix)/$(lib-dir)/$(LIB_NAME) \
101
-			$(lib-prefix)/$(lib-dir)/$(LIB_LINK_NAME) 
93
+install: $(LIB_NAME) $(lib_prefix)/$(lib_dir)
94
+	$(INSTALL_TOUCH) $(lib_prefix)/$(lib_dir)/$(LIB_NAME)
95
+	$(INSTALL_LIB) $(LIB_NAME) $(lib_prefix)/$(lib_dir)
96
+	rm -f $(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME) \
97
+			$(lib_prefix)/$(lib_dir)/$(LIB_LINK_NAME) 
98
+	ln -s $(lib_prefix)/$(lib_dir)/$(LIB_NAME) \
99
+			$(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME) 
100
+	ln -s $(lib_prefix)/$(lib_dir)/$(LIB_NAME) \
101
+			$(lib_prefix)/$(lib_dir)/$(LIB_LINK_NAME) 
102 102
 
103 103
 
104 104
 .PHONY:install-if-newer
105
-install-if-newer: $(lib-prefix)/$(lib-dir)/$(LIB_RUNTIME_NAME) 
105
+install-if-newer: $(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME) 
106 106
 
107
-$(lib-prefix)/$(lib-dir)/$(LIB_RUNTIME_NAME): $(LIB_NAME)
107
+$(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME): $(LIB_NAME)
108 108
 	@$(MAKE) install
Browse code

- modules are installed by Makefile.modules - rpath is automatically set up for modules using ser libraries on install or make (rpath is different for installed modules and for modules only compiled) - ser libraries are built and installed automatically if a module needs them (the module must define SER_LIBS in its makefile). See print_lib for an example.

Andrei Pelinescu-Onciul authored on 29/03/2007 23:38:02
Showing 1 changed files
... ...
@@ -26,17 +26,18 @@ ifeq ($(BUGFIX_VER),)
26 26
 endif
27 27
 
28 28
 ifeq ($(OS), darwin)
29
-	LIB_NAME:=lib$(NAME).$(MAJOR_VER).$(MINOR_VER).$(BUGFIX_VER).dylib
30
-	LIB_RUNTIME_NAME:=lib$(NAME).$(MAJOR_VER).dylib
31
-	LIB_LINK_NAME:=lib$(NAME).dylib
29
+	LIB_NAME:= \
30
+	$(LIB_PREFIX)$(NAME).$(MAJOR_VER).$(MINOR_VER).$(BUGFIX_VER)$(LIB_SUFFIX)
31
+	LIB_RUNTIME_NAME:=$(LIB_PREFIX)$(NAME).$(MAJOR_VER)$(LIB_SUFFIX)
32
+	LIB_LINK_NAME:=$(LIB_PREFIX)$(NAME)$(LIB_SUFFIX)
32 33
 	NAME_LD_FLAGS:= -compatibility_version $(MAJOR_VER).$(MINOR_VER) \
33 34
 					-current_version $(MAJOR_VER).$(MINOR_VER).$(BUGFIX_VER) \
34 35
 					-install_name $(lib_target)/$(LIB_RUNTIME_NAME)
35 36
 
36 37
 else
37
-	LIB_NAME:=lib$(NAME).so.$(MAJOR_VER).$(MINOR_VER)
38
-	LIB_RUNTIME_NAME:=lib$(NAME).so.$(MAJOR_VER)
39
-	LIB_LINK_NAME:=lib$(NAME).so
38
+	LIB_NAME:=$(LIB_PREFIX)$(NAME)$(LIB_SUFFIX).$(MAJOR_VER).$(MINOR_VER)
39
+	LIB_RUNTIME_NAME:=$(LIB_PREFIX)$(NAME)$(LIB_SUFFIX).$(MAJOR_VER)
40
+	LIB_LINK_NAME:=$(LIB_PREFIX)$(NAME)$(LIB_SUFFIX)
40 41
 	NAME_LD_FLAGS:= $(LIB_SONAME)$(LIB_RUNTIME_NAME)
41 42
 endif
42 43
 
... ...
@@ -72,7 +73,7 @@ include $(COREPATH)/Makefile.rules
72 73
 
73 74
 $(NAME): $(LIB_RUNTIME_NAME) $(LIB_LINK_NAME)
74 75
 
75
-$(LIB_RUNTIME_NAME): 
76
+$(LIB_RUNTIME_NAME):
76 77
 	-@ln -s $(LIB_NAME) $(LIB_RUNTIME_NAME)
77 78
 
78 79
 $(LIB_LINK_NAME):
... ...
@@ -99,3 +100,9 @@ install: $(LIB_NAME) $(lib-prefix)/$(lib-dir)
99 100
 	ln -s $(lib-prefix)/$(lib-dir)/$(LIB_NAME) \
100 101
 			$(lib-prefix)/$(lib-dir)/$(LIB_LINK_NAME) 
101 102
 
103
+
104
+.PHONY:install-if-newer
105
+install-if-newer: $(lib-prefix)/$(lib-dir)/$(LIB_RUNTIME_NAME) 
106
+
107
+$(lib-prefix)/$(lib-dir)/$(LIB_RUNTIME_NAME): $(LIB_NAME)
108
+	@$(MAKE) install
Browse code

- better support for building libraries added (should work on all archs, sets soname, rpath a.s.o). static libs are not yet supported.

Andrei Pelinescu-Onciul authored on 16/03/2007 21:53:54
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,101 @@
1
+#
2
+# $Id$
3
+#
4
+# module Makefile
5
+#(to be included from each library makefile)
6
+#
7
+# History:
8
+# --------
9
+#  2007-03-16  created by andrei
10
+
11
+# NAME, MAJOR_VER and MINOR_VER should be pre-defined in the library 
12
+# makefile
13
+#
14
+
15
+ifeq ($(NAME),)
16
+$(error NAME, MAJOR_VER and MINOR_VER must be defined in the library Makefile)
17
+endif
18
+ifeq ($(MAJOR_VER),)
19
+$(error NAME, MAJOR_VER and MINOR_VER must be defined in the library Makefile)
20
+endif
21
+ifeq ($(MINOR_VER),)
22
+$(error NAME, MAJOR_VER and MINOR_VER must be defined in the library Makefile)
23
+endif
24
+ifeq ($(BUGFIX_VER),)
25
+	BUGFIX_VER:=0
26
+endif
27
+
28
+ifeq ($(OS), darwin)
29
+	LIB_NAME:=lib$(NAME).$(MAJOR_VER).$(MINOR_VER).$(BUGFIX_VER).dylib
30
+	LIB_RUNTIME_NAME:=lib$(NAME).$(MAJOR_VER).dylib
31
+	LIB_LINK_NAME:=lib$(NAME).dylib
32
+	NAME_LD_FLAGS:= -compatibility_version $(MAJOR_VER).$(MINOR_VER) \
33
+					-current_version $(MAJOR_VER).$(MINOR_VER).$(BUGFIX_VER) \
34
+					-install_name $(lib_target)/$(LIB_RUNTIME_NAME)
35
+
36
+else
37
+	LIB_NAME:=lib$(NAME).so.$(MAJOR_VER).$(MINOR_VER)
38
+	LIB_RUNTIME_NAME:=lib$(NAME).so.$(MAJOR_VER)
39
+	LIB_LINK_NAME:=lib$(NAME).so
40
+	NAME_LD_FLAGS:= $(LIB_SONAME)$(LIB_RUNTIME_NAME)
41
+endif
42
+
43
+
44
+COREPATH ?=../..
45
+
46
+ALLDEP=Makefile $(COREPATH)/Makefile.sources $(COREPATH)/Makefile.rules \
47
+ $(COREPATH)/Makefile.libs
48
+
49
+
50
+ifeq ($(MAKELEVEL), 0)
51
+# make called directly in the library dir!
52
+ifneq ($(makefile_defs), 1)
53
+$(error "the local makefile does not include Makefile.defs!")
54
+endif
55
+
56
+else
57
+# called by the main Makefile
58
+
59
+ALLDEP+=$(COREPATH)/Makefile $(COREPATH)/Makefile.defs
60
+
61
+endif
62
+
63
+include $(COREPATH)/Makefile.sources
64
+
65
+
66
+CFLAGS:=$(LIB_CFLAGS)
67
+LDFLAGS:=$(LIB_LDFLAGS) $(NAME_LD_FLAGS)
68
+NAME:=$(LIB_NAME)
69
+
70
+
71
+include $(COREPATH)/Makefile.rules
72
+
73
+$(NAME): $(LIB_RUNTIME_NAME) $(LIB_LINK_NAME)
74
+
75
+$(LIB_RUNTIME_NAME): 
76
+	-@ln -s $(LIB_NAME) $(LIB_RUNTIME_NAME)
77
+
78
+$(LIB_LINK_NAME):
79
+	-@ln -s $(LIB_NAME) $(LIB_LINK_NAME)
80
+
81
+.PHONY: link_clean
82
+link_clean:
83
+	-@rm -f $(LIB_RUNTIME_NAME)
84
+	-@rm -f $(LIB_LINK_NAME)
85
+
86
+clean: link_clean
87
+
88
+$(lib-prefix)/$(lib-dir):
89
+	mkdir -p $(lib-prefix)/$(lib-dir)
90
+
91
+.PHONY: install
92
+install: $(LIB_NAME) $(lib-prefix)/$(lib-dir)
93
+	$(INSTALL-TOUCH) $(lib-prefix)/$(lib-dir)/$(LIB_NAME)
94
+	$(INSTALL-LIB) $(LIB_NAME) $(lib-prefix)/$(lib-dir)
95
+	rm -f $(lib-prefix)/$(lib-dir)/$(LIB_RUNTIME_NAME) \
96
+			$(lib-prefix)/$(lib-dir)/$(LIB_LINK_NAME) 
97
+	ln -s $(lib-prefix)/$(lib-dir)/$(LIB_NAME) \
98
+			$(lib-prefix)/$(lib-dir)/$(LIB_RUNTIME_NAME) 
99
+	ln -s $(lib-prefix)/$(lib-dir)/$(LIB_NAME) \
100
+			$(lib-prefix)/$(lib-dir)/$(LIB_LINK_NAME) 
101
+