# Top Makefile for linuxdoc-make RCS=$$Id: Makefile,v 1.106 2002/08/22 02:33:33 gilles Exp $ # $Log: Makefile,v $ # Revision 1.106 2002/08/22 02:33:33 gilles # Added datefr # Added clean-i in cleanf # # Revision 1.105 2002/08/21 22:25:29 gilles # Added wilcards for copying bin/* in make clone # # Revision 1.104 2002/08/21 22:16:08 gilles # Cleaned code commented # Splitted make if # # Revision 1.103 2002/08/21 21:44:29 gilles # Removed debug for i4 # Splitted i in i4 (m4) i0 (all but m4 avoided) # clean-hd is clean-i0 now # Wrote rule for index.html from .index.m4 files # Corrected M4PATH to allow ../include if ./include does not exist # # Revision 1.102 2002/08/21 17:52:13 gilles # Defined INDEX_FROM_M4 and started his rule # # Revision 1.101 2002/08/21 06:35:03 gilles # Removed clone dir exclusion # Removed navsquare dependency for indexes # Include M4 path is not static anymore for indexes # Moved include/*.m4 upper clone.m4 generation (was erased) # # Revision 1.100 2002/08/21 05:22:14 gilles # Removed override.m4 copy in make clone # Changed clone.m4 generation (still from proto.m4) # # Revision 1.99 2002/08/20 17:39:48 gilles # cp commands are from variable CP # Added -p (preserve) to cp commands # # Revision 1.98 2002/08/20 07:27:43 gilles # Uppercased all VARIABLES # # Revision 1.97 2002/08/20 07:16:08 gilles # Updated make dump # # Revision 1.96 2002/08/20 06:54:19 gilles # Added L_ECHO function # Developped make dump with L_ECHO # Moved make help at top # # Revision 1.95 2002/08/20 06:20:22 gilles # Added L_DEF # Redefined VERSION NAV.html DIST_NAME with L_DEF # Allow blank lines (m4_dnl) in .m4 definitions # # Revision 1.94 2002/08/19 05:43:43 gilles # Made make cleanf harder # # Revision 1.93 2002/08/15 00:39:43 gilles # Added html in "make doc" # # Revision 1.92 2002/08/15 00:19:12 gilles # In make clone, override.m4 is copied from proto.m4 # # Revision 1.91 2002/08/15 00:04:12 gilles # project name is taken from CLONE variable # # Revision 1.90 2002/08/14 23:33:21 gilles # Added message about override.m4 in "make clone" # # Revision 1.89 2002/07/28 22:47:38 gilles # clean-hd does not remove indexes now # # Revision 1.88 2002/07/28 22:43:37 gilles # Changed RCS definition # # Revision 1.87 2002/07/28 22:07:01 gilles # Added link test for index files # # Revision 1.86 2002/07/28 21:00:33 gilles # fixed clone .myname # # Revision 1.85 2002/06/09 00:37:39 gilles # Adapted to new navsquare release # # Revision 1.84 2002/06/08 20:33:29 gilles # use of $(INCLUDE) variable # # Revision 1.83 2002/06/08 18:43:46 gilles # Added local .index.memo to regenerate indexes # Added better automatic html index files # # Revision 1.82 2002/06/08 16:16:46 gilles # Added rcs log tag # help: default dump: $(call L_ECHO,CP) $(call L_ECHO,M4PATH) $(call L_ECHO,INCLUDE) $(call L_ECHO,DEFINITIONS) $(call L_ECHO,VERSION) $(call L_ECHO,NAV.HTML) $(call L_ECHO,DIST_NAME) $(call L_ECHO,DATE) $(call L_ECHO,INDEX.HTML) $(call L_ECHO,INDEX.M4) $(call L_ECHO,MYNAME.sh) $(call L_ECHO,DIST) $(call L_ECHO,DIST_DIR) $(call L_ECHO,CLONE) $(call L_ECHO,MYNAME_LST);echo $(call L_ECHO,INDEX.M4_LST);echo $(call L_ECHO,INDEX_FROM_M4);echo $(call L_ECHO,INDEX.HTML_LST);echo $(call L_ECHO,NAV_LST);echo $(call L_ECHO,SGML_FROM_M4);echo $(call L_ECHO,SGML_LST_LS);echo $(call L_ECHO,HTM_FROM_SGML);echo $(call L_ECHO,HTML_FROM_SGML);echo $(call L_ECHO,TXT_FROM_SGML);echo $(call L_ECHO,TXT2_FROM_SGML);echo $(call L_ECHO,DVI_FROM_SGML);echo $(call L_ECHO,RTF_FROM_SGML);echo $(call L_ECHO,PS_FROM_SGML);echo $(call L_ECHO,INFO_FROM_SGML);echo $(call L_ECHO,PDF_FROM_SGML);echo $(call L_ECHO,INDEX.MEMO) $(call L_ECHO,README) include ./bin/variables include ./bin/rules M4PATH=include export M4PATH CP = cp -p INCLUDE=include DEFINITIONS=$(INCLUDE)/definitions.m4 L_DEF = $(shell \ if [ -f ./$(DEFINITIONS) ]; then\ (cat $(DEFINITIONS) ;\ echo $(1) )|M4PATH=$(M4PATH) m4 -P|grep -v '^$$';\ else \ echo "unknown";\ fi \ ) L_ECHO = $(shell \ echo @echo $(1)=[$($(1))];\ ) VERSION = $(call L_DEF, M4_VERSION) NAV.HTML = $(call L_DEF, M4_NAV_FILENAME) DIST_NAME = $(call L_DEF, M4_SOFTWARE) define DATE $(shell \ date '+%Y%m%d%H%M%S' ) endef INDEX.HTML=index.html INDEX.M4=.index.m4 define MYNAME.sh $(shell \ if bin/myname.sh 2>/dev/null 1>&2; then \ echo "bin/myname.sh";\ else \ echo @echo no myname.sh;\ fi ) endef DIST=$(DIST_NAME)-$(VERSION) DIST_DIR=./00_dist/ CLONE=clone .PHONY: default help .PHONY: all html htm txt txt2 rtf dvi info lyx ps tex man pdf sgml \ clone clean-clone \ clean clean-html clean-htm clean-txt clean-txt2 clean-rtf \ clean-dvi clean-info clean-lyx clean-ps \ clean-tex clean-man \ dist clean-dist \ test \ navsquare ns \ lfo lfot rules rules-clean date datefr dist-dir-test \ html_dir htm_dir txt_dir txt2_dir dvi_dir rtf_dir ps_dir tex_dir \ info_dir lyx_dir man_dir pdf_dir \ lh all: html htm txt rtf dvi ps lyx tex man pdf indexes info date: @date '+[%Y %m %d %H:%M:%S] %Y %B %d %A %Z %z' datefr: @ LANG=fr_FR date '+%A %d %B %Y %H:%M:%S %Z %z' #echo `find . -name .myname|grep -v ./clone` define MYNAME_LST $(shell \ echo `find . -name .myname` ) endef #echo `find . -name $(INDEX.M4)|grep -v ./clone` define INDEX.M4_LST $(shell \ echo `find . -name $(INDEX.M4)` ) endef INDEX_FROM_M4=$(patsubst %$(INDEX.M4),%$(INDEX.HTML), $(INDEX.M4_LST)) INDEX.HTML_LST=$(patsubst %.myname,%$(INDEX.HTML), $(MYNAME_LST)) NAV_LST=$(patsubst %.myname,%$(NAV.HTML), $(MYNAME_LST)) SGML_FROM_M4=$(patsubst %.m4,%.sgml, $(wildcard ./sgml/*.m4)) SGML_LST_LS=$(sort $(wildcard ./sgml/*.sgml) $(SGML_FROM_M4)) HTM_FROM_SGML=$(patsubst ./sgml/%.sgml,./$(HTM_DIR)/%.htm, $(SGML_LST_LS)) HTML_FROM_SGML=$(patsubst ./sgml/%.sgml,./$(HTML_DIR)/%.html, $(SGML_LST_LS)) TXT_FROM_SGML=$(patsubst ./sgml/%.sgml,./$(TXT_DIR)/%.txt, $(SGML_LST_LS)) TXT2_FROM_SGML=$(patsubst ./sgml/%.sgml,./$(TXT2_DIR)/%.txt, $(SGML_LST_LS)) DVI_FROM_SGML=$(patsubst ./sgml/%.sgml,./$(DVI_DIR)/%.dvi, $(SGML_LST_LS)) RTF_FROM_SGML=$(patsubst ./sgml/%.sgml,./$(RTF_DIR)/%.rtf, $(SGML_LST_LS)) PS_FROM_SGML=$(patsubst ./sgml/%.sgml,./$(PS_DIR)/%.ps, $(SGML_LST_LS)) TEX_FROM_SGML=$(patsubst ./sgml/%.sgml,./$(TEX_DIR)/%.tex, $(SGML_LST_LS)) INFO_FROM_SGML=$(patsubst ./sgml/%.sgml,./$(INFO_DIR)/%.info, $(SGML_LST_LS)) LYX_FROM_SGML=$(patsubst ./sgml/%.sgml,./$(LYX_DIR)/%.lyx, $(SGML_LST_LS)) MAN_FROM_SGML=$(patsubst ./sgml/%.sgml,./$(MAN_DIR)/%.1, $(SGML_LST_LS)) PDF_FROM_SGML=$(patsubst ./sgml/%.sgml,./$(PDF_DIR)/%.pdf, $(SGML_LST_LS)) #---------------+ # indexes stuff | #---------------+ i: i0 i4 if: clean-i i clean-i : clean-i0 clean-i4 i0: indexes i4: $(INDEX_FROM_M4) i4f: clean-i4 i4 clean-i4: rm -f $(INDEX_FROM_M4) clean-hd : clean-i0 i0f: clean-i0 i0 indexes: .indexes.done INDEX.MEMO=.index.memo $(INDEX_FROM_M4): $(INDEX.M4_LST) @fhd=$@;\ dirfhd=$(@D);\ fm4=$$dirfhd/$(INDEX.M4); \ fml=$$dirfhd/$(INDEX.HTML); \ fms=$$dirfhd/$(INDEX.MEMO); \ pwd=`pwd`; \ if [ -L $$fml ]; then \ echo "symlink $$fml" ;\ elif newer $$fml $$fm4; then \ echo $$fml is up to date ;\ elif [ -f $$fm4 ]; then \ echo "exists $$fm4" ;\ if test -d $$dirfhd/$(M4PATH); then \ M4PATH=$$dirfhd/$(M4PATH);\ else \ M4PATH=$$dirfhd/../$(M4PATH);\ fi ;\ cmd="M4PATH=$$M4PATH m4 -P -DM4_HERE=$$dirfhd $$fm4 > $$fml";\ echo "$$cmd";\ echo "cd $$pwd && $$cmd" > $$fms;\ eval "$$cmd";\ fi ;\ touch .indexes.done clean-i0: # rm -f $(INDEX.HTML_LST) # can be a link ! rm -f .indexes.done $(INDEX.HTML_LST): $(MYNAME_LST) $(INDEX.M4_LST) .indexes.done: $(INDEX.HTML_LST) $(INDEX.M4_LST) list="$(INDEX.HTML_LST)";\ for fhd in $${list}; do \ dirfhd=`dirname $$fhd`; \ fm4=$$dirfhd/$(INDEX.M4); \ fml=$$dirfhd/$(INDEX.HTML); \ fms=$$dirfhd/$(INDEX.MEMO); \ pwd=`pwd`; \ if [ -L $$fml ]; then \ echo "symlink $$fml" ;\ elif [ -f $$fm4 ]; then \ echo "exists $$fm4" ;\ else \ echo "no exists $$fm4" ;\ echo "creating $$fml" ;\ cat $(INCLUDE)/head.html $(INCLUDE)/body_begin.html > $$fml ;\ cat $$dirfhd/$(NAV.HTML) >> $$fml ;\ echo "
" >> $$fml ;\
			(ls -d .. && ls -CF -X -w 80 $$dirfhd) | bin/lshtml.pl >> $$fml;\
			echo "
