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 305
 cfg.tab.c cfg.tab.h: cfg.y  $(ALLDEP)
304 306
 	$(YACC) $(YACC_FLAGS) $<
305 307
 
308
+include Makefile.shared
309
+
306 310
 ifeq ($(config_mak),1)
307 311
 
308 312
 COREPATH=.
309 313
 include Makefile.cfg
310 314
 
311 315
 else
312
-include Makefile.shared
313 316
 
314 317
 config.mak: Makefile.defs
315 318
 	@echo making config...
... ...
@@ -550,6 +553,9 @@ $(doc_prefix)/$(doc_dir):
550 553
 $(man_prefix)/$(man_dir)/man8:
551 554
 		mkdir -p $(man_prefix)/$(man_dir)/man8
552 555
 
556
+$(man_prefix)/$(man_dir)/man7:
557
+		mkdir -p $(man_prefix)/$(man_dir)/man7
558
+
553 559
 $(man_prefix)/$(man_dir)/man5:
554 560
 		mkdir -p $(man_prefix)/$(man_dir)/man5
555 561
 		
... ...
@@ -564,7 +570,8 @@ install-cfg: $(cfg_prefix)/$(cfg_dir)
564 570
 				$(cfg_prefix)/$(cfg_dir)ser.cfg; \
565 571
 		fi
566 572
 		sed -e "s#/usr/.*lib/ser/modules/#$(modules-target)#g" \
567
-			< etc/ser-oob.cfg > $(cfg_prefix)/$(cfg_dir)ser-advanced.cfg.sample
573
+			< etc/ser-oob.cfg \
574
+			> $(cfg_prefix)/$(cfg_dir)ser-advanced.cfg.sample
568 575
 		chmod 644 $(cfg_prefix)/$(cfg_dir)ser-advanced.cfg.sample
569 576
 		if [ -z "${skip_cfg_install}" -a \
570 577
 				! -f $(cfg_prefix)/$(cfg_dir)ser-advanced.cfg ]; then \
... ...
@@ -572,9 +579,9 @@ install-cfg: $(cfg_prefix)/$(cfg_dir)
572 579
 				$(cfg_prefix)/$(cfg_dir)ser-advanced.cfg; \
573 580
 		fi
574 581
 		# radius dictionary
575
-		$(INSTALL_TOUCH) $(cfg_prefix)/$(cfg_dir)/dictionary.ser 
582
+		$(INSTALL_TOUCH) $(cfg_prefix)/$(cfg_dir)/dictionary.ser
576 583
 		$(INSTALL_CFG) etc/dictionary.ser $(cfg_prefix)/$(cfg_dir)
577
-
584
+		
578 585
 		# TLS configuration
579 586
 		$(INSTALL_TOUCH) $(cfg_prefix)/$(cfg_dir)/tls.cfg
580 587
 		$(INSTALL_CFG) modules/tls/tls.cfg $(cfg_prefix)/$(cfg_dir)
... ...
@@ -589,9 +596,10 @@ install-share: $(share_prefix)/$(share_dir)
589 596
 	@for r in $(share_install) "" ; do \
590 597
 		if [ -n "$$r" ]; then \
591 598
 			if [ -f "$$r" ]; then \
592
-				$(INSTALL_TOUCH) \
593
-					$(share_prefix)/$(share_dir)/`basename "$$r"` ; \
594
-				$(INSTALL_SHARE)  "$$r"  $(share_prefix)/$(share_dir) ; \
599
+				$(call try_err, $(INSTALL_TOUCH) \
600
+						$(share_prefix)/$(share_dir)/`basename "$$r"` ); \
601
+				$(call try_err, \
602
+					$(INSTALL_SHARE)  "$$r"  $(share_prefix)/$(share_dir) );\
595 603
 			else \
596 604
 				echo "ERROR: $$r not found" ; \
597 605
 				if [ ${err_fail} = 1 ] ; then \
... ...
@@ -618,9 +626,10 @@ install-utils: utils $(bin_prefix)/$(bin_dir)
618 626
 	@for r in $(utils_bin_install) "" ; do \
619 627
 		if [ -n "$$r" ]; then \
620 628
 			if [ -f "$$r" ]; then \
621
-				$(INSTALL_TOUCH) \
622
-					$(bin_prefix)/$(bin_dir)/`basename "$$r"` ; \
623
-				$(INSTALL_BIN)  "$$r"  $(bin_prefix)/$(bin_dir) ; \
629
+				$(call try_err, $(INSTALL_TOUCH) \
630
+						$(bin_prefix)/$(bin_dir)/`basename "$$r"` ); \
631
+				$(call try_err,\
632
+					$(INSTALL_BIN)  "$$r"  $(bin_prefix)/$(bin_dir) ); \
624 633
 			else \
