Browse code

- added install-modules-man and made make install also imake & install the modules man pages (if present)

- added try_err function to Makefile.shared, for checking and reporting if
a shell command failed (if err_fail is 1 it will also force an error return
from the current makefile subshell)

- install-share, install-utils, install-modules-doc, install-modules-man will
now fail if err_fail=1 (default) and one of the individual file install
fails. Closes SER-389.

Andrei Pelinescu-Onciul authored on 28/06/2008 20:16:36
Showing 3 changed files
... ...
@@ -48,6 +48,8 @@
48 48
 #  2008-06-23  added 2 new targets: README and man (re-generate the README
49 49
 #              or manpages for all the modules) (andrei)
50 50
 #  2008-06-25  make cfg support (use a pre-built cfg.: config.mak) (andrei)
51
+#  2008-06-28  added install-modules-man & error checks for 
52
+#              install-utils & doc (andrei)
51 53
 
52 54
 auto_gen=lex.yy.c cfg.tab.c #lexx, yacc etc
53 55
 auto_gen_others=cfg.tab.h  # auto generated, non-c
... ...
@@ -303,13 +305,14 @@ lex.yy.c: cfg.lex cfg.tab.h $(ALLDEP)
303 303
 cfg.tab.c cfg.tab.h: cfg.y  $(ALLDEP)
304 304
 	$(YACC) $(YACC_FLAGS) $<
305 305
 
306
+include Makefile.shared
307
+
306 308
 ifeq ($(config_mak),1)
307 309
 
308 310
 COREPATH=.
309 311
 include Makefile.cfg
310 312
 
311 313
 else
312
-include Makefile.shared
313 314
 
314 315
 config.mak: Makefile.defs
315 316
 	@echo making config...
... ...
@@ -550,6 +553,9 @@ $(doc_prefix)/$(doc_dir):
550 550
 $(man_prefix)/$(man_dir)/man8:
551 551
 		mkdir -p $(man_prefix)/$(man_dir)/man8
552 552
 
553
+$(man_prefix)/$(man_dir)/man7:
554
+		mkdir -p $(man_prefix)/$(man_dir)/man7
555
+
553 556
 $(man_prefix)/$(man_dir)/man5:
554 557
 		mkdir -p $(man_prefix)/$(man_dir)/man5
555 558
 		
... ...
@@ -564,7 +570,8 @@ install-cfg: $(cfg_prefix)/$(cfg_dir)
564 564
 				$(cfg_prefix)/$(cfg_dir)ser.cfg; \
565 565
 		fi
566 566
 		sed -e "s#/usr/.*lib/ser/modules/#$(modules-target)#g" \
567
-			< etc/ser-oob.cfg > $(cfg_prefix)/$(cfg_dir)ser-advanced.cfg.sample
567
+			< etc/ser-oob.cfg \
568
+			> $(cfg_prefix)/$(cfg_dir)ser-advanced.cfg.sample
568 569
 		chmod 644 $(cfg_prefix)/$(cfg_dir)ser-advanced.cfg.sample
569 570
 		if [ -z "${skip_cfg_install}" -a \
570 571
 				! -f $(cfg_prefix)/$(cfg_dir)ser-advanced.cfg ]; then \
... ...
@@ -572,9 +579,9 @@ install-cfg: $(cfg_prefix)/$(cfg_dir)
572 572
 				$(cfg_prefix)/$(cfg_dir)ser-advanced.cfg; \
573 573
 		fi
574 574
 		# radius dictionary
575
-		$(INSTALL_TOUCH) $(cfg_prefix)/$(cfg_dir)/dictionary.ser 
575
+		$(INSTALL_TOUCH) $(cfg_prefix)/$(cfg_dir)/dictionary.ser
576 576
 		$(INSTALL_CFG) etc/dictionary.ser $(cfg_prefix)/$(cfg_dir)
577
-
577
+		
578 578
 		# TLS configuration
579 579
 		$(INSTALL_TOUCH) $(cfg_prefix)/$(cfg_dir)/tls.cfg
580 580
 		$(INSTALL_CFG) modules/tls/tls.cfg $(cfg_prefix)/$(cfg_dir)