" >> $$fml ;\ cat $(INCLUDE)/body_end.html $(INCLUDE)/tail.html >> $$fml ;\ fi ;\ done touch .indexes.done h-htm: htm_dir $(HTM_FROM_SGML) i #-------------+ # directories | #-------------+ html_dir: mkdir -p $(HTML_DIR) -$(MYNAME.sh) $(HTML_DIR) htm_dir: mkdir -p $(HTM_DIR) -$(MYNAME.sh) $(HTM_DIR) txt_dir: mkdir -p $(TXT_DIR) -$(MYNAME.sh) $(TXT_DIR) txt2_dir: mkdir -p $(TXT2_DIR) -$(MYNAME.sh) $(TXT2_DIR) dvi_dir: mkdir -p $(DVI_DIR) -$(MYNAME.sh) $(DVI_DIR) rtf_dir: mkdir -p $(RTF_DIR) -$(MYNAME.sh) $(RTF_DIR) ps_dir: mkdir -p $(PS_DIR) -$(MYNAME.sh) $(PS_DIR) tex_dir: mkdir -p $(TEX_DIR) -$(MYNAME.sh) $(TEX_DIR) info_dir: mkdir -p $(INFO_DIR) -$(MYNAME.sh) $(INFO_DIR) lyx_dir: mkdir -p $(LYX_DIR) -$(MYNAME.sh) $(LYX_DIR) man_dir: mkdir -p $(MAN_DIR) -$(MYNAME.sh) $(MAN_DIR) pdf_dir: tex_dir mkdir -p $(PDF_DIR) -$(MYNAME.sh) $(PDF_DIR) sgml: $(SGML_FROM_M4) html: html_dir $(HTML_FROM_SGML) htm: htm_dir $(HTM_FROM_SGML) txt: txt_dir $(TXT_FROM_SGML) txt2: txt2_dir $(TXT2_FROM_SGML) dvi: dvi_dir $(DVI_FROM_SGML) rtf: rtf_dir $(RTF_FROM_SGML) ps: ps_dir $(PS_FROM_SGML) .SECONDARY: $(TEX_FROM_SGML) .INTERMEDIATE: $(TEX_FROM_SGML) tex: tex_dir $(TEX_FROM_SGML) info: info_dir $(INFO_FROM_SGML) lyx: lyx_dir $(LYX_FROM_SGML) man: man_dir $(MAN_FROM_SGML) pdf: pdf_dir $(PDF_FROM_SGML) clean: clean-html clean-htm clean-txt clean-rtf \ clean-dvi clean-info clean-lyx clean-ps \ clean-tex clean-man clean-pdf clean-sgml \ clean-i0 find . -name "*~" -exec rm {} \; cleanf: clean cleanf-rtf cleanf-html clean-sgml \ clean-memo clean-clone clean-rules clean-dist \ clean-dist clean-nav clean-i clean-memo: find . -name $(INDEX.MEMO) -exec rm {} \; clean-sgml: rm -f $(SGML_FROM_M4) clean-html: -rm -f $(HTML_FROM_SGML) cleanf-html: -rm -f $(HTML_DIR)/*.html clean-htm: -rm -f $(HTM_FROM_SGML) clean-txt: -rm -f $(TXT_FROM_SGML) clean-dvi: -rm -f $(DVI_FROM_SGML) clean-rtf: -rm -f $(RTF_FROM_SGML) cleanf-rtf: -rm -f rtf/*.rtf clean-ps: -rm -f $(PS_FROM_SGML) clean-tex: -rm -f $(TEX_FROM_SGML) clean-info: -rm -f $(INFO_FROM_SGML) clean-lyx: -rm -f $(LYX_FROM_SGML) clean-man: -rm -f $(MAN_FROM_SGML) clean-pdf: -rm -f $(PDF_FROM_SGML) clonef: clean-clone clone clone: mkdir -p $(CLONE) &&\ cd $(CLONE) &&\ mkdir -p bin $(INCLUDE) sgml &&\ $(CP) -f ../sgml/.myname ./sgml &&\ $(CP) -f ../bin/*.pl ../bin/rules ../bin/variables \ ../bin/*.sh ../bin/*.sed \ ./bin/ &&\ $(CP) -f ../Makefile ../$(INDEX.M4) . &&\ echo "$(CLONE)" > .myname &&\ $(CP) -f ../$(INCLUDE)/*.m4 ./$(INCLUDE) &&\ m4 -DM4_SOFTWARE_CLONE=\`$(CLONE)\' ../$(INCLUDE)/proto.m4 > ./$(INCLUDE)/clone.m4 &&\ $(CP) -f ../$(INCLUDE)/*.html ./$(INCLUDE) @echo @echo "You can rename and move the directory named ./$(CLONE)/" @echo "and use it exactly like this one (./)" @echo "If you are new with $(DIST_NAME)," @echo "then update the file ./$(CLONE)/$(INCLUDE)/override.m4" @echo "after doing a cp ./$(CLONE)/$(INCLUDE)/clone.m4 ./$(CLONE)/$(INCLUDE)/override.m4" @echo "Happy doc !" clonee: clone $(CP) -f ./sgml/lidoma-model.??.sgml $(CLONE)/sgml clean-clone: rm -rf $(CLONE) clean-test2: rm -rf $(CLONE) doc: html htm txt pdf clean-rules: rm -f bin/rules-* rules: bin/rules bin/rules: bin/makerules.pl @echo saving file $@ to $@-$(DATE) if [ -f $@ ]; then $(CP) $@ $@-$(DATE); fi ./bin/makerules.pl > $@ # This is my local section. Will be less local in next release. dist-dir-test: @if [ -d ../$(DIST) ]; then \ echo good ../$(DIST) exists;\ else \ echo bad ../$(DIST) is not a directory;\ /bin/false;\ fi README=./README.html tarball: mkdir -p $(DIST_DIR) # rm -f $(DIST_DIR)/$(DIST).tgz cd .. && ls -d ./$(DIST) && tar czvf ./$(DIST).tgz ./$(DIST) mv ../$(DIST).tgz $(DIST_DIR) du -sk $(DIST_DIR)/$(DIST).tgz @echo The Tarball is $(DIST_DIR)/$(DIST).tgz tarball-pre: dist-dir-test testf clean-test2 \ clean-rules clean-dist cleanf doc nsf clean-dvi if dist: tarball-pre tarball md5dist dist-check: cd ../linuxdoc-make-check &&\ tar xzvf ../$(DIST)/$(DIST_DIR)/$(DIST).tgz t1: tarball-pre t2: clean-i0 if clean-dist: rm -f $(DIST_DIR)/*.tgz # echo coucou > $(DIST_DIR)/$(README) # touch $(DIST_DIR)/$(DIST).tgz testf: clean-test test md5dist: cd $(DIST_DIR) && echo \ > $(README) &&\ echo You can check the md5sum: >> $(README) &&\ md5sum $(DIST).tgz >> $(README) &&\ echo \ >> $(README) md5distt: cd $(DIST_DIR) && md5sum $(DIST).tgz clean-test: clean-clone test: clone if [ ! -f clone/sgml/lidoma-model.fr.sgml ]; then \ $(CP) sgml/lidoma-model.??.sgml clone/sgml/ ;\ fi cd clone/ && make pdf s lfo: dist clean-i0 if rsync lfot: dist clean-i0 if rsync: mkdir -p ../$(DIST_NAME)-archive $(CP) $(DIST_DIR)/$(DIST).tgz ../$(DIST_NAME)-archive/ rsync -alptvz --delete ./ \ /home/gilles/public_html/www.linux-france.org/html/prj/$(DIST_NAME) du -sk $(DIST_DIR)/$(DIST).tgz s: site site: clean-i0 h-htm # make tidy TIDY='echo aaa' TIDY=tidy -i -latin1 -m tidy: -$(TIDY) $(HTM_DIR)/*.htm -$(TIDY) $(HTML_DIR)/*.html #-----------------+ # navsquare stuff | #-----------------+ $(NAV_LST): $(MYNAME_LST) clean-nav: rm -f .nav.md5 .nav.done find . -name $(NAV.HTML) | xargs rm -f .nav.done: $(NAV_LST) $(MYNAME_LST) navsquare --output=$(NAV.HTML) --root=. --nosave \ foo touch .nav.done navsquare: .nav.done ns: navsquare nsf: clean-nav ns #---------+ # default | #---------+ hl: @echo "make rules # The old file will be saved with the current date" @echo "make md5dist # generate 00_dist/$(README)" @echo "make dist # generate the tarball" default: # @echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" @echo " BULDING THE DOCUMENTATION " @echo " make all # to build everything" @echo " make i # to build $(INDEX.HTML)" @echo " make clean # to clean everything" @echo " make clean-xxx # to clean xxx output (make clean-html per ex.)" @echo " make html # build html in several pages ending with .html" @echo " make htm # build html in one single page ending with .htm" @echo " make tidy # cleanup html files with tidy" @echo " make txt # build ASCII files" @echo " make txt2 # build ASCII files with lynx" @echo " make man # build man pages (buggy)" @echo " make pdf # build PDF files" @echo " make ps # build postscript" @echo " make info # build info files (buggy)" @echo " make lyx # build lyx files" @echo " make dvi # build dvi files" @echo " make tex # build LaTeX files" @echo " make rtf # build RTF files (ugly)" @echo "" @echo " BULDING A CLONE " @echo " make clone # build a clone directory to be moved anywhere" @echo " make clone CLONE=foo # build a clone directory named foo" @echo "" @echo " $(DIST_NAME) $(VERSION)" # @echo "" @echo "RCS tag $(RCS)" # @echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"