Makefile.comm revision 69626
1# Copyright (C) 1989-2000 Free Software Foundation, Inc.
2#      Written by James Clark (jjc@jclark.com)
3# 
4# This file is part of groff.
5# 
6# groff is free software; you can redistribute it and/or modify it under
7# the terms of the GNU General Public License as published by the Free
8# Software Foundation; either version 2, or (at your option) any later
9# version.
10# 
11# groff is distributed in the hope that it will be useful, but WITHOUT ANY
12# WARRANTY; without even the implied warranty of MERCHANTABILITY or
13# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14# for more details.
15# 
16# You should have received a copy of the GNU General Public License along
17# with groff; see the file COPYING.  If not, write to the Free Software
18# Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19#
20# Makefile.comm
21#
22SHELL=/bin/sh
23INCLUDES=-I. -I$(srcdir) \
24  -I$(top_builddir)/src/include -I$(top_srcdir)/src/include
25ALL_CCFLAGS=$(INCLUDES) $(CCDEFINES) $(CCFLAGS) $(CPPFLAGS)
26COMPILE.cc=$(CCC) $(ALL_CCFLAGS) -c
27ALL_CFLAGS=$(INCLUDES) $(CDEFINES) $(CFLAGS) $(CPPFLAGS)
28COMPILE.c=$(CC) $(ALL_CFLAGS)  -c
29LINK.cc=$(CCC) $(CCFLAGS) $(LDFLAGS)
30LINK.c=$(CC) $(CFLAGS) $(LDFLAGS)
31LIBGROFF=$(top_builddir)/src/libs/libgroff/libgroff.a
32LIBBIB=$(top_builddir)/src/libs/libbib/libbib.a
33LIBDRIVER=$(top_builddir)/src/libs/libdriver/libdriver.a
34MLIB=
35XLIBS=
36YTABH=
37YTABC=
38GRAM=
39LIBCLEAN=
40CLEANADD=
41MOSTLYCLEANFILES=$(MANCLEAN) $(PROG) $(OBJS) $(GENSRCS) $(GENHDRS) \
42  depend.temp core y.output $(CLEANADD)
43CLEANFILES=$(LIBCLEAN)
44DISTCLEANFILES=TAGS Makefile Makefile.dep
45REALCLEANFILES=$(YTABC) $(YTABH)
46NAMEPREFIX=
47HDRS=
48MANPAGES=$(MAN1) $(MAN5) $(MAN7)
49MANCLEAN=$(MANPAGES)
50fontsubdir=$(fontdir)/dev$(DEV)
51
52all install install_bin install_data TAGS depend distfiles uninstall_sub:
53
54install: prefix_must_exist install_bin install_data
55uninstall: uninstall_sub
56pure:
57
58.PHONY: all clean distclean mostlyclean realclean extraclean depend distfiles
59.PHONY: install install_bin install_data prefix_must_exist
60.PHONY: uninstall uninstall_sub
61.PHONY: pure
62
63prefix_must_exist:
64	@test -d $(prefix) \
65	  || (echo ; \
66	      echo The prefix directory \`$(prefix)\' doesn\'t exist; \
67	      echo ; \
68	      exit 1)
69
70mostlyclean:
71	-rm -f $(MOSTLYCLEANFILES)
72
73clean:
74	-rm -f $(CLEANFILES) $(MOSTLYCLEANFILES)
75
76distclean:
77	-rm -f $(DISTCLEANFILES) $(CLEANFILES) $(MOSTLYCLEANFILES)
78
79realclean:
80	-rm -f $(REALCLEANFILES) $(DISTCLEANFILES) $(CLEANFILES) \
81	  $(MOSTLYCLEANFILES)
82
83extraclean:
84	-rm -f $(DISTCLEANFILES) $(CLEANFILES) $(MOSTLYCLEANFILES) \
85	  \#* *~ =* core junk grot old temp tmp tem
86
87.SUFFIXES:
88.SUFFIXES: .o .cc .c .y .man .n
89
90.cc.o:
91	$(COMPILE.cc) $<
92
93.c.o:
94	$(COMPILE.c) $<
95
96.y.cc:
97	if test -n "$(YTABH)"; then \
98	  $(YACC) $(YACCFLAGS) -d $<; \
99	else \
100	  $(YACC) $(YACCFLAGS) $<; \
101	fi
102	-test -f y.tab.h && mv y.tab.h y_tab.h
103	-test -f y.tab.c && mv y.tab.c y_tab.c
104	mv y_tab.c $@
105# Avoid ending up with two versions of $(YTABH).
106	if test -n "$(YTABH)"; then \
107	  if test -f $(srcdir)/$(YTABH); then \
108	    rm -f $(YTABH); \
109	    mv y_tab.h $(srcdir)/$(YTABH); \
110	  else \
111	    mv y_tab.h $(YTABH); \
112	  fi; \
113	fi
114
115version=`cat $(top_srcdir)/VERSION`
116# No additional number for the groff archive if revision is zero
117revision=`sed -e 's/^0$$//' -e 's/^[1-9].*$$/.&/' $(top_srcdir)/REVISION`
118
119.man.n:
120	@echo Making $@ from $<
121	@-rm -f $@
122	@sed -e "s|@FONTDIR@|$(fontdir)|g" \
123	-e "s|@FONTPATH@|$(fontpath)|g" \
124	-e "s|@MACRODIR@|$(tmacdir)|g" \
125	-e "s|@MACROPATH@|$(tmacpath)|g" \
126	-e "s|@DEVICE@|$(DEVICE)|g" \
127	-e "s|@DEFAULT_INDEX@|$(indexdir)/$(indexname)|g" \
128	-e "s|@DEFAULT_INDEX_NAME@|$(indexname)|g" \
129	-e "s|@INDEX_SUFFIX@|$(indexext)|g" \
130	-e "s|@COMMON_WORDS_FILE@|$(common_words_file)|g" \
131	-e "s|@MAN1EXT@|$(man1ext)|g" \
132	-e "s|@MAN5EXT@|$(man5ext)|g" \
133	-e "s|@MAN7EXT@|$(man7ext)|g" \
134	-e "s|@TMAC_S_PREFIX@|$(tmac_s_prefix)|g" \
135	-e "s|@TMAC_M_PREFIX@|$(tmac_m_prefix)|g" \
136	-e "s|@TMAC_AN_PREFIX@|$(tmac_an_prefix)|g" \
137	-e "s|@TMAC_MDIR@|$(tmacdir)/mm|g" \
138	-e "s|@BROKEN_SPOOLER_FLAGS@|$(BROKEN_SPOOLER_FLAGS)|g" \
139	-e "s|@VERSION@|$(version)$(revision)|g" \
140	-e "s|@MDATE@|`$(SHELL) $(top_srcdir)/mdate.sh $<`|g" \
141	-e "s|@g@|$(g)|g" \
142	-e "s!@G@!`echo $(g) | tr [a-z] [A-Z]`!g" \
143	$< >$@
144
145.PHONY: install_man
146install_man:
147	-test -d $(manroot) || $(mkinstalldirs) $(manroot)
148	-test -d $(man1dir) || $(mkinstalldirs) $(man1dir)
149	@-pages="$(MAN1)"; \
150	for p in $$pages; do \
151	 prog=`basename $$p .n`; \
152	 target=$(man1dir)/$(NAMEPREFIX)$$prog.$(man1ext); \
153	 rm -f $$target; \
154	 echo $(INSTALL_DATA) $$p $$target; \
155	 $(INSTALL_DATA) $$p $$target; \
156	done
157	-test -d $(man5dir) || $(mkinstalldirs) $(man5dir)
158	@-pages="$(MAN5)"; \
159	for p in $$pages; do \
160	 target=$(man5dir)/`basename $$p .n`.$(man5ext); \
161	 rm -f $$target; \
162	 echo $(INSTALL_DATA) $$p $$target; \
163	 $(INSTALL_DATA) $$p $$target; \
164	done
165	-test -d $(man7dir) || $(mkinstalldirs) $(man7dir)
166	@-pages="$(MAN7)"; \
167	for p in $$pages; do \
168	 target=$(man7dir)/`basename $$p .n`.$(man7ext); \
169	 rm -f $$target; \
170	 echo $(INSTALL_DATA) $$p $$target; \
171	 $(INSTALL_DATA) $$p $$target; \
172	done
173
174.PHONY: uninstall_man
175uninstall_man:
176	@-pages="$(MAN1)"; \
177	for p in $$pages; do \
178	 target=$(man1dir)/$(NAMEPREFIX)`basename $$p .n`.$(man1ext); \
179	 echo rm -f $$target; \
180	 rm -f $$target; \
181	done
182	@-pages="$(MAN5)"; \
183	for p in $$pages; do \
184	 target=$(man5dir)/`basename $$p .n`.$(man5ext); \
185	 echo rm -f $$target; \
186	 rm -f $$target; \
187	done
188	@-pages="$(MAN7)"; \
189	for p in $$pages; do \
190	 target=$(man7dir)/`basename $$p .n`.$(man7ext); \
191	 echo rm -f $$target; \
192	 rm -f $$target; \
193	done
194
195.PHONY: install_prog
196install_prog:
197	-test -d $(bindir) || $(mkinstalldirs) $(bindir)
198	rm -f $(bindir)/$(NAMEPREFIX)$(PROG)
199	$(INSTALL_PROGRAM) $(PROG) $(bindir)/$(NAMEPREFIX)$(PROG)
200
201.PHONY: uninstall_prog
202uninstall_prog:
203	-rm -f $(bindir)/$(NAMEPREFIX)$(PROG)	
204
205.PHONY: install_dev
206install_dev:
207	-test -d $(datadir) || $(mkinstalldirs) $(datadir)
208	-test -d $(datasubdir) || $(mkinstalldirs) $(datasubdir)
209	-test -d $(fontdir) || $(mkinstalldirs) $(fontdir)
210	-test -d $(fontsubdir) || $(mkinstalldirs) $(fontsubdir)
211	-if test -d $(srcdir)/generate; then \
212	  test -d $(fontsubdir)/generate || \
213	    $(mkinstalldirs) $(fontsubdir)/generate; \
214	fi
215	-for f in $(DEVFILES); do \
216	  rm -f $(fontsubdir)/$$f; \
217	  if test -f $$f; then \
218	    $(INSTALL_DATA) $$f $(fontsubdir)/$$f; \
219	  else \
220	    $(INSTALL_DATA) $(srcdir)/$$f $(fontsubdir)/$$f; \
221	  fi; \
222	done
223
224.PHONY: uninstall_dev
225uninstall_dev:
226	-for f in $(DEVFILES); do rm -f $(fontsubdir)/$$f; done
227	-if test -d $(fontsubdir)/generate; then \
228	  rmdir $(fontsubdir)/generate; \
229	fi
230	-rmdir $(fontsubdir)
231
232.PHONY: depend_src
233depend_src: depend.temp
234	mv depend.temp Makefile.dep
235
236depend.temp: FORCE
237	> depend.temp;
238	test -z "$(CCSRCS)$(YTABC)"  \
239	  || $(CCC) $(ALL_CCFLAGS) -MM $(CCSRCS) $(YTABC) >>depend.temp
240	test -z "$(CSRCS)" \
241	  || $(CC) $(ALL_CFLAGS) -MM $(CSRCS) >>depend.temp
242	if test -n "$(YTABH)"; then \
243	  sed -e 's|$(YTABH)|$(YTABC)|g' depend.temp >depend1.temp; \
244	  mv depend1.temp depend.temp; \
245	fi
246
247.PHONY: TAGS_src
248TAGS_src:
249	$(ETAGS) $(ETAGSFLAGS) $(CCSRCS) $(CSRCS)
250	test -z "$(GRAM)$(HDRS)" \
251	  || $(ETAGS) $(ETAGSFLAGS) -a $(ETAGSCCFLAG) $(GRAM) $(HDRS)
252
253Makefile:
254	-rm -f Makefile
255	echo srcdir=$(srcdir) >>Makefile
256	echo VPATH=$(VPATH) >>Makefile
257	cat $(MAKEFILEPARTS) /dev/null >>Makefile
258
259FORCE:
260
261.NOEXPORT:
262