1#######################################################################
2#
3#	@(#)Makefile	1.6	(CWI)	88/03/04
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/.code
19LIBDIR = /usr/local/lib/ditroff
20MANDIR = /usr/man/manl
21
22# the directories where the .o files are stored
23
24N = nrobs
25T = trobs
26
27# the object files needed by nroff and troff
28
29NOBS = $N/n1.o $N/n2.o $N/n3.o $N/n4.o $N/n5.o $N/n6.o $N/n7.o $N/n8.o \
30       $N/n9.o $N/n10.o $N/ni.o $N/nii.o $N/hytab.o $N/suftab.o
31
32TOBS = $T/n1.o $T/n2.o $T/n3.o $T/n4.o $T/n5.o $T/t6.o $T/n7.o $T/n8.o \
33       $T/n9.o $T/t10.o $T/ni.o $T/nii.o $T/hytab.o $T/suftab.o
34
35#######################################################################
36
37all:	nroff ditroff $(UDIRS)
38
39ditroff: $(T) $(TOBS)
40	$(CC) $(CFLAGS) $(TOBS) -o ditroff
41
42
43nroff:	$(N) $(NOBS)
44	$(CC) $(CFLAGS) $(NFLAGS) $(NOBS) -o nroff
45
46
47$(T):
48	mkdir $(T)
49
50$(N):
51	mkdir $(N)
52
53$(LIBDIR):
54	mkdir $(LIBDIR)
55	mkdir $(LIBDIR)/font
56
57install: all $(LIBDIR)
58	install -c -s ditroff $(DESTDIR)$(BINDIR)/ditroff
59	install -c -s nroff $(DESTDIR)$(BINDIR)/nroff
60	install -c -m 664 ditroff.1 $(DESTDIR)$(MANDIR)/ditroff.1
61	for i in $(UDIRS); do (cd $$i; make $(MFLAGS) DESTDIR=${DESTDIR} install); done
62
63clean:  force
64	rm -rf make.out ditroff 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