... ...
@@ -589,9 +596,10 @@ install-share: $(share_prefix)/$(share_dir)
589 589
 	@for r in $(share_install) "" ; do \
590 590
 		if [ -n "$$r" ]; then \
591 591
 			if [ -f "$$r" ]; then \
592
-				$(INSTALL_TOUCH) \
593
-					$(share_prefix)/$(share_dir)/`basename "$$r"` ; \
594
-				$(INSTALL_SHARE)  "$$r"  $(share_prefix)/$(share_dir) ; \
592
+				$(call try_err, $(INSTALL_TOUCH) \
593
+						$(share_prefix)/$(share_dir)/`basename "$$r"` ); \
594
+				$(call try_err, \
595
+					$(INSTALL_SHARE)  "$$r"  $(share_prefix)/$(share_dir) );\
595 596
 			else \
596 597
 				echo "ERROR: $$r not found" ; \
597 598
 				if [ ${err_fail} = 1 ] ; then \
... ...
@@ -618,9 +626,10 @@ install-utils: utils $(bin_prefix)/$(bin_dir)
618 618
 	@for r in $(utils_bin_install) "" ; do \
619 619
 		if [ -n "$$r" ]; then \
620 620
 			if [ -f "$$r" ]; then \
621
-				$(INSTALL_TOUCH) \
622
-					$(bin_prefix)/$(bin_dir)/`basename "$$r"` ; \
623
-				$(INSTALL_BIN)  "$$r"  $(bin_prefix)/$(bin_dir) ; \
621
+				$(call try_err, $(INSTALL_TOUCH) \
622
+						$(bin_prefix)/$(bin_dir)/`basename "$$r"` ); \
623
+				$(call try_err,\
624
+					$(INSTALL_BIN)  "$$r"  $(bin_prefix)/$(bin_dir) ); \
624 625
 			else \
625 626
 				echo "ERROR: $$r not compiled" ; \
626 627
 				if [ ${err_fail} = 1 ] ; then \
... ...
@@ -632,9 +641,10 @@ install-utils: utils $(bin_prefix)/$(bin_dir)
632 632
 	@for r in $(utils_script_install) "" ; do \
633 633
 		if [ -n "$$r" ]; then \
634 634
 			if [ -f "$$r" ]; then \
635
-				$(INSTALL_TOUCH) \
636
-					$(bin_prefix)/$(bin_dir)/`basename "$$r"` ; \
637
-				$(INSTALL_SCRIPT)  "$$r"  $(bin_prefix)/$(bin_dir) ; \
635
+				$(call try_err, $(INSTALL_TOUCH) \
636
+						$(bin_prefix)/$(bin_dir)/`basename "$$r"` ); \
637
+				$(call try_err,\
638
+					$(INSTALL_SCRIPT)  "$$r"  $(bin_prefix)/$(bin_dir) ); \
638 639
 			else \
639 640
 				echo "ERROR: $$r not compiled" ; \
640 641
 				if [ ${err_fail} = 1 ] ; then \
... ...
@@ -648,7 +658,6 @@ install-utils: utils $(bin_prefix)/$(bin_dir)
648 648
 	sed -e "s#^DEFAULT_SCRIPT_DIR.*#DEFAULT_SCRIPT_DIR=\"$(share_prefix)/$(share_dir)\"#g" \
649 649
 		< scripts/mysql/ser_mysql.sh > $(bin_prefix)/$(bin_dir)/ser_mysql.sh
650 650
 	chmod 755 $(bin_prefix)/$(bin_dir)/ser_mysql.sh
651
-	true
652 651
 
653 652
 
654 653
 install-modules-all: install-modules install-modules-doc
... ...
@@ -671,17 +680,20 @@ install-modules-doc: $(doc_prefix)/$(doc_dir)
671 671
 	@for r in $(modules_basenames) "" ; do \
672 672
 		if [ -n "$$r" ]; then \
673 673
 			if [ -f modules/"$$r"/README ]; then \
