1#######################################################################
2#
3#	@(#)Makefile	1.7	(CWI)	90/11/03
4#
5# Makefile for ditroff and nroff
6#
7#######################################################################
8
9CFLAGS = -DINCORE -O
10NFLAGS = -DNROFF -DSMALLER	# additional flags for nroff compile
11
12# other utilities maintained by this makefile
13
14UDIRS = utilities devhar eqn pic ideal grap tbl term devnver chem
15
16# location to install final output
17
18BINDIR = /usr/local/bin
19LIBDIR = /usr/local/libdata/ditroff_font
20LIBXDIR = /usr/local/libexec
21MANDIR = /usr/local/man/manl
22
23# the directories where the .o files are stored
24
25N = nrobs
26T = trobs
27
28# the object files needed by nroff and troff
29
30NOBS = $N/n1.o $N/n2.o $N/n3.o $N/n4.o $N/n5.o $N/n6.o $N/n7.o $N/n8.o \
31       $N/n9.o $N/n10.o $N/ni.o $N/nii.o $N/hytab.o $N/suftab.o
32
33TOBS = $T/n1.o $T/n2.o $T/n3.o $T/n4.o $T/n5.o $T/t6.o $T/n7.o $T/n8.o \
34       $T/n9.o $T/t10.o $T/ni.o $T/nii.o $T/hytab.o $T/suftab.o
35
36#######################################################################
37
38all:	troff_p $(UDIRS)
39
40troff_p: $(T) $(TOBS)
41	$(CC) $(CFLAGS) $(TOBS) -o troff_p -lcompat
42
43
44nroff:	$(N) $(NOBS)
45	$(CC) $(CFLAGS) $(NFLAGS) $(NOBS) -o nroff -lcompat
46
47
48$(T):
49	mkdir $(T)
50
51$(N):
52	mkdir $(N)
53
54$(LIBDIR):
55	mkdir $(LIBDIR)
56
57install: all $(LIBDIR)
58	install -c -s ditroff $(DESTDIR)$(LIBXDIR)/troff_p
59	for i in $(UDIRS); do (cd $$i; make $(MFLAGS) DESTDIR=${DESTDIR} install); done
60#	install -c -s nroff $(DESTDIR)$(BINDIR)/nroff
61#	install -c -m 664 ditroff.1 $(DESTDIR)$(MANDIR)/ditroff.1
62
63clean:  force
64	rm -rf make.out troff_p nroff $N $T
65	for i in ${UDIRS}; do (cd $$i; make ${MFLAGS} clean); done
66
67$(UDIRS): force
68	cd $@; make $(MFLAGS)
69
70
71# fake dependency to force a make
72force:
73
74
75#######################################################################
76#
77# The dependencies are divided into two parts: the
78# first expresses the dependencies between the files
79# and includes the fact that the .o files are in
80# different directories than the .c files.  The 2nd
81# part expresses no dependencies, but contains the
82# rule for compiling the .c files into .o files.
83#
84# File Dependencies:
85#
86
87$T/n1.o:		n1.c  tdef.h tw.h ext.h $T/ni.o
88$N/n1.o:		n1.c  tdef.h tw.h ext.h $N/ni.o
89
90$T/n2.o  $N/n2.o:	n2.c  tdef.h tw.h
91$T/n3.o  $N/n3.o:	n3.c  tdef.h tw.h
92$T/n4.o  $N/n4.o:	n4.c  tdef.h tw.h
93$T/n5.o  $N/n5.o:	n5.c  tdef.h tw.h
94
95$T/t6.o:		t6.c  tdef.h tw.h dev.h $T/ni.o
96$N/n6.o:		n6.c  tdef.h tw.h
97
98$T/n7.o  $N/n7.o:	n7.c  tdef.h tw.h
99$T/n8.o  $N/n8.o:	n8.c  tdef.h tw.h
100$T/n9.o  $N/n9.o:	n9.c  tdef.h tw.h
101
102$T/t10.o:		t10.c tdef.h tw.h dev.h $T/ni.o
103$N/n10.o:		n10.c tdef.h tw.h
104
105$T/ni.o  $N/ni.o:	ni.c  tdef.h tw.h
106$T/nii.o $N/nii.o:	nii.c tdef.h tw.h
107$T/hytab.o $N/hytab.o:	hytab.c
108$T/suftab.o $N/suftab.o: suftab.c
109
110
111#
112# Generation Rule:
113#  .oldestfile is older than everything, so
114#  these rules will not be invoked unless
115#  one of the above dependencies is.]
116#
117
118$(NOBS):  .oldestfile
119	  $(CC) $(CFLAGS) $(NFLAGS) -c $@ `basename $@ .o`.c
120	mv `basename $@` nrobs
121
122$(TOBS):  .oldestfile
123	  $(CC) $(CFLAGS) -c $@ `basename $@ .o`.c
124	mv `basename $@` trobs
125
126.oldestfile:
127	touch .oldestfile
128