386BSD 0.1 development
[unix-history] / usr / src / usr.bin / groff / Makefile.gnu
CommitLineData
552b13ca
WJ
1#Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc.
2# Written by James Clark (jjc@jclark.uucp)
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 1, 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 LICENSE. If not, write to the Free Software
18#Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
19
20# Define PAGE to be letter if your PostScript printer uses 8.5x11 paper (USA)
21# and define it to be A4, if it uses A4 paper (rest of the world).
22PAGE=A4
23#PAGE=letter
24
25# BINDIR says where to install executables.
26BINDIR=/usr/local/bin
27
28GROFFLIBDIR=/usr/local/lib/groff
29
30# FONTDIR says where to install dev*/*.
31FONTDIR=$(GROFFLIBDIR)/font
32
33# FONTPATH says where to look for dev*/*.
34FONTPATH=.:$(FONTDIR):/usr/local/lib/font:/usr/lib/font
35
36# MACRODIR says where to install macros.
37MACRODIR=$(GROFFLIBDIR)/tmac
38
39# MACROPATH says where to look for macro files.
40MACROPATH=.:$(MACRODIR):/usr/lib/tmac
41
42# DEVICE is the default device.
43DEVICE=ps
44
45# PSPRINT is the command to use for printing a PostScript file.
46# It must be a simple command, not a pipeline.
47PSPRINT=lpr
48
49# DVIPRINT is the command to use for printing a TeX dvi file.
50# It must be a simple command, not a pipeline.
51DVIPRINT=lpr -d
52
53# HYPHENFILE is the file containing the hyphenation patterns.
54HYPHENFILE=$(GROFFLIBDIR)/hyphen
55
56# MANROOT is the root of the man page directory tree.
57MANROOT=/usr/local/man
58
59# MAN1EXT is the man section for user commands.
60MAN1EXT=1
61MAN1DIR=$(MANROOT)/man$(MAN1EXT)
62
63# MAN5EXT is the man section for file formats.
64MAN5EXT=5
65MAN5DIR=$(MANROOT)/man$(MAN5EXT)
66
67# MAN7EXT is the man section for macros.
68MAN7EXT=7
69MAN7DIR=$(MANROOT)/man$(MAN7EXT)
70
71# The groff ms macros will be available as -m$(TMAC_S).
72# If you use `TMAC_S=s', you can use the Unix ms macros by using
73# groff -ms -M/usr/lib/tmac.
74TMAC_S=gs
75
76# Include -DBROKEN_SPOOLER in CPPDEFINES if you have a PostScript
77# spooler or previewer that is unable to cope with anything after
78# %%EndProlog and before the first page (old versions of TranScript
79# have this problem) or gets confused by included documents (the Sun
80# pageview previewer has this problem), or if you are going to be
81# sharing PostScript documents with others who might be running such a
82# spooler or previewer.
83# Include -DCFRONT_ANSI_BUG if you are using AT&T C++ 2.0 with an ANSI C
84# compiler backend.
85# Include -DHAVE_VFORK if you have vfork().
86# Include -DHAVE_SYS_SIGLIST if you have sys_siglist[].
87# Include -DHAVE_UNION_WAIT if wait() is declared by osfcn.h to take
88# an argument of type union wait * (Sun C++ does this). Don't include
89# it if you're using the libg++ header files.
90CPPDEFINES=-DBROKEN_SPOOLER -DHAVE_VFORK -DHAVE_SYS_SIGLIST # -DHAVE_UNION_WAIT -DCFRONT_ANSI_BUG
91
92# Uncomment the next line if you don't have fmod in your math library.
93# I believe this is needed on Ultrix and BSD 4.3.
94# FMOD=fmod.o
95
96# Uncomment the next line if you don't have strtol in your C library.
97# I believe this is needed on BSD 4.3.
98# STRTOL=strtol.o
99
100# Additional flags needed to compile lib/malloc.c
101# Use this with BSD.
102MALLOCFLAGS=-DBSD
103# Use this with System V
104# MALLOCFLAGS=-DUSG
105# Use this with SunOS 4.1
106# MALLOCFLAGS=-DBSD -DSUNOS_LOCALTIME_BUG
107
108# Comment this out if the GNU malloc gives you problems, or if you would
109# prefer to use the system malloc.
110MALLOC=malloc.o
111
112GROFF=
113# Comment the next line out if groff.c gives problems.
114GROFF=groff
115
116# CC is the C++ compiler
117CC=g++
118# I'm told that -fno-inline is needed on a 68030-based Apollo
119# CC=g++ -fno-inline
120
121# OLDCC is the C compiler.
122OLDCC=gcc
123
124PROFILE_FLAG=
125DEBUG_FLAG=-g
126OPTIMIZE_FLAG=-O
127WARNING_FLAGS=#-Wall -Wcast-qual -Wwrite-strings
128
129# Use this to pass additional flags on the command line.
130XCFLAGS=
131
132# CFLAGS are passed to sub makes
133CFLAGS=$(PROFILE_FLAG) $(DEBUG_FLAG) $(OPTIMIZE_FLAG) $(WARNING_FLAGS) \
134 $(CPPDEFINES) $(XCFLAGS)
135
136XOLDCFLAGS=
137# OLDCFLAGS are passed to sub makes
138OLDCFLAGS=$(DEBUG_FLAG) $(PROFILE_FLAG) $(OPTIMIZE_FLAG) $(XOLDCFLAGS)
139
140XLDFLAGS=
141LDFLAGS=$(PROFILE_FLAG) $(DEBUG_FLAG) $(XLDFLAGS)
142# Libraries needed for linking C++ programs.
143LIBS=
144# Libraries needed for linking C++ programs that use libm.a.
145MLIBS=$(LIBS) -lm
146
147AR=ar
148
149# Define RANLIB to be empty if you don't have ranlib.
150RANLIB=ranlib
151
152# YACC can be either yacc or bison -y
153YACC=bison -y
154YACCFLAGS=-v
155
156ETAGS=/usr/local/bin/etags
157# Flag to make etags treat *.[ch] files as C++
158ETAGSFLAGS=-p
159
160SHELL=/bin/sh
161
162SUBDIRS=lib troff pic tbl eqn etc driver ps tty dvi macros man
163
164# SUBFLAGS says what flags to pass to sub makes
165SUBFLAGS="CC=$(CC)" "CFLAGS=$(CFLAGS)" "LDFLAGS=$(LDFLAGS)" \
166 "OLDCC=$(OLDCC)" "OLDCFLAGS=$(OLDCFLAGS)" \
167 "YACC=$(YACC)" "YACCFLAGS=$(YACCFLAGS)" \
168 "DEVICE=$(DEVICE)" "FONTPATH=$(FONTPATH)" "MACROPATH=$(MACROPATH)" \
169 "MALLOCFLAGS=$(MALLOCFLAGS)" "MALLOC=$(MALLOC)" \
170 "FMOD=$(FMOD)" "STRTOL=$(STRTOL)" \
171 "AR=$(AR)" "RANLIB=$(RANLIB)" "LIBS=$(LIBS)" "MLIBS=$(MLIBS)" \
172 "FONTDIR=$(FONTDIR)" "BINDIR=$(BINDIR)" "PAGE=$(PAGE)" \
173 "MACRODIR=$(MACRODIR)" "HYPHENFILE=$(HYPHENFILE)" \
174 "TMAC_S=$(TMAC_S)" "MAN1EXT=$(MAN1EXT)" "MAN1DIR=$(MAN1DIR)" \
175 "MAN5EXT=$(MAN5EXT)" "MAN5DIR=$(MAN5DIR)" \
176 "MAN7EXT=$(MAN7EXT)" "MAN7DIR=$(MAN7DIR)"
177
178all: $(SUBDIRS) $(GROFF) shgroff
179
180$(SUBDIRS): FORCE
181 @cd $@; \
182 echo Making all in $@; \
183 $(MAKE) $(SUBFLAGS) all
184
185troff pic tbl eqn etc ps tty dvi: lib
186ps tty dvi: driver
187
188TAGS: FORCE
189 @for dir in $(SUBDIRS); do \
190 echo Making TAGS in $$dir; \
191 (cd $$dir; $(MAKE) "ETAGSFLAGS=$(ETAGSFLAGS)" "ETAGS=$(ETAGS)" TAGS); \
192 done
193
194topclean: FORCE
195 -rm -f shgroff
196 -rm -f groff *.o core
197
198clean: topclean FORCE
199 @for dir in $(SUBDIRS) doc; do \
200 echo Making clean in $$dir; \
201 (cd $$dir; $(MAKE) clean); done
202
203distclean: topclean FORCE
204 @for dir in $(SUBDIRS) doc; do \
205 echo Making distclean in $$dir; \
206 (cd $$dir; $(MAKE) distclean); done
207
208# You really don't want to use this target.
209realclean: topclean FORCE
210 @for dir in $(SUBDIRS) doc; do \
211 echo Making realclean in $$dir; \
212 (cd $$dir; $(MAKE) realclean); done
213
214install.nobin: FORCE shgroff
215 -[ -d $(BINDIR) ] || mkdir $(BINDIR)
216 -[ -d $(GROFFLIBDIR) ] || mkdir $(GROFFLIBDIR)
217 -[ -d $(MANROOT) ] || mkdir $(MANROOT)
218 @for dir in $(SUBDIRS); do \
219 echo Making install.nobin in $$dir; \
220 (cd $$dir; $(MAKE) $(SUBFLAGS) install.nobin); done
221 if [ -z "$(GROFF)" ] ; then cp shgroff $(BINDIR)/groff ; fi
222
223install.bin: FORCE $(GROFF)
224 -[ -d $(BINDIR) ] || mkdir $(BINDIR)
225 @for dir in $(SUBDIRS); do \
226 echo Making install.bin in $$dir; \
227 (cd $$dir; $(MAKE) $(SUBFLAGS) install.bin); done
228 if [ -n "$(GROFF)" ] ; then cp groff $(BINDIR)/groff ; fi
229
230install: install.bin install.nobin
231
232install.mm: FORCE
233 -[ -d $(GROFFLIBDIR) ] || mkdir $(GROFFLIBDIR)
234 -[ -d $(MACRODIR) ] || mkdir $(MACRODIR)
235 sed -f macros/fixmacros.sed -e 's;/usr/lib/tmac;$(MACRODIR);' \
236 /usr/lib/macros/mmt >$(MACRODIR)/tmac.m
237 sed -f macros/fixmacros.sed /usr/lib/tmac/sys.name \
238 >$(MACRODIR)/sys.name
239 patch -s $(MACRODIR)/tmac.m macros/mm.diff
240
241shgroff: groff.sh
242 @echo Making $@ from groff.sh
243 @-rm -f $@
244 @sed -e "s;@BINDIR@;$(BINDIR);" \
245 -e "s;@DEVICE@;$(DEVICE);" \
246 -e "s;@PROG_PREFIX@;$(PROG_PREFIX);" \
247 -e "s;@FONTDIR@;$(FONTDIR);" \
248 -e "s;@PSPRINT@;$(PSPRINT);" \
249 -e "s;@DVIPRINT@;$(DVIPRINT);" \
250 groff.sh >$@ || rm -f $@
251 @chmod +x $@
252
253groff: groff.o lib/libgroff.a
254 $(CC) $(LDFLAGS) -o $@ groff.o lib/libgroff.a $(LIBS)
255
256lib/libgroff.a: lib
257
258groff.o: groff.c stringify
259 $(CC) -c -Ilib $(CFLAGS) -DDEVICE=\"$(DEVICE)\" \
260 "-DPSPRINT=`$(SHELL) stringify $(PSPRINT)`" \
261 "-DDVIPRINT=`$(SHELL) stringify $(DVIPRINT)`" \
262 groff.c
263
264groff.o: lib/lib.h lib/errarg.h lib/error.h lib/stringclass.h lib/font.h
265
266bindist: all VERSION Makefile.bd README.bd FORCE
267 -[ -d bindist ] || mkdir bindist
268 @topdir=`pwd`; \
269 for dir in $(SUBDIRS); do \
270 (cd $$dir; $(MAKE) "BINDIR=$$topdir/bindist" install.bin); done
271 cp README.bd bindist/README
272 cp VERSION bindist
273 if [ "$(GROFF)" ] ; then cp groff bindist/groff ; fi
274 @echo Making bindist/Makefile
275 @sed -e "s;@GROFFLIBDIR@;$(GROFFLIBDIR);" \
276 -e "s;@FONTDIR@;$(FONTDIR);" \
277 -e "s;@FONTPATH@;$(FONTPATH);" \
278 -e "s;@MACRODIR@;$(MACRODIR);" \
279 -e "s;@MACROPATH@;$(MACROPATH);" \
280 -e "s;@HYPHENFILE@;$(HYPHENFILE);" \
281 -e "s;@DEVICE@;$(DEVICE);" \
282 -e "s;@GROFF@;$(GROFF);" \
283 Makefile.bd >bindist/Makefile
284
285FORCE: