Makefile.comm revision 18099
1# Copyright (C) 1989, 1990, 1991, 1992 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) -I../include -I$(srcdir)/../include
24ALL_CCFLAGS=$(INCLUDES) $(CCDEFINES) $(CCFLAGS) $(CPPFLAGS)
25COMPILE.cc=$(CCC) $(ALL_CCFLAGS) -c
26ALL_CFLAGS=$(CDEFINES) $(CFLAGS) $(CPPFLAGS)
27COMPILE.c=$(CC) $(ALL_CFLAGS)  -c
28LINK.cc=$(CCC) $(CCFLAGS) $(LDFLAGS)
29LINK.c=$(CC) $(CFLAGS) $(LDFLAGS)
30TOP=..
31LIBGROFF=$(TOP)/libgroff/libgroff.a
32LIBBIB=$(TOP)/libbib/libbib.a
33LIBDRIVER=$(TOP)/libdriver/libdriver.a
34LIBM=-lm
35MLIB=
36XLIBS=
37YTABH=
38YTABC=
39GRAM=
40LIBCLEAN=
41CLEANADD=
42MOSTLYCLEANFILES=$(MANCLEAN) $(PROG) $(OBJS) $(GENSRCS) $(GENHDRS) \
43  depend.temp core y.output $(CLEANADD)
44CLEANFILES=$(LIBCLEAN)
45DISTCLEANFILES=TAGS Makefile
46REALCLEANFILES=$(YTABC) $(YTABH)
47NAMEPREFIX=
48HDRS=
49MANPAGES=$(MAN1) $(MAN5) $(MAN7)
50MANCLEAN=$(MANPAGES)
51fontsubdir=$(fontdir)/dev$(DEV)
52
53all install install_bin install_data TAGS depend distfiles uninstall_sub:
54
55install: install_bin install_data
56uninstall: uninstall_sub
57pure:
58
59.PHONY: all clean distclean mostlyclean realclean extraclean depend distfiles
60.PHONY: install install_bin install_data
61.PHONY: uninstall uninstall_sub
62.PHONY: pure
63
64mostlyclean:
65	-rm -f $(MOSTLYCLEANFILES)
66
67clean:
68	-rm -f $(CLEANFILES) $(MOSTLYCLEANFILES)
69
70distclean:
71	-rm -f $(DISTCLEANFILES) $(CLEANFILES) $(MOSTLYCLEANFILES)
72
73realclean:
74	-rm -f $(REALCLEANFILES) $(DISTCLEANFILES) $(CLEANFILES) \
75	  $(MOSTLYCLEANFILES)
76
77extraclean:
78	-rm -f $(DISTCLEANFILES) $(CLEANFILES) $(MOSTLYCLEANFILES) \
79	  \#* *~ =* core junk grot old temp tmp tem
80
81.SUFFIXES:
82.SUFFIXES: .o .cc .c .y .man .n
83
84.cc.o:
85	$(COMPILE.cc) $<
86
87.c.o:
88	$(COMPILE.c) $<
89
90.y.cc:
91	if test -n "$(YTABH)"; then \
92	  $(YACC) $(YACCFLAGS) -d $<; \
93	else \
94	  $(YACC) $(YACCFLAGS) $<; \
95	fi
96	mv y.tab.c $@
97# Avoid ending up with two versions of $(YTABH).
98	if test -n "$(YTABH)"; then \
99	  if test -f $(srcdir)/$(YTABH); then \
100	    rm -f $(YTABH); \
101	    mv y.tab.h $(srcdir)/$(YTABH); \
102	  else \
103	    mv y.tab.h $(YTABH); \
104	  fi; \
105	fi
106
107.man.n:
108	@echo Making $@ from $<
109	@-rm -f $@
110	@sed -e "s;@FONTDIR@;$(fontdir);g" \
111	-e "s;@FONTPATH@;$(fontpath);g" \
112	-e "s;@MACRODIR@;$(tmacdir);g" \
113	-e "s;@MACROPATH@;$(tmacpath);g" \
114	-e "s;@DEVICE@;$(DEVICE);g" \
115	-e "s;@DEFAULT_INDEX@;$(indexdir)/$(indexname);g" \
116	-e "s;@DEFAULT_INDEX_NAME@;$(indexname);g" \
117	-e "s;@INDEX_SUFFIX@;$(indexext);g" \
118	-e "s;@COMMON_WORDS_FILE@;$(common_words_file);g" \
119	-e "s;@MAN1EXT@;$(man1ext);g" \
120	-e "s;@MAN5EXT@;$(man5ext);g" \
121	-e "s;@MAN7EXT@;$(man7ext);g" \
122	-e "s;@TMAC_S_PREFIX@;$(tmac_s_prefix);g" \
123	-e "s;@TMAC_M_PREFIX@;$(tmac_m_prefix);g" \
124	-e "s;@TMAC_MDIR@;$(tmacdir)/mm;g" \
125	-e "s;@BROKEN_SPOOLER_FLAGS@;$(BROKEN_SPOOLER_FLAGS);g" \
126	-e "s;@VERSION@;`cat $(srcdir)/../VERSION`;g" \
127	-e "s;@MDATE@;`$(SHELL) $(srcdir)/../mdate.sh $<`;g" \
128	-e "s;@g@;$(g);g" \
129	-e "s;@G@;`echo $(g) | tr [a-z] [A-Z]`;g" \
130	$< >$@
131
132.PHONY: install_man
133install_man:
134	-test -d $(manroot) || mkdir $(manroot)
135	-test -d $(man1dir) || mkdir $(man1dir)
136	@-pages="$(MAN1)"; \
137	for p in $$pages; do \
138	 prog=`basename $$p .n`; \
139	 target=$(man1dir)/$(NAMEPREFIX)$$prog.$(man1ext); \
140	 rm -f $$target; \
141	 echo $(INSTALL_DATA) $$p $$target; \
142	 $(INSTALL_DATA) $$p $$target; \
143	done
144	-test -d $(man5dir) || mkdir $(man5dir)
145	@-pages="$(MAN5)"; \
146	for p in $$pages; do \
147	 target=$(man5dir)/`basename $$p .n`.$(man5ext); \
148	 rm -f $$target; \
149	 echo $(INSTALL_DATA) $$p $$target; \
150	 $(INSTALL_DATA) $$p $$target; \
151	done
152	-test -d $(man7dir) || mkdir $(man7dir)
153	@-pages="$(MAN7)"; \
154	for p in $$pages; do \
155	 target=$(man7dir)/`basename $$p .n`.$(man7ext); \
156	 rm -f $$target; \
157	 echo $(INSTALL_DATA) $$p $$target; \
158	 $(INSTALL_DATA) $$p $$target; \
159	done
160
161.PHONY: uninstall_man
162uninstall_man:
163	@-pages="$(MAN1)"; \
164	for p in $$pages; do \
165	 target=$(man1dir)/$(NAMEPREFIX)`basename $$p .n`.$(man1ext); \
166	 echo rm -f $$target; \
167	 rm -f $$target; \
168	done
169	@-pages="$(MAN5)"; \
170	for p in $$pages; do \
171	 target=$(man5dir)/`basename $$p .n`.$(man5ext); \
172	 echo rm -f $$target; \
173	 rm -f $$target; \
174	done
175	@-pages="$(MAN7)"; \
176	for p in $$pages; do \
177	 target=$(man7dir)/`basename $$p .n`.$(man7ext); \
178	 echo rm -f $$target; \
179	 rm -f $$target; \
180	done
181
182.PHONY: install_prog
183install_prog:
184	-test -d $(bindir) || mkdir $(bindir)
185	rm -f $(bindir)/$(NAMEPREFIX)$(PROG)
186	$(INSTALL_PROGRAM) $(PROG) $(bindir)/$(NAMEPREFIX)$(PROG)
187
188.PHONY: uninstall_prog
189uninstall_prog:
190	-rm -f $(bindir)/$(NAMEPREFIX)$(PROG)	
191
192.PHONY: install_dev
193install_dev:
194	-test -d $(datadir) || mkdir $(datadir)
195	-test -d $(datasubdir) || mkdir $(datasubdir)
196	-test -d $(fontdir) || mkdir $(fontdir)
197	-test -d $(fontsubdir) || mkdir $(fontsubdir)
198	-if test -d $(srcdir)/generate; then \
199	  test -d $(fontsubdir)/generate || mkdir $(fontsubdir)/generate; \
200	fi
201	-for f in $(DEVFILES); do \
202	  rm -f $(fontsubdir)/$$f; \
203	  if test -f $$f; then \
204	    $(INSTALL_DATA) $$f $(fontsubdir)/$$f; \
205	  else \
206	    $(INSTALL_DATA) $(srcdir)/$$f $(fontsubdir)/$$f; \
207	  fi; \
208	done
209
210.PHONY: uninstall_dev
211uninstall_dev:
212	-for f in $(DEVFILES); do rm -f $(fontsubdir)/$$f; done
213	-if test -d $(fontsubdir)/generate; then \
214	  rmdir $(fontsubdir)/generate; \
215	fi
216	-rmdir $(fontsubdir)
217
218.PHONY: depend_src
219depend_src: depend.temp
220	mv depend.temp Makefile.dep
221
222depend.temp: FORCE
223	> depend.temp;
224	test -z "$(CCSRCS)$(YTABC)"  \
225	  || $(CCC) $(ALL_CCFLAGS) -MM $(CCSRCS) $(YTABC) >>depend.temp
226	test -z "$(CSRCS)" \
227	  || $(CC) $(ALL_CFLAGS) -MM $(CSRCS) >>depend.temp
228	if test -n "$(YTABH)"; then \
229	  sed -e 's|$(YTABH)|$(YTABC)|g' depend.temp >depend.temp1; \
230	  mv depend.temp1 depend.temp; \
231	fi
232
233.PHONY: TAGS_src
234TAGS_src:
235	$(ETAGS) $(ETAGSFLAGS) $(CCSRCS) $(CSRCS)
236	test -z "$(GRAM)$(HDRS)" \
237	  || $(ETAGS) $(ETAGSFLAGS) -a $(ETAGSCCFLAG) $(GRAM) $(HDRS)
238
239Makefile:
240	-rm -f Makefile
241	echo srcdir=$(srcdir) >>Makefile
242	echo VPATH=$(VPATH) >>Makefile
243	cat $(MAKEFILEPARTS) /dev/null >>Makefile
244
245FORCE:
246
247.NOEXPORT:
248