Makefile.gnuhost revision 1.15 1 # $NetBSD: Makefile.gnuhost,v 1.15 2002/01/31 22:43:44 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
20 DIST= ${.CURDIR}/../../gnu/dist/${MODULE}
21
22 FIND_ARGS+= \! \( -type d \( \
23 -name 'CVS' -o \
24 -name 'config' -o \
25 -name 'doc' -o \
26 -name 'po' -o \
27 -name 'nbsd.mt' -o \
28 -name 'tests*' \
29 \) -prune \)
30
31 # Do this "find" only if actually building something.
32 .if (${USETOOLS} == "yes") && empty(.MAKEFLAGS:M-V*) && \
33 (make(all) || make(realall) || (!make(clean) && !make(cleandir) && !make(obj))) && \
34 !defined(_GNU_CFGSRC)
35
36 _GNU_CFGSRC!= find ${DIST} ${FIND_ARGS} \
37 -type f \( -name 'config*' -o -name '*.in' \) -print
38 .MAKEOVERRIDES+= _GNU_CFGSRC
39 .endif
40
41 CONFIGURE_ENV+= CC=${HOST_CC:Q} \
42 CFLAGS=${HOST_CFLAGS:Q} \
43 CPPFLAGS=${HOST_CPPFLAGS:Q} \
44 CXX=${HOST_CXX:Q} \
45 CXXFLAGS=${HOST_CXXFLAGS:Q} \
46 INSTALL=${HOST_INSTALL_FILE:Q} \
47 LDFLAGS=${HOST_LDFLAGS:Q} \
48 LEX=${LEX:Q} \
49 PATH="${TOOLDIR}/bin:$$PATH" \
50 YACC=${YACC:Q}
51
52 CONFIGURE_ARGS+=--prefix=${TOOLDIR} --disable-shared
53
54 MAKE_ARGS:= -j1 ${MAKE_ARGS}
55
56 .ifndef _NOWRAPPER
57 MAKE_ARGS:= -f ${.PARSEDIR}/Makefile.gnuwrap ${MAKE_ARGS}
58 .else
59 MAKE_ARGS+= _NOWRAPPER=1
60 .endif
61
62 MAKE_ARGS+= BISON=true DESTDIR= INSTALL=${HOST_INSTALL_FILE:Q}
63
64 ALL_TARGET?= all
65 INSTALL_TARGET?=install
66
67 .configure_done: ${_GNU_CFGSRC} ${.CURDIR}/Makefile
68 @mkdir build 2>/dev/null || true
69 @(cd build && ${CONFIGURE_ENV} sh ${DIST}/configure ${CONFIGURE_ARGS})
70 @touch $@
71
72 # The .build_done timestamp is only updated if a file actually changes
73 # in the build tree during "make all". This way, if nothing has changed,
74 # a "make install UPDATE=" will do nothing.
75
76 .build_done: .configure_done
77 @(cd build && ${MAKE} ${MAKE_ARGS} ${ALL_TARGET})
78 @if [ ! -f $@ ] || [ -n "$$(find build -type f -newer .build_done -print)" ]; \
79 then touch $@; fi
80
81 .install_done: ${BUILD:D.build_done}
82 .if defined(UPDATE)
83 @cd ${.OBJDIR}; \
84 if [ ! -f .install_done ] || [ ! -f .build_done ] || \
85 [ -n "$$(find .build_done -prune -newer .install_done -print)" ]; then \
86 (cd build && ${MAKE} ${MAKE_ARGS} ${INSTALL_TARGET}); \
87 fi
88 .else
89 @(cd ${.OBJDIR}/build && ${MAKE} ${MAKE_ARGS} ${INSTALL_TARGET})
90 .endif
91 @touch $@
92
93 .PHONY: .build_done .install_done
94
95 # Mapping to standard targets.
96
97 .if ${USETOOLS} == "yes"
98 realall: .build_done
99 realinstall: .install_done
100 .endif
101
102 clean: clean.gnu
103 clean.gnu:
104 -rm -r -f .*_done build
105
106 .include <bsd.hostprog.mk>
107