674
-				$(INSTALL_TOUCH)  $(doc_prefix)/$(doc_dir)/README ; \
675
-				$(INSTALL_DOC)  modules/"$$r"/README  \
676
-									$(doc_prefix)/$(doc_dir)/README ; \
677
-				mv -f $(doc_prefix)/$(doc_dir)/README \
678
-						$(doc_prefix)/$(doc_dir)/README."$$r" ; \
674
+				$(call try_err,\
675
+					$(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/README ); \
676
+				$(call try_err,\
677
+					$(INSTALL_DOC)  modules/"$$r"/README  \
678
+									$(doc_prefix)/$(doc_dir)/README ); \
679
+				$(call try_err,\
680
+					mv -f $(doc_prefix)/$(doc_dir)/README \
681
+							$(doc_prefix)/$(doc_dir)/README."$$r" ); \
679 682
 			fi ; \
680 683
 		fi ; \
681
-	done 
684
+	done; true
682 685
 
683 686
 
684
-install-man: $(man_prefix)/$(man_dir)/man8 $(man_prefix)/$(man_dir)/man5
687
+install-ser-man: $(man_prefix)/$(man_dir)/man8 $(man_prefix)/$(man_dir)/man5
685 688
 		sed -e "s#/etc/ser/ser\.cfg#$(cfg_target)ser.cfg#g" \
686 689
 			-e "s#/usr/sbin/#$(bin_target)#g" \
687 690
 			-e "s#/usr/lib/ser/modules/#$(modules_target)#g" \
... ...
@@ -695,6 +707,21 @@ install-man: $(man_prefix)/$(man_dir)/man8 $(man_prefix)/$(man_dir)/man5
695 695
 			< ser.cfg.5 >  $(man_prefix)/$(man_dir)/man5/ser.cfg.5
696 696
 		chmod 644  $(man_prefix)/$(man_dir)/man5/ser.cfg.5
697 697
 
698
+install-man:  install-ser-man install-modules-man
699
+
700
+install-modules-man: modules-man $(man_prefix)/$(man_dir)/man7
701
+	@for r in $(modules_basenames) "" ; do \
702
+		if [ -n "$$r" ]; then \
703
+			if [ -f modules/"$$r"/"$$r".7 ]; then \
704
+				$(call try_err,\
705
+					$(INSTALL_TOUCH) $(man_prefix)/$(man_dir)/man7/"$$r".7 );\
706
+				$(call try_err,\
707
+					$(INSTALL_MAN)  modules/"$$r"/"$$r".7  \
708
+									$(man_prefix)/$(man_dir)/man7 ); \
709
+			fi ; \
710
+		fi ; \
711
+	done; true
712
+
698 713
 
699 714
 .PHONY: clean_libs
700 715
 
... ...
@@ -33,3 +33,12 @@ mapf2=$(foreach v,$($(2)),$(call $(1),$v,$(3)))
33 33
 
34 34
 #cfg_fixed_to_file=$(call mapf2,cfg_save_var,saved_fixed_vars,$(1))
35 35
 #cfg_chg_to_file=$(call mapf2,cfg_save_var2,saved_chg_vars,$(1))
36
+
37
+ifeq (${err_fail},1)
38
+sh_err_fail=set -e;
39
+try_err=$(1) ; if [ $$? != 0 ]; then echo ERROR: $(1) failed ;  exit 1 ; fi
40
+else
41
+sh_err_fail=
42
+try_err=$(1) ; if [ $$? != 0 ]; then echo ERROR: $(1) failed ; fi
43
+endif
44
+
... ...
@@ -15,7 +15,8 @@
15 15
 
16 16
 clean_targets:=	clean proper distclean realclean mantainer-clean clean_libs
17 17
 doc_targets:=	modules-doc modules-readme README modules-man man \
18
-		install-doc install-modules-doc install-man
18
+		install-doc install-modules-doc install-man install-ser-man \
19
+		install-modules-man
19 20
 # auxiliary: maintance, debugging, etc. (don't affect code/objects)
20 21
 aux_targets:=	TAGS tar dist cfg config config.mak print-modules dbg \
21 22
 		dbinstall librpath.lst makecfg.lst