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 5 changed files
... ...
@@ -41,7 +41,8 @@
41 41
 #               logic when using group_include (greger)
42 42
 #  2007-03-01  fail if a module or a required utility make fail unless 
43 43
 #              err_fail=0; don't try to make modules with no Makefiles (andrei)
44
-#  2007-03-16  moved the exports to Makefile.defs
44
+#  2007-03-16  moved the exports to Makefile.defs (andrei)
45
+#  2007-03-29  install-modules changed to use make -C modpath install (andrei)
45 46
 
46 47
 auto_gen=lex.yy.c cfg.tab.c #lexx, yacc etc
47 48
 auto_gen_others=cfg.tab.h  # auto generated, non-c
... ...
@@ -326,6 +327,7 @@ tar:
326 326
 		--exclude=CVS* \
327 327
 		--exclude=.svn* \
328 328
 		--exclude=.cvsignore \
329
+		--exclude=librpath.lst \
329 330
 		--exclude=*.[do] \
330 331
 		--exclude=*.so \
331 332
 		--exclude=*.il \
... ...
@@ -391,7 +393,7 @@ modules-doc:
391 391
 	done 
392 392
 
393 393
 .PHONY: install
394
-install: all mk-install-dirs install-cfg install-bin install-modules \
394
+install: install-bin install-modules install-cfg \
395 395
 	install-doc install-man install-utils
396 396
 		mv -f $(bin-prefix)/$(bin-dir)/sc $(bin-prefix)/$(bin-dir)/serctl #fix
397 397
 
... ...
@@ -440,23 +442,18 @@ install-cfg: $(cfg-prefix)/$(cfg-dir)
440 440
 		$(INSTALL-CFG) etc/dictionary.ser $(cfg-prefix)/$(cfg-dir)
441 441
 #		$(INSTALL-CFG) etc/ser.cfg $(cfg-prefix)/$(cfg-dir)
442 442
 
443
-install-bin: $(bin-prefix)/$(bin-dir) 
444
-		$(INSTALL-TOUCH) $(bin-prefix)/$(bin-dir)/ser 
445
-		$(INSTALL-BIN) ser $(bin-prefix)/$(bin-dir)
443
+install-bin: $(bin-prefix)/$(bin-dir) $(NAME)
444
+		$(INSTALL-TOUCH) $(bin-prefix)/$(bin-dir)/$(NAME)
445
+		$(INSTALL-BIN) $(NAME) $(bin-prefix)/$(bin-dir)
446 446
 
447
-install-modules: modules $(modules-prefix)/$(modules-dir)
448
-	@for r in $(modules_full_path) "" ; do \
449
-		if [ -n "$$r" ]; then \
450
-			if [ -f "$$r" ]; then \
451
-				$(INSTALL-TOUCH) \
452
-					$(modules-prefix)/$(modules-dir)/`basename "$$r"` ; \
453
-				$(INSTALL-MODULES)  "$$r"  $(modules-prefix)/$(modules-dir) ; \
454
-			else \
455
-				echo "ERROR: module $$r not compiled" ; \
456
-				if [ ${err_fail} = 1 ] ; then \
457
-					exit 1; \
458
-				fi ; \
459
-			fi ;\
447
+install-modules: $(modules-prefix)/$(modules-dir)
448
+	@for r in $(modules) "" ; do \
449
+		if [ -n "$$r" -a -r "$$r/Makefile" ]; then \
450
+			echo  "" ; \
451
+			echo  "" ; \
452
+			if ! $(MAKE) -C $$r install && [ ${err_fail} = 1 ] ; then \
453
+				exit 1; \
454
+			fi ; \
460 455
 		fi ; \
461 456
 	done; true
462 457
 
... ...
@@ -71,7 +71,7 @@ MAIN_NAME=ser
71 71
 VERSION = 2
72 72
 PATCHLEVEL = 1
73 73
 SUBLEVEL =  0
74
-EXTRAVERSION = -dev1
74
+EXTRAVERSION = -dev2
75 75
 
76 76
 SER_VER = $(shell expr $(VERSION) \* 1000000 + $(PATCHLEVEL) \* 1000 + \
77 77
 			$(SUBLEVEL) )
... ...
@@ -1266,6 +1266,8 @@ endif
1266 1266
 YACC_FLAGS=-d -b cfg
1267 1267
 # on solaris add -lxnet (e.g. LIBS= -lxnet)
1268 1268
 LIBS= -ldl -lresolv
1269
+LIB_PREFIX:=lib
1270
+LIB_SUFFIX:=.so
1269 1271
 
1270 1272
 
1271 1273
 #os specific stuff
... ...
@@ -1455,6 +1457,7 @@ ifeq ($(OS), darwin)
1455 1455
 	LDFLAGS=        # darwin doesn't like -O2 or -E
1456 1456
 	MOD_LDFLAGS:= -bundle -bundle_loader ../../$(MAIN_NAME)
1457 1457
 	LIB_LDFLAGS:= -dynamiclib
1458
+	LIB_SUFFIX:=.dylib
1458 1459
 	# on darwin soname should include the full path
1459 1460
 	# (it kind of combines rpath & soname)
1460 1461
 	LIB_SONAME=
... ...
@@ -1497,7 +1500,8 @@ endif
1497 1497
 #export relevant variables to the sub-makes
1498 1498
 export RELEASE OS ARCH
1499 1499
 export DEFS PROFILE CC LD MKDEP MKTAGS CFLAGS LDFLAGS INCLUDES MOD_CFLAGS \
1500
-		MOD_LDFLAGS LIB_CFLAGS LIB_LDFLAGS LIB_SONAME LD_RPATH
1500
+		MOD_LDFLAGS LIB_CFLAGS LIB_LDFLAGS LIB_SONAME LD_RPATH \
1501
+		LIB_SUFFIX LIB_PREFIX
1501 1502
 export LIBS
1502 1503
 export LEX YACC YACC_FLAGS
1503 1504
 export PREFIX LOCALBASE
... ...
@@ -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 72
 
73 73
 $(NAME): $(LIB_RUNTIME_NAME) $(LIB_LINK_NAME)
74 74
 
75
-$(LIB_RUNTIME_NAME): 
75
+$(LIB_RUNTIME_NAME):
76 76
 	-@ln -s $(LIB_NAME) $(LIB_RUNTIME_NAME)
77 77
 
78 78
 $(LIB_LINK_NAME):
... ...
@@ -99,3 +100,9 @@ install: $(LIB_NAME) $(lib-prefix)/$(lib-dir)
99 99
 	ln -s $(lib-prefix)/$(lib-dir)/$(LIB_NAME) \
100 100
 			$(lib-prefix)/$(lib-dir)/$(LIB_LINK_NAME) 
101 101
 
102
+
103
+.PHONY:install-if-newer
104
+install-if-newer: $(lib-prefix)/$(lib-dir)/$(LIB_RUNTIME_NAME) 
105
+
106
+$(lib-prefix)/$(lib-dir)/$(LIB_RUNTIME_NAME): $(LIB_NAME)
107
+	@$(MAKE) install
... ...
@@ -4,6 +4,13 @@
4 4
 # module Makefile
5 5
 #(to be included from each module)
6 6
 #
7
+# History:
8
+# --------
9
+#  2007-03-29  if a module depends on SER_LIBS, it will be rebuilt on install
10
+#               with the proper rpath; libraries will be automatically
11
+#               installed if needed (andrei)
12
+#
13
+
7 14
 MOD_NAME=$(NAME:.so=)
8 15
 
9 16
 # allow place modules in separate directory apart from ser core
... ...
@@ -23,7 +30,7 @@ override static_modules_path=
23 23
 ifeq ($(MAKELEVEL), 0)
24 24
 # make called directly in the module dir!
25 25
 
26
-$(warning "you should run make from the main ser directory")
26
+#$(warning "you should run make from the main ser directory")
27 27
 ifneq ($(makefile_defs), 1)
28 28
 $(error "the local makefile does not include Makefile.defs!")
29 29
 endif
... ...
@@ -42,4 +49,18 @@ CFLAGS:=$(MOD_CFLAGS)
42 42
 LDFLAGS:=$(MOD_LDFLAGS)
43 43
 endif
44 44
 
45
+
45 46
 include $(COREPATH)/Makefile.rules
47
+
48
+
49
+$(modules-prefix)/$(modules-dir):
50
+		mkdir -p $(modules-prefix)/$(modules-dir)
51
+
52
+
53
+.PHONY: install
54
+install: $(NAME) $(modules-prefix)/$(modules-dir)
55
+	$(INSTALL-TOUCH) $(modules-prefix)/$(modules-dir)/$(NAME)
56
+	$(INSTALL-MODULES)  $(NAME)  $(modules-prefix)/$(modules-dir)
57
+	@for lib in $(dir $(SER_LIBS)); do \
58
+		$(MAKE) -C "$${lib}" install-if-newer ;\
59
+	done
... ...
@@ -6,9 +6,18 @@
6 6
 #
