浏览代码

makefile: make install for utils

- make install for utils
- various small Makefile.utils fixes
Andrei Pelinescu-Onciul 16 年之前
父节点
当前提交
911f374259
共有 1 个文件被更改,包括 34 次插入5 次删除
  1. 34 5
      Makefile.utils

+ 34 - 5
Makefile.utils

@@ -8,6 +8,7 @@
 # --------
 # --------
 #  2009-04-23  initial version derived from Makefile.modules (andrei)
 #  2009-04-23  initial version derived from Makefile.modules (andrei)
 
 
+UTIL_NAME=$(NAME)
 
 
 # default path to the core makefiles
 # default path to the core makefiles
 COREPATH ?=../..
 COREPATH ?=../..
@@ -20,6 +21,9 @@ override modules=
 override static_modules=
 override static_modules=
 override static_modules_path=
 override static_modules_path=
 
 
+# temporary def (visible only in the util makefile, not exported)
+DEFS +=
+
 ifneq ($(makefile_defs_included),1)
 ifneq ($(makefile_defs_included),1)
 $(error "the local makefile does not include Makefile.defs!")
 $(error "the local makefile does not include Makefile.defs!")
 endif
 endif
@@ -41,20 +45,45 @@ include $(COREPATH)/Makefile.sources
 # the rest of makefile and try only to remake the config
 # the rest of makefile and try only to remake the config
 ifeq ($(makefile_defs),1)
 ifeq ($(makefile_defs),1)
 
 
+err_fail?=1
 
 
 include $(COREPATH)/Makefile.dirs
 include $(COREPATH)/Makefile.dirs
 include $(COREPATH)/Makefile.targets
 include $(COREPATH)/Makefile.targets
 include $(COREPATH)/Makefile.rules
 include $(COREPATH)/Makefile.rules
+include $(COREPATH)/Makefile.shared
+
+# default: if not overwritten by the main Makefile, install in bin_dir
+util_dst=$(bin_prefix)/$(bin_dir)
+
+$(util_dst):
+		mkdir -p $(util_dst)
 
 
 modules:
 modules:
 
 
+.PHONY: install
+.PHONY: install-libs
+install: $(NAME) $(util_dst) install-libs
+	$(INSTALL_TOUCH) $(util_dst)/$(NAME)
+	$(INSTALL_BIN)  $(NAME)  $(util_dst)
+
+install-libs:
+	@for lib in $(dir $(SER_LIBS)); do \
+		$(call try_err, $(MAKE) -C "$${lib}" install-if-newer ) ;\
+	done
+
+.PHONY: install-if-newer
+install-if-newer: $(util_dst)/$(NAME)
+
+$(util_dst)/$(NAME): $(NAME)
+	@$(MAKE) install
+
 # README build rules
 # README build rules
 ifneq (,$(wildcard doc/Makefile))
 ifneq (,$(wildcard doc/Makefile))
 #doc/Makefile present => we can generate README
 #doc/Makefile present => we can generate README
 
 
 README: doc/*.xml
 README: doc/*.xml
-	$(MAKE) -C doc $(MOD_NAME).txt
-	mv doc/$(MOD_NAME).txt $@
+	$(MAKE) -C doc $(UTIL_NAME).txt
+	mv doc/$(UTIL_NAME).txt $@
 
 
 else
 else
 # do nothing
 # do nothing
@@ -63,12 +92,12 @@ README:
 endif
 endif
 
 
 #man page build rules
 #man page build rules
-ifneq (,$(wildcard $(MOD_NAME).xml))
+ifneq (,$(wildcard $(UTIL_NAME).xml))
 
 
-$(MOD_NAME).7: $(MOD_NAME).xml
+$(UTIL_NAME).7: $(UTIL_NAME).xml
 	docbook2x-man -s ../../doc/stylesheets/serdoc2man.xsl $<
 	docbook2x-man -s ../../doc/stylesheets/serdoc2man.xsl $<
 
 
-man: $(MOD_NAME).7
+man: $(UTIL_NAME).7
 
 
 else
 else