1#	$NetBSD: Makefile,v 1.32 2016/01/14 01:13:26 christos Exp $
2
3MODULE=		groff
4
5ALL_TARGET=	src/include all
6MAKE_ARGS=	bindir=${TOOLDIR}/lib/groff MAKEINFO=${TOOL_MAKEINFO:Q} \
7		INSTALL_INFO=${TOOL_INSTALL_INFO:Q}
8# we don't need any of the X applications
9CONFIGURE_ARGS+=	--without-x
10
11TMACDIR=	${TOOLDIR}/share/groff/tmac
12SITETMACDIR=	${TOOLDIR}/share/groff/site-tmac
13GROFFDIR=	${.CURDIR}/../../external/gpl2/groff
14
15# Add gnuwrap hack directly to the Makefile.
16_NOWRAPPER=1
17
18# Fixup build/Makefile.
19# XXX - the groff distribution Makefiles don't get their dependencies right.
20#	We use internal knowledge to specify additional target ordering.
21#	This can be removed once our own make(1) can be invoked in true
22#	sequential (i.e. compatible) mode again for subdir makes.
23#
24.configure_done: _post_conf
25_post_conf: .USE
26	@(echo '.include "${.CURDIR}/../Makefile.gnuwrap"'; \
27	  echo '.ORDER: $$(ALLDIRS) dot';\
28	  echo '.ORDER: all install' ) >> build/Makefile
29
30
31
32.include "${.CURDIR}/../Makefile.gnuhost"
33.-include "${TOOLDIR}/share/compat/defs.mk"
34
35.PATH:	${.CURDIR}/../../share/tmac ${GROFFDIR}/tmac
36
37_installtmac: .USE
38.if ${MKUPDATE} != "no"
39	@if ! cmp ${.ALLSRC} ${.TARGET} >/dev/null 2>&1; then \
40		echo ${HOST_INSTALL_FILE:Q} -m ${NONBINMODE} ${.ALLSRC} ${.TARGET}; \
41		${HOST_INSTALL_FILE} -m ${NONBINMODE} ${.ALLSRC} ${.TARGET}; \
42	fi
43.else
44	${HOST_INSTALL_FILE} -m ${NONBINMODE} ${.ALLSRC} ${.TARGET}
45.endif
46
47#
48# Since ${TMACDIR} is created by the `realinstall' target, the `afterinstall'
49# sources below that depend on it must wait until `realinstall' is done.
50#
51#.for F in an andoc doc doc-ditroff doc-common doc-nroff doc-syms html html-end man man.local mdoc mdoc.local
52.for F in doc2html
53afterinstall:	${TMACDIR}/${F}.tmac
54.PHONY:		${TMACDIR}/${F}.tmac
55${TMACDIR}/${F}.tmac: ${F} _installtmac
56.ORDER: realinstall ${TMACDIR}/${F}.tmac
57.endfor
58.for F in man.local mdoc.local
59afterinstall:	${SITETMACDIR}/${F}
60.PHONY:		${SITETMACDIR}/${F}
61${SITETMACDIR}/${F}: ${F}-s _installtmac
62.ORDER: realinstall ${SITETMACDIR}/${F}
63CLEANFILES+=${F}-s
64${F}-s: ${F}
65	${TOOL_SED} -f ${GROFFDIR}/dist/tmac/strip.sed ${.ALLSRC} > ${.TARGET}
66.endfor
67
68# The silly walk below is because sometimes the files begin with "g",
69# and sometimes not, depending on what the host tool has at build time.
70
71afterinstall: install.grofflinks
72.ORDER: realinstall install.grofflinks
73install.grofflinks:
74	@cd ${.CURDIR} && ${MAKE} install.grofflinks.recurse
75
76.for F in eqn groff indxbib pic refer soelim tbl
77install.grofflinks.recurse: ${TOOLDIR}/bin/${_TOOL_PREFIX}${F}${HOSTEXEEXT}
78.if exists(${TOOLDIR}/lib/groff/g${F}${HOSTEXEEXT})
79${TOOLDIR}/bin/${_TOOL_PREFIX}${F}${HOSTEXEEXT}: ${TOOLDIR}/lib/groff/g${F}${HOSTEXEEXT}
80.else
81${TOOLDIR}/bin/${_TOOL_PREFIX}${F}${HOSTEXEEXT}: ${TOOLDIR}/lib/groff/${F}${HOSTEXEEXT}
82.endif
83	ln -f ${.ALLSRC} ${.TARGET}
84.endfor
85
86.for F in nroff
87install.grofflinks.recurse: ${TOOLDIR}/bin/${_TOOL_PREFIX}${F}
88.if exists(${TOOLDIR}/lib/groff/g${F})
89${TOOLDIR}/bin/${_TOOL_PREFIX}${F}: ${TOOLDIR}/lib/groff/g${F}
90.else
91${TOOLDIR}/bin/${_TOOL_PREFIX}${F}: ${TOOLDIR}/lib/groff/${F}
92.endif
93	ln -f ${.ALLSRC} ${.TARGET}
94.endfor
95