Makefile.comm revision 104862
1104862Sru# Copyright (C) 1989-2000, 2002 Free Software Foundation, Inc.
218099Spst#      Written by James Clark (jjc@jclark.com)
318099Spst# 
418099Spst# This file is part of groff.
518099Spst# 
618099Spst# groff is free software; you can redistribute it and/or modify it under
718099Spst# the terms of the GNU General Public License as published by the Free
818099Spst# Software Foundation; either version 2, or (at your option) any later
918099Spst# version.
1018099Spst# 
1118099Spst# groff is distributed in the hope that it will be useful, but WITHOUT ANY
1218099Spst# WARRANTY; without even the implied warranty of MERCHANTABILITY or
1318099Spst# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1418099Spst# for more details.
1518099Spst# 
1618099Spst# You should have received a copy of the GNU General Public License along
1718099Spst# with groff; see the file COPYING.  If not, write to the Free Software
1818099Spst# Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1918099Spst#
2018099Spst# Makefile.comm
2118099Spst#
2218099SpstSHELL=/bin/sh
2369626SruINCLUDES=-I. -I$(srcdir) \
2469626Sru  -I$(top_builddir)/src/include -I$(top_srcdir)/src/include
2518099SpstALL_CCFLAGS=$(INCLUDES) $(CCDEFINES) $(CCFLAGS) $(CPPFLAGS)
2618099SpstCOMPILE.cc=$(CCC) $(ALL_CCFLAGS) -c
2769626SruALL_CFLAGS=$(INCLUDES) $(CDEFINES) $(CFLAGS) $(CPPFLAGS)
28104862SruCOMPILE.c=$(CC) $(ALL_CFLAGS) -c
2918099SpstLINK.cc=$(CCC) $(CCFLAGS) $(LDFLAGS)
3018099SpstLINK.c=$(CC) $(CFLAGS) $(LDFLAGS)
3169626SruLIBGROFF=$(top_builddir)/src/libs/libgroff/libgroff.a
3269626SruLIBBIB=$(top_builddir)/src/libs/libbib/libbib.a
3369626SruLIBDRIVER=$(top_builddir)/src/libs/libdriver/libdriver.a
3418099SpstMLIB=
3518099SpstXLIBS=
3618099SpstYTABH=
3718099SpstYTABC=
3818099SpstGRAM=
3918099SpstLIBCLEAN=
4018099SpstCLEANADD=
41104862SruCLEANDIRADD=
42104862SruCLEANNOTSRCDIRADD=
4318099SpstMOSTLYCLEANFILES=$(MANCLEAN) $(PROG) $(OBJS) $(GENSRCS) $(GENHDRS) \
4418099Spst  depend.temp core y.output $(CLEANADD)
4518099SpstCLEANFILES=$(LIBCLEAN)
4669626SruDISTCLEANFILES=TAGS Makefile Makefile.dep
4718099SpstREALCLEANFILES=$(YTABC) $(YTABH)
4818099SpstNAMEPREFIX=
4918099SpstHDRS=
5018099SpstMANPAGES=$(MAN1) $(MAN5) $(MAN7)
5118099SpstMANCLEAN=$(MANPAGES)
5218099Spstfontsubdir=$(fontdir)/dev$(DEV)
5318099Spst
5418099Spstall install install_bin install_data TAGS depend distfiles uninstall_sub:
5518099Spst
5669626Sruinstall: prefix_must_exist install_bin install_data
5718099Spstuninstall: uninstall_sub
5818099Spstpure:
5918099Spst
6018099Spst.PHONY: all clean distclean mostlyclean realclean extraclean depend distfiles
6169626Sru.PHONY: install install_bin install_data prefix_must_exist
6218099Spst.PHONY: uninstall uninstall_sub
6318099Spst.PHONY: pure
6418099Spst
6569626Sruprefix_must_exist:
6669626Sru	@test -d $(prefix) \
6769626Sru	  || (echo ; \
6869626Sru	      echo The prefix directory \`$(prefix)\' doesn\'t exist; \
6969626Sru	      echo ; \
7069626Sru	      exit 1)
7169626Sru
7218099Spstmostlyclean:
7318099Spst	-rm -f $(MOSTLYCLEANFILES)
74104862Sru	-rm -rf $(CLEANDIRADD)
75104862Sru	-@if test `cd $(srcdir); pwd` = `pwd`; then \
76104862Sru	  :; \
77104862Sru	else \
78104862Sru	  rm -f $(CLEANNOTSRCDIRADD); \
79104862Sru	fi
8018099Spst
81104862Sruclean: mostlyclean
82104862Sru	-rm -f $(CLEANFILES)
8318099Spst
84104862Srudistclean: clean
85104862Sru	-rm -f $(DISTCLEANFILES)
86104862Sru	-@if test `cd $(srcdir); pwd` = `pwd`; then \
87104862Sru	  :; \
88104862Sru	else \
89104862Sru	  rm -f $(YTABC) $(YTABH); \
90104862Sru	fi
9118099Spst
92104862Srurealclean: distclean
93104862Sru	-rm -f $(REALCLEANFILES)
9418099Spst
95104862Sruextraclean: distclean
96104862Sru	-rm -f \#* *~ =* core junk grot old temp tmp tem
9718099Spst
9818099Spst.SUFFIXES:
99104862Sru.SUFFIXES: .o .obj .cc .c .y .man .n
10018099Spst
10118099Spst.cc.o:
10218099Spst	$(COMPILE.cc) $<
10318099Spst
10418099Spst.c.o:
10518099Spst	$(COMPILE.c) $<
10618099Spst
107104862Sru.cc.obj:
108104862Sru	$(COMPILE.cc) $<
109104862Sru
110104862Sru.c.obj:
111104862Sru	$(COMPILE.c) $<
112104862Sru
11318099Spst.y.cc:
11418099Spst	if test -n "$(YTABH)"; then \
11518099Spst	  $(YACC) $(YACCFLAGS) -d $<; \
11618099Spst	else \
11718099Spst	  $(YACC) $(YACCFLAGS) $<; \
11818099Spst	fi
11969626Sru	-test -f y.tab.h && mv y.tab.h y_tab.h
12069626Sru	-test -f y.tab.c && mv y.tab.c y_tab.c
121104862Sru	mv y_tab.c $(YTABC)
122104862Sru	if test -n "$(YTABH)"; then mv y_tab.h $(YTABH); fi
123104862Sru
124104862Sru# The next rule is needed for make of Solaris 2.5.1 to override its
125104862Sru# built-in .y.o rule (which takes precedence over the .y.cc rule above).
126104862Sru.y.o:
12718099Spst	if test -n "$(YTABH)"; then \
128104862Sru	  $(YACC) $(YACCFLAGS) -d $<; \
129104862Sru	else \
130104862Sru	  $(YACC) $(YACCFLAGS) $<; \
13118099Spst	fi
132104862Sru	-test -f y.tab.h && mv y.tab.h y_tab.h
133104862Sru	-test -f y.tab.c && mv y.tab.c y_tab.c
134104862Sru	mv y_tab.c $(YTABC)
135104862Sru	if test -n "$(YTABH)"; then mv y_tab.h $(YTABH); fi
136104862Sru	$(COMPILE.cc) $(YTABC)
13718099Spst
13818099Spst.man.n:
13918099Spst	@echo Making $@ from $<
14018099Spst	@-rm -f $@
14175584Sru	@sed -e "s|@BINDIR@|$(bindir)|g" \
14275584Sru	-e "s|@FONTDIR@|$(fontdir)|g" \
143104862Sru	-e "s|@LOCALFONTDIR@|$(localfontdir)|g" \
144104862Sru	-e "s|@LEGACYFONTDIR@|$(legacyfontdir)|g" \
14569626Sru	-e "s|@MACRODIR@|$(tmacdir)|g" \
14675584Sru	-e "s|@SYSTEMMACRODIR@|$(systemtmacdir)|g" \
14775584Sru	-e "s|@LOCALMACRODIR@|$(localtmacdir)|g" \
148104862Sru	-e "s|@DOCDIR@|$(docdir)|g" \
149104862Sru	-e "s|@EXAMPLEDIR@|$(exampledir)|g" \
150104862Sru	-e "s|@HTMLDOCDIR@|$(htmldocdir)|g" \
15169626Sru	-e "s|@DEVICE@|$(DEVICE)|g" \
15269626Sru	-e "s|@DEFAULT_INDEX@|$(indexdir)/$(indexname)|g" \
15369626Sru	-e "s|@DEFAULT_INDEX_NAME@|$(indexname)|g" \
15469626Sru	-e "s|@INDEX_SUFFIX@|$(indexext)|g" \
15569626Sru	-e "s|@COMMON_WORDS_FILE@|$(common_words_file)|g" \
15669626Sru	-e "s|@MAN1EXT@|$(man1ext)|g" \
15769626Sru	-e "s|@MAN5EXT@|$(man5ext)|g" \
15869626Sru	-e "s|@MAN7EXT@|$(man7ext)|g" \
15969626Sru	-e "s|@TMAC_S_PREFIX@|$(tmac_s_prefix)|g" \
16069626Sru	-e "s|@TMAC_M_PREFIX@|$(tmac_m_prefix)|g" \
16169626Sru	-e "s|@TMAC_AN_PREFIX@|$(tmac_an_prefix)|g" \
16269626Sru	-e "s|@TMAC_MDIR@|$(tmacdir)/mm|g" \
16369626Sru	-e "s|@BROKEN_SPOOLER_FLAGS@|$(BROKEN_SPOOLER_FLAGS)|g" \
16469626Sru	-e "s|@VERSION@|$(version)$(revision)|g" \
16569626Sru	-e "s|@MDATE@|`$(SHELL) $(top_srcdir)/mdate.sh $<`|g" \
16669626Sru	-e "s|@g@|$(g)|g" \
16769626Sru	-e "s!@G@!`echo $(g) | tr [a-z] [A-Z]`!g" \
16818099Spst	$< >$@
16918099Spst
17018099Spst.PHONY: install_man
17118099Spstinstall_man:
17269626Sru	-test -d $(manroot) || $(mkinstalldirs) $(manroot)
17369626Sru	-test -d $(man1dir) || $(mkinstalldirs) $(man1dir)
17418099Spst	@-pages="$(MAN1)"; \
17518099Spst	for p in $$pages; do \
17618099Spst	 prog=`basename $$p .n`; \
17718099Spst	 target=$(man1dir)/$(NAMEPREFIX)$$prog.$(man1ext); \
17818099Spst	 rm -f $$target; \
17918099Spst	 echo $(INSTALL_DATA) $$p $$target; \
18018099Spst	 $(INSTALL_DATA) $$p $$target; \
18118099Spst	done
18269626Sru	-test -d $(man5dir) || $(mkinstalldirs) $(man5dir)
18318099Spst	@-pages="$(MAN5)"; \
18418099Spst	for p in $$pages; do \
18518099Spst	 target=$(man5dir)/`basename $$p .n`.$(man5ext); \
18618099Spst	 rm -f $$target; \
18718099Spst	 echo $(INSTALL_DATA) $$p $$target; \
18818099Spst	 $(INSTALL_DATA) $$p $$target; \
18918099Spst	done
19069626Sru	-test -d $(man7dir) || $(mkinstalldirs) $(man7dir)
19118099Spst	@-pages="$(MAN7)"; \
19218099Spst	for p in $$pages; do \
19318099Spst	 target=$(man7dir)/`basename $$p .n`.$(man7ext); \
19418099Spst	 rm -f $$target; \
19518099Spst	 echo $(INSTALL_DATA) $$p $$target; \
19618099Spst	 $(INSTALL_DATA) $$p $$target; \
19718099Spst	done
19818099Spst
19918099Spst.PHONY: uninstall_man
20018099Spstuninstall_man:
20118099Spst	@-pages="$(MAN1)"; \
20218099Spst	for p in $$pages; do \
20318099Spst	 target=$(man1dir)/$(NAMEPREFIX)`basename $$p .n`.$(man1ext); \
20418099Spst	 echo rm -f $$target; \
20518099Spst	 rm -f $$target; \
20618099Spst	done
20718099Spst	@-pages="$(MAN5)"; \
20818099Spst	for p in $$pages; do \
20918099Spst	 target=$(man5dir)/`basename $$p .n`.$(man5ext); \
21018099Spst	 echo rm -f $$target; \
21118099Spst	 rm -f $$target; \
21218099Spst	done
21318099Spst	@-pages="$(MAN7)"; \
21418099Spst	for p in $$pages; do \
21518099Spst	 target=$(man7dir)/`basename $$p .n`.$(man7ext); \
21618099Spst	 echo rm -f $$target; \
21718099Spst	 rm -f $$target; \
21818099Spst	done
21918099Spst
22018099Spst.PHONY: install_prog
22118099Spstinstall_prog:
22269626Sru	-test -d $(bindir) || $(mkinstalldirs) $(bindir)
22318099Spst	rm -f $(bindir)/$(NAMEPREFIX)$(PROG)
22418099Spst	$(INSTALL_PROGRAM) $(PROG) $(bindir)/$(NAMEPREFIX)$(PROG)
22518099Spst
22618099Spst.PHONY: uninstall_prog
22718099Spstuninstall_prog:
22818099Spst	-rm -f $(bindir)/$(NAMEPREFIX)$(PROG)	
22918099Spst
23018099Spst.PHONY: install_dev
23118099Spstinstall_dev:
23269626Sru	-test -d $(datadir) || $(mkinstalldirs) $(datadir)
23375584Sru	-test -d $(dataprogramdir) || $(mkinstalldirs) $(dataprogramdir)
23469626Sru	-test -d $(datasubdir) || $(mkinstalldirs) $(datasubdir)
23569626Sru	-test -d $(fontdir) || $(mkinstalldirs) $(fontdir)
23669626Sru	-test -d $(fontsubdir) || $(mkinstalldirs) $(fontsubdir)
23718099Spst	-if test -d $(srcdir)/generate; then \
23869626Sru	  test -d $(fontsubdir)/generate || \
23969626Sru	    $(mkinstalldirs) $(fontsubdir)/generate; \
24018099Spst	fi
24118099Spst	-for f in $(DEVFILES); do \
24218099Spst	  rm -f $(fontsubdir)/$$f; \
24318099Spst	  if test -f $$f; then \
24418099Spst	    $(INSTALL_DATA) $$f $(fontsubdir)/$$f; \
24518099Spst	  else \
24618099Spst	    $(INSTALL_DATA) $(srcdir)/$$f $(fontsubdir)/$$f; \
24718099Spst	  fi; \
24818099Spst	done
24918099Spst
25018099Spst.PHONY: uninstall_dev
25118099Spstuninstall_dev:
25218099Spst	-for f in $(DEVFILES); do rm -f $(fontsubdir)/$$f; done
25318099Spst	-if test -d $(fontsubdir)/generate; then \
25418099Spst	  rmdir $(fontsubdir)/generate; \
25518099Spst	fi
25618099Spst	-rmdir $(fontsubdir)
25718099Spst
25818099Spst.PHONY: depend_src
25918099Spstdepend_src: depend.temp
26018099Spst	mv depend.temp Makefile.dep
26118099Spst
26218099Spstdepend.temp: FORCE
26318099Spst	> depend.temp;
264104862Sru	test -z "$(CCSRCS)$(YTABC)" \
26518099Spst	  || $(CCC) $(ALL_CCFLAGS) -MM $(CCSRCS) $(YTABC) >>depend.temp
26618099Spst	test -z "$(CSRCS)" \
26718099Spst	  || $(CC) $(ALL_CFLAGS) -MM $(CSRCS) >>depend.temp
26818099Spst	if test -n "$(YTABH)"; then \
26969626Sru	  sed -e 's|$(YTABH)|$(YTABC)|g' depend.temp >depend1.temp; \
27069626Sru	  mv depend1.temp depend.temp; \
27118099Spst	fi
27218099Spst
27318099Spst.PHONY: TAGS_src
27418099SpstTAGS_src:
27518099Spst	$(ETAGS) $(ETAGSFLAGS) $(CCSRCS) $(CSRCS)
27618099Spst	test -z "$(GRAM)$(HDRS)" \
27718099Spst	  || $(ETAGS) $(ETAGSFLAGS) -a $(ETAGSCCFLAG) $(GRAM) $(HDRS)
27818099Spst
279104862Sru# This rule is only considered for the subdir_Makefile target.
28018099SpstMakefile:
28118099Spst	-rm -f Makefile
28218099Spst	echo srcdir=$(srcdir) >>Makefile
28318099Spst	echo VPATH=$(VPATH) >>Makefile
28418099Spst	cat $(MAKEFILEPARTS) /dev/null >>Makefile
28518099Spst
28618099SpstFORCE:
28718099Spst
28818099Spst.NOEXPORT:
289