7 7
 
8 8
 #
9
-# Uses: NAME, ALLDEP, CC, CFLAGS, DEFS, INCLUDES, LIBS, MKDEP, auto_gen, auto_gen_others,
10
-# depends, objs, extra_objs, static_modules, static_modules_path
9
+# Uses: NAME, ALLDEP, CC, CFLAGS, DEFS, INCLUDES, LIBS, MKDEP, auto_gen, 
10
+# auto_gen_others, depends, objs, extra_objs, static_modules, 
11
+# static_modules_path, LD_RPATH
11 12
 # (all this must  be defined previously!,  see Makefile.defs & Makefile)
13
+# Optional: SER_LIBS - list of ser libraries that will be automatically
14
+#  built if necessary. Format: path/shortname, where shortname is the 
15
+#  name passed to -l (e.g. for libprint.so the shortname is print)
16
+#
17
+# History:
18
+# --------
19
+#  2007-03-29  set rpath differently for make install
20
+#              automatically build listed SER_LIBS if needed (andrei)
12 21
 #
13 22
 
14 23
 
... ...
@@ -22,20 +31,49 @@
22 22
 	|  sed 's#\(\($*D)\)\?$(*F)\)\.o[ :]*#$*.o $@ : #g' > $@; \
23 23
 	[ -s $@ ] || rm -f $@
24 24
 
25
-# use RPATH and SER_LIBS if needed
25
+# use RPATH and SER_LIBS if needed (make install and the module depends
26
+# on some ser libs)
27
+
26 28
 ifneq	($(SER_LIBS),)
27 29
 ifneq	($(LD_RPATH),)
28
-SER_RPATH:=$(LD_RPATH)$(lib-target)
30
+ifneq	(,$(filter install, $(MAKECMDGOALS)))
31
+SER_RPATH_LST:=$(lib-target)
32
+else
33
+SER_RPATH_LST:=$(realpath $(dir $(SER_LIBS)))
34
+endif
35
+ifneq	($(strip $(SER_RPATH_LST)),)
36
+SER_RPATH:=$(addprefix $(LD_RPATH),$(SER_RPATH_LST))
29 37
 endif
30 38
 endif
39
+endif
40
+
41
+ALL_LIBS=$(LIBS)
42
+
43
+ifneq ($(SER_LIBS),)
44
+-include librpath.lst
45
+ifneq ($(SER_RPATH_LST), $(LIB_RPATH_LST))
46
+$(shell rm -f librpath.lst)
47
+endif
48
+
49
+SER_LIBS_DEPS:= \
50
+	$(foreach l, $(SER_LIBS), $(dir $l)$(LIB_PREFIX)$(notdir $l)$(LIB_SUFFIX))
51
+ALL_LIBS+=$(foreach l, $(SER_LIBS), -L$(dir $l) -l$(notdir $l))
52
+
53
+$(NAME): $(SER_LIBS_DEPS) librpath.lst
31 54
 
32
-ALL_LIBS=$(LIBS) $(SER_LIBS)
55
+$(SER_LIBS_DEPS):
56
+	$(MAKE) -C $(dir $@)
57
+
58
+endif
33 59
 
34 60
 # normal rules
35 61
 $(NAME): $(objs) $(ALLDEP)
36 62
 	$(LD) $(LDFLAGS) $(objs) $(extra_objs) $(ALL_LIBS) $(SER_RPATH) -o $(NAME)
37 63
 
38 64
 
65
+librpath.lst: $(ALLDEP)
66
+	@echo LIB_RPATH_LST:=$(SER_RPATH_LST) >librpath.lst
67
+
39 68
 .PHONY: all
40 69
 all: $(NAME) modules
41 70
 
... ...
@@ -47,7 +85,7 @@ static: $(objs)
47 47
 
48 48
 .PHONY: clean
49 49
 clean: 
50
-	-@rm -f $(objs) $(NAME) $(objs:.o=.il) 2>/dev/null
50
+	-@rm -f $(objs) $(NAME) $(objs:.o=.il) librpath.lst 2>/dev/null
51 51
 	-@for r in $(modules) $(static_modules_path) "" ; do \
52 52
 		if [ -d "$$r" ]; then \
53 53
 			echo "module $$r" ; \