Browse code

makefile: make install for utils

- make install for utils
- various small Makefile.utils fixes

Andrei Pelinescu-Onciul authored on 01/10/2009 11:42:36
Showing 1 changed files
... ...
@@ -8,6 +8,7 @@
8 8
 # --------
9 9
 #  2009-04-23  initial version derived from Makefile.modules (andrei)
10 10
 
11
+UTIL_NAME=$(NAME)
11 12
 
12 13
 # default path to the core makefiles
13 14
 COREPATH ?=../..
... ...
@@ -20,6 +21,9 @@ override modules=
20 20
 override static_modules=
21 21
 override static_modules_path=
22 22
 
23
+# temporary def (visible only in the util makefile, not exported)
24
+DEFS +=
25
+
23 26
 ifneq ($(makefile_defs_included),1)
24 27
 $(error "the local makefile does not include Makefile.defs!")
25 28
 endif
... ...
@@ -41,20 +45,45 @@ include $(COREPATH)/Makefile.sources
41 41
 # the rest of makefile and try only to remake the config
42 42
 ifeq ($(makefile_defs),1)
43 43
 
44
+err_fail?=1
44 45
 
45 46
 include $(COREPATH)/Makefile.dirs
46 47
 include $(COREPATH)/Makefile.targets
47 48
 include $(COREPATH)/Makefile.rules
49
+include $(COREPATH)/Makefile.shared
50
+
51
+# default: if not overwritten by the main Makefile, install in bin_dir
52
+util_dst=$(bin_prefix)/$(bin_dir)
53
+
54
+$(util_dst):
55
+		mkdir -p $(util_dst)
48 56
 
49 57
 modules:
50 58
 
59
+.PHONY: install
60
+.PHONY: install-libs
61
+install: $(NAME) $(util_dst) install-libs
62
+	$(INSTALL_TOUCH) $(util_dst)/$(NAME)
63
+	$(INSTALL_BIN)  $(NAME)  $(util_dst)
64
+
65
+install-libs:
66
+	@for lib in $(dir $(SER_LIBS)); do \
67
+		$(call try_err, $(MAKE) -C "$${lib}" install-if-newer ) ;\
68
+	done
69
+
70
+.PHONY: install-if-newer
71
+install-if-newer: $(util_dst)/$(NAME)
72
+
73
+$(util_dst)/$(NAME): $(NAME)
74
+	@$(MAKE) install
75
+
51 76
 # README build rules
52 77
 ifneq (,$(wildcard doc/Makefile))
53 78
 #doc/Makefile present => we can generate README
54 79
 
55 80
 README: doc/*.xml
56
-	$(MAKE) -C doc $(MOD_NAME).txt
57
-	mv doc/$(MOD_NAME).txt $@
81
+	$(MAKE) -C doc $(UTIL_NAME).txt
82
+	mv doc/$(UTIL_NAME).txt $@
58 83
 
59 84
 else
60 85
 # do nothing
... ...
@@ -63,12 +92,12 @@ README:
63 63
 endif
64 64
 
65 65
 #man page build rules
66
-ifneq (,$(wildcard $(MOD_NAME).xml))
66
+ifneq (,$(wildcard $(UTIL_NAME).xml))
67 67
 
68
-$(MOD_NAME).7: $(MOD_NAME).xml
68
+$(UTIL_NAME).7: $(UTIL_NAME).xml
69 69
 	docbook2x-man -s ../../doc/stylesheets/serdoc2man.xsl $<
70 70
 
71
-man: $(MOD_NAME).7
71
+man: $(UTIL_NAME).7
72 72
 
73 73
 else
74 74