Makefile.gnuhost revision 1.7
1#	$NetBSD: Makefile.gnuhost,v 1.7 2001/11/14 22:14:48 tv Exp $
2#
3# Rules used when building a GNU host package.  Expects MODULE to be set.
4#
5# There's not a lot we can do to build reliably in the face of many
6# available configuration options.  To be as low-overhead as possible,
7# we follow the following scheme:
8#
9# * Configuration is only re-run when an autoconf source file (such as
10#   "configure" or "config.sub") is changed.
11#
12# * "config.status" is run to rebuild Makefiles and .h files if an
13#   autoconf-parsed file (such as Makefile.in) is changed.
14#
15# * If UPDATE is set, "make install" is only run if a build has happened
16#   since the last install in the current directory.
17
18.include <bsd.own.mk>
19
20DIST=		${.CURDIR}/../../gnu/dist/${MODULE}
21
22FIND_ARGS+=	\! \( -type d \( \
23			-name 'CVS' -o \
24			-name 'config' -o \
25			-name 'doc' -o \
26			-name 'po' -o \
27			-name 'tests*' \
28		\) -prune \)
29
30# Do this "find" only if actually building something.
31.if (${USETOOLS} == "yes") && empty(.MAKEFLAGS:M-V*) && \
32    (make(all) || make(realall) || (!make(clean) && !make(cleandir) && !make(obj))) && \
33    !defined(_GNU_CFGSRC)
34
35_GNU_CFGSRC!=	find ${DIST} ${FIND_ARGS} \
36		-type f \( -name 'config*' -o -name '*.in' \) -print
37.MAKEOVERRIDES+= _GNU_CFGSRC
38.endif
39
40CONFIGURE_ENV+=	CC=${HOST_CC:Q} \
41		CFLAGS=${HOST_CFLAGS:Q} \
42		CPPFLAGS=${HOST_CPPFLAGS:Q} \
43		CXX=${HOST_CXX:Q} \
44		CXXFLAGS=${HOST_CXXFLAGS:Q} \
45		INSTALL=${INSTALL_FILE:N-U:Q} \
46		LDFLAGS=${HOST_LDFLAGS:Q} \
47		PATH="${TOOLDIR}/bin:$$PATH"
48
49CONFIGURE_ARGS+=--prefix=${TOOLDIR} --disable-shared
50
51MAKE_ARGS:=	-j1 ${MAKE_ARGS}
52
53.ifndef _NOWRAPPER
54MAKE_ARGS:=	-f ${.PARSEDIR}/Makefile.gnuwrap ${MAKE_ARGS}
55.else
56MAKE_ARGS+=	_NOWRAPPER=1
57.endif
58
59MAKE_ARGS+=	LEX=true BISON=true DESTDIR= INSTALL=${INSTALL_FILE:N-U:Q}
60
61ALL_TARGET?=	all
62INSTALL_TARGET?=install
63
64.configure_done: ${_GNU_CFGSRC} ${.CURDIR}/Makefile
65	@mkdir build 2>/dev/null || true
66	@(cd build && ${CONFIGURE_ENV} ${DIST}/configure ${CONFIGURE_ARGS})
67	@touch $@
68
69.build_done: .configure_done
70	@(cd build && ${MAKE} ${MAKE_ARGS} ${ALL_TARGET})
71	@touch $@
72
73.install_done:
74.if defined(UPDATE)
75	@if [ ! -f .install_done ] || [ .build_done -nt .install_done ]; then \
76		(cd build && ${MAKE} ${MAKE_ARGS} ${INSTALL_TARGET}); \
77	fi
78.else
79	@(cd build && ${MAKE} ${MAKE_ARGS} ${INSTALL_TARGET})
80.endif
81	@touch $@
82
83.PHONY:		.build_done .install_done
84.ORDER:		.build_done .install_done
85
86# Mapping to standard targets.
87
88.if ${USETOOLS} == "yes"
89realall: .build_done
90realinstall: .install_done
91.endif
92
93clean: clean.gnu
94clean.gnu:
95	-rm -r -f .*_done build
96
97.include <bsd.hostprog.mk>
98