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 21
 override static_modules=
21 22
 override static_modules_path=
22 23
 
24
+# temporary def (visible only in the util makefile, not exported)
25
+DEFS +=
26
+
23 27
 ifneq ($(makefile_defs_included),1)
24 28
 $(error "the local makefile does not include Makefile.defs!")
25 29
 endif
... ...
@@ -41,20 +45,45 @@ include $(COREPATH)/Makefile.sources
41 45
 # the rest of makefile and try only to remake the config
42 46
 ifeq ($(makefile_defs),1)
43 47
 
48
+err_fail?=1
44 49
 
45 50
 include $(COREPATH)/Makefile.dirs
46 51
 include $(COREPATH)/Makefile.targets
47 52
 include $(COREPATH)/Makefile.rules
53
+include $(COREPATH)/Makefile.shared
54
+
55
+# default: if not overwritten by the main Makefile, install in bin_dir
56
+util_dst=$(bin_prefix)/$(bin_dir)
57
+
58
+$(util_dst):
59
+		mkdir -p $(util_dst)
48 60
 
49 61
 modules:
50 62
 
63
+.PHONY: install
64
+.PHONY: install-libs
65
+install: $(NAME) $(util_dst) install-libs
66
+	$(INSTALL_TOUCH) $(util_dst)/$(NAME)
67
+	$(INSTALL_BIN)  $(NAME)  $(util_dst)
68
+
69
+install-libs:
70
+	@for lib in $(dir $(SER_LIBS)); do \
71
+		$(call try_err, $(MAKE) -C "$${lib}" install-if-newer ) ;\
72
+	done
73
+
74
+.PHONY: install-if-newer
75
+install-if-newer: $(util_dst)/$(NAME)
76
+
77
+$(util_dst)/$(NAME): $(NAME)
78
+	@$(MAKE) install
79
+
51 80
 # README build rules
52 81
 ifneq (,$(wildcard doc/Makefile))
53 82
 #doc/Makefile present => we can generate README
54 83
 
55 84
 README: doc/*.xml
56
-	$(MAKE) -C doc $(MOD_NAME).txt
57
-	mv doc/$(MOD_NAME).txt $@
85
+	$(MAKE) -C doc $(UTIL_NAME).txt
86
+	mv doc/$(UTIL_NAME).txt $@
58 87
 
59 88
 else
60 89
 # do nothing
... ...
@@ -63,12 +92,12 @@ README:
63 92
 endif
64 93
 
65 94
 #man page build rules
66
-ifneq (,$(wildcard $(MOD_NAME).xml))
95
+ifneq (,$(wildcard $(UTIL_NAME).xml))
67 96
 
68
-$(MOD_NAME).7: $(MOD_NAME).xml
97
+$(UTIL_NAME).7: $(UTIL_NAME).xml
69 98
 	docbook2x-man -s ../../doc/stylesheets/serdoc2man.xsl $<
70 99
 
71
-man: $(MOD_NAME).7
100
+man: $(UTIL_NAME).7
72 101
 
73 102
 else
74 103