625 634
 				echo "ERROR: $$r not compiled" ; \
626 635
 				if [ ${err_fail} = 1 ] ; then \
... ...
@@ -632,9 +641,10 @@ install-utils: utils $(bin_prefix)/$(bin_dir)
632 641
 	@for r in $(utils_script_install) "" ; do \
633 642
 		if [ -n "$$r" ]; then \
634 643
 			if [ -f "$$r" ]; then \
635
-				$(INSTALL_TOUCH) \
636
-					$(bin_prefix)/$(bin_dir)/`basename "$$r"` ; \
637
-				$(INSTALL_SCRIPT)  "$$r"  $(bin_prefix)/$(bin_dir) ; \
644
+				$(call try_err, $(INSTALL_TOUCH) \
645
+						$(bin_prefix)/$(bin_dir)/`basename "$$r"` ); \
646
+				$(call try_err,\
647
+					$(INSTALL_SCRIPT)  "$$r"  $(bin_prefix)/$(bin_dir) ); \
638 648
 			else \
639 649
 				echo "ERROR: $$r not compiled" ; \
640 650
 				if [ ${err_fail} = 1 ] ; then \
... ...
@@ -648,7 +658,6 @@ install-utils: utils $(bin_prefix)/$(bin_dir)
648 658
 	sed -e "s#^DEFAULT_SCRIPT_DIR.*#DEFAULT_SCRIPT_DIR=\"$(share_prefix)/$(share_dir)\"#g" \
649 659
 		< scripts/mysql/ser_mysql.sh > $(bin_prefix)/$(bin_dir)/ser_mysql.sh
650 660
 	chmod 755 $(bin_prefix)/$(bin_dir)/ser_mysql.sh
651
-	true
652 661
 
653 662
 
654 663
 install-modules-all: install-modules install-modules-doc
... ...
@@ -671,17 +680,20 @@ install-modules-doc: $(doc_prefix)/$(doc_dir)
671 680
 	@for r in $(modules_basenames) "" ; do \
672 681
 		if [ -n "$$r" ]; then \
673 682
 			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" ; \
683
+				$(call try_err,\
684
+					$(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/README ); \
685
+				$(call try_err,\
686
+					$(INSTALL_DOC)  modules/"$$r"/README  \
687
+									$(doc_prefix)/$(doc_dir)/README ); \
688
+				$(call try_err,\
689
+					mv -f $(doc_prefix)/$(doc_dir)/README \
690
+							$(doc_prefix)/$(doc_dir)/README."$$r" ); \
679 691
 			fi ; \
680 692
 		fi ; \
681
-	done 
693
+	done; true
682 694
 
683 695
 
684
-install-man: $(man_prefix)/$(man_dir)/man8 $(man_prefix)/$(man_dir)/man5
696
+install-ser-man: $(man_prefix)/$(man_dir)/man8 $(man_prefix)/$(man_dir)/man5
685 697
 		sed -e "s#/etc/ser/ser\.cfg#$(cfg_target)ser.cfg#g" \
686 698
 			-e "s#/usr/sbin/#$(bin_target)#g" \
687 699
 			-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 707
 			< ser.cfg.5 >  $(man_prefix)/$(man_dir)/man5/ser.cfg.5
696 708
 		chmod 644  $(man_prefix)/$(man_dir)/man5/ser.cfg.5
697 709
 
710
+install-man:  install-ser-man install-modules-man
711
+
712
+install-modules-man: modules-man $(man_prefix)/$(man_dir)/man7
713
+	@for r in $(modules_basenames) "" ; do \
714
+		if [ -n "$$r" ]; then \
715
+			if [ -f modules/"$$r"/"$$r".7 ]; then \
716
+				$(call try_err,\
717
+					$(INSTALL_TOUCH) $(man_prefix)/$(man_dir)/man7/"$$r".7 );\
718
+				$(call try_err,\
719
+					$(INSTALL_MAN)  modules/"$$r"/"$$r".7  \
720
+									$(man_prefix)/$(man_dir)/man7 ); \
721
+			fi ; \
722
+		fi ; \
723
+	done; true
724
+
698 725
 
699 726
 .PHONY: clean_libs
700 727
 
... ...
@@ -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