# $Source: /hpux/shared/supp//usr/src/cmd/text/./roff.d/makefile,v $
# $Revision: 72.10 $

#
# This command is built archived due to the compiled macros feature.
# If it is built shared, the feature doesn't work.  Also, it is used
# as a base command for some performance test.  Building it archived 
# helps get better performance.
#

# Common makefile for nroff

FINDMSG  = /usr/bin/findmsg
GENCAT	 = /usr/bin/gencat

PTAG	 = -DNROFF -DNOCOMPACT -D_HPUX_SOURCE -Aa
PFLAGS	 = -s -Wp,-H100000

NTSOURCE = hytab.c n1.c n10.c n[2-9i].c nii.c ntab.c strs.hd t10.c \
	   t6.c tab3.c tdef.hd tw.hd uns.hd def.nr.names def.rq.names
CSOURCE = hytab.c n1.c n10.c n[2-9i].c nii.c ntab.c t10.c \
	   t6.c tab3.c freeze.c
SMSOURCE = suftabmake.c suftab.c
SOURCE 	 = $(NTSOURCE) $(SMSOURCE)
NFILES 	 = hytab.o n1.o n10.o n2.o n3.o n4.o n5.o n6.o n7.o n8.o n9.o ni.o \
           nii.o  ntab.o hpux_rel.o freeze.o
TFILES 	 = n1.o n2.o n3.o n4.o n5.o t6.o n7.o n8.o n9.o t10.o ni.o \
	   nii.o tab3.o hytab.o freeze.o
MSGSRC 	 = n1.c n2.c n3.c n4.c n5.c n7.c n8.c n9.c n10.c

default: all

all:	nroff suftab terms nroff.cat

metrics:	nroff.M

nroff:  $(NFILES)
	$(CC) $(LDFLAGS) -Wl,-a,archive -o nroff $(NFILES) $(ARCH_4B_NLS_OPTS)

nroff.M:  $(CSOURCE)
	$(METRICS) $(CFLAGS) $(PTAG) -o nroff.M $(CSOURCE)

troff:  checkPTAG $(TFILES)
	$(CC) $(LDFLAGS) -Wl,-a,archive -o troff $(TFILES)

checkPTAG:
	-@if [ -n "$(PTAG)" ];\
	then echo "must use PTAG="; exit 1;\
	else exit 0; fi

# Dependencies
n1.o n8.o:		tdef.hd strs.hd tw.hd uns.hd
n2.o n3.o n4.o n5.o n6.o n7.o n9.o n10.o nii.o:	tdef.hd strs.hd tw.hd
ni.o:			tdef.hd nrtab.dt rqtab.dt

#	***** NOTE *****  the 300 in the next line is hardwired for (NN)
nrtab.dt: bldtab def.nr.names
	./bldtab 300 def.nr.names > nrtab.dt

#	***** NOTE *****  the 500 in the next line is hardwired for (NM)
rqtab.dt:  bldtab def.rq.names
	./bldtab 500 def.rq.names > rqtab.dt

# suftab cannot be made if we are cross-compiling -- the suftabmake
# program must be run on the target machine.
suftab:	suftabmake
	echo ./suftabmake; ./suftabmake
#	echo ./suftabmake; ./suftabmake; cp suftab /usr/share/lib/suftab

# on 300 only used cc.unshared
bldtab:	bldtab.c tdef.hd
	$(CC) -Wl,-a,archive $(LDFLAGS) $(PFLAGS) -o bldtab bldtab.c

# on 300 only used cc.unshared
suftabmake:	suftabmake.c suftab.c
	$(CC) -Wl,-a,archive $(LDFLAGS) -o suftabmake suftabmake.c

terms:
	cd terms.d; $(MAKE)

nroff.cat: $(MSGSRC)
	for i in $(MSGSRC); do \
		$(FINDMSG) $$i >nroff.msg;\
		$(GENCAT) $@ nroff.msg;\
	done

clean:
	rm -f *.o host.d/*.o nroff.msg 
	cd terms.d; $(MAKE) clean

clobber:	clean
	rm -f bldtab ??tab.dt
	rm -f nroff troff suftab suftabmake nroff.cat host.d/nroff
	cd terms.d; $(MAKE) clobber

# Redefine the .c to .o rule as to include PTAG
.c.o:
	$(CC) $(CFLAGS) $(PTAG) -c $<
