| @@ -1,139 +1,139 @@ | | | @@ -1,139 +1,139 @@ |
1 | # $NetBSD: Makefile.gnuhost,v 1.39 2012/06/19 21:48:33 hans Exp $ | | 1 | # $NetBSD: Makefile.gnuhost,v 1.40 2013/08/06 21:47:01 apb Exp $ |
2 | # | | 2 | # |
3 | # Rules used when building a GNU host package. Expects MODULE to be set. | | 3 | # Rules used when building a GNU host package. Expects MODULE to be set. |
4 | # | | 4 | # |
5 | # There's not a lot we can do to build reliably in the face of many | | 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, | | 6 | # available configuration options. To be as low-overhead as possible, |
7 | # we follow the following scheme: | | 7 | # we follow the following scheme: |
8 | # | | 8 | # |
9 | # * Configuration is only re-run when an autoconf source file (such as | | 9 | # * Configuration is only re-run when an autoconf source file (such as |
10 | # "configure" or "config.sub") is changed. | | 10 | # "configure" or "config.sub") is changed. |
11 | # | | 11 | # |
12 | # * "config.status" is run to rebuild Makefiles and .h files if an | | 12 | # * "config.status" is run to rebuild Makefiles and .h files if an |
13 | # autoconf-parsed file (such as Makefile.in) is changed. | | 13 | # autoconf-parsed file (such as Makefile.in) is changed. |
14 | # | | 14 | # |
15 | # * If MKUPDATE != "no", "make install" is only run if a build has happened | | 15 | # * If MKUPDATE != "no", "make install" is only run if a build has happened |
16 | # since the last install in the current directory. | | 16 | # since the last install in the current directory. |
17 | | | 17 | |
18 | .include <bsd.own.mk> | | 18 | .include <bsd.own.mk> |
19 | | | 19 | |
20 | # Disable use of pre-compiled headers on Darwin. | | 20 | # Disable use of pre-compiled headers on Darwin. |
21 | BUILD_OSTYPE!= uname -s | | 21 | BUILD_OSTYPE!= uname -s |
22 | .if ${BUILD_OSTYPE} == "Darwin" | | 22 | .if ${BUILD_OSTYPE} == "Darwin" |
23 | HOST_CFLAGS+=-O2 -no-cpp-precomp | | 23 | HOST_CFLAGS+=-O2 -no-cpp-precomp |
24 | .endif | | 24 | .endif |
25 | MAKE_PROGRAM?= ${MAKE} | | 25 | MAKE_PROGRAM?= ${MAKE} |
26 | | | 26 | |
27 | GNUHOSTDIST?= ${.CURDIR}/../../gnu/dist/${MODULE} | | 27 | GNUHOSTDIST?= ${.CURDIR}/../../gnu/dist/${MODULE} |
28 | | | 28 | |
29 | FIND_ARGS+= \! \( -type d \( \ | | 29 | FIND_ARGS+= \! \( -type d \( \ |
30 | -name 'CVS' -o \ | | 30 | -name 'CVS' -o \ |
31 | -name 'config' -o \ | | 31 | -name 'config' -o \ |
32 | -name 'doc' -o \ | | 32 | -name 'doc' -o \ |
33 | -name 'po' -o \ | | 33 | -name 'po' -o \ |
34 | -name 'nbsd.mt' -o \ | | 34 | -name 'nbsd.mt' -o \ |
35 | -name 'tests*' \ | | 35 | -name 'tests*' \ |
36 | \) -prune \) | | 36 | \) -prune \) |
37 | | | 37 | |
38 | # Do this "find" only if actually building something. | | 38 | # Do this "find" only if actually building something. |
39 | .if (${USETOOLS} == "yes") && empty(.MAKEFLAGS:M-V*) && \ | | 39 | .if (${USETOOLS} == "yes") && empty(.MAKEFLAGS:M-V*) && \ |
40 | (make(all) || make(realall) || (!make(clean) && !make(cleandir) && !make(obj))) && \ | | 40 | (make(all) || make(realall) || (!make(clean) && !make(cleandir) && !make(obj))) && \ |
41 | !defined(_GNU_CFGSRC) | | 41 | !defined(_GNU_CFGSRC) |
42 | | | 42 | |
43 | _GNU_CFGSRC!= find ${GNUHOSTDIST} ${FIND_ARGS} \ | | 43 | _GNU_CFGSRC!= find ${GNUHOSTDIST} ${FIND_ARGS} \ |
44 | -type f \( -name 'config*' -o -name '*.in' \) -print | | 44 | -type f \( -name 'config*' -o -name '*.in' \) -print |
45 | .MAKEOVERRIDES+= _GNU_CFGSRC | | 45 | .MAKEOVERRIDES+= _GNU_CFGSRC |
46 | .endif | | 46 | .endif |
47 | | | 47 | |
48 | CONFIGURE_ENV+= \ | | 48 | CONFIGURE_ENV+= \ |
49 | AR=${HOST_AR:Q} \ | | 49 | AR=${HOST_AR:Q} \ |
50 | AWK=${TOOL_AWK:Q} \ | | 50 | AWK=${TOOL_AWK:Q} \ |
51 | CC=${HOST_CC:Q} \ | | 51 | CC=${HOST_CC:Q} \ |
52 | CFLAGS=${HOST_CFLAGS:Q} \ | | 52 | CFLAGS=${HOST_CFLAGS:Q} \ |
53 | CPPFLAGS=${HOST_CPPFLAGS:Q} \ | | 53 | CPPFLAGS=${HOST_CPPFLAGS:Q} \ |
54 | CXX=${HOST_CXX:Q} \ | | 54 | CXX=${HOST_CXX:Q} \ |
55 | CXXFLAGS=${HOST_CXXFLAGS:Q} \ | | 55 | CXXFLAGS=${HOST_CXXFLAGS:Q} \ |
56 | INSTALL=${HOST_INSTALL_FILE:Q} \ | | 56 | INSTALL=${HOST_INSTALL_FILE:Q} \ |
57 | LDFLAGS=${HOST_LDFLAGS:Q} \ | | 57 | LDFLAGS=${HOST_LDFLAGS:Q} \ |
58 | LEX=${LEX:Q} \ | | 58 | LEX=${LEX:Q} \ |
59 | M4=${TOOL_M4:Q} \ | | 59 | M4=${TOOL_M4:Q}" -g -D__gnu__" \ |
60 | MAKE=${MAKE_PROGRAM:Q} \ | | 60 | MAKE=${MAKE_PROGRAM:Q} \ |
61 | PATH="${TOOLDIR}/bin:$$PATH" \ | | 61 | PATH="${TOOLDIR}/bin:$$PATH" \ |
62 | RANLIB=${HOST_RANLIB:Q} \ | | 62 | RANLIB=${HOST_RANLIB:Q} \ |
63 | YACC=${YACC:Q} | | 63 | YACC=${YACC:Q} |
64 | | | 64 | |
65 | BUILD_ENV+= ${CONFIGURE_ENV} | | 65 | BUILD_ENV+= ${CONFIGURE_ENV} |
66 | | | 66 | |
67 | CONFIGURE_ARGS+=--prefix=${TOOLDIR} | | 67 | CONFIGURE_ARGS+=--prefix=${TOOLDIR} |
68 | .if ${MKPIC} == "no" | | 68 | .if ${MKPIC} == "no" |
69 | CONFIGURE_ARGS+=--disable-shared | | 69 | CONFIGURE_ARGS+=--disable-shared |
70 | .endif | | 70 | .endif |
71 | | | 71 | |
72 | .if ${MAKE_PROGRAM} == ${MAKE} | | 72 | .if ${MAKE_PROGRAM} == ${MAKE} |
73 | .ifndef _NOWRAPPER | | 73 | .ifndef _NOWRAPPER |
74 | # Some systems have a small ARG_MAX. On such systems, prevent Make | | 74 | # Some systems have a small ARG_MAX. On such systems, prevent Make |
75 | # variables set on the command line from being exported in the | | 75 | # variables set on the command line from being exported in the |
76 | # environment (they will still be set in MAKEOVERRIDES). | | 76 | # environment (they will still be set in MAKEOVERRIDES). |
77 | .if ${BUILD_OSTYPE} == "Darwin" || ${BUILD_OSTYPE} == "FreeBSD" | | 77 | .if ${BUILD_OSTYPE} == "Darwin" || ${BUILD_OSTYPE} == "FreeBSD" |
78 | __noenvexport= -X | | 78 | __noenvexport= -X |
79 | .endif | | 79 | .endif |
80 | MAKE_ARGS:= ${__noenvexport} -f ${.PARSEDIR}/Makefile.gnuwrap ${MAKE_ARGS} | | 80 | MAKE_ARGS:= ${__noenvexport} -f ${.PARSEDIR}/Makefile.gnuwrap ${MAKE_ARGS} |
81 | .else | | 81 | .else |
82 | MAKE_ARGS+= _NOWRAPPER=1 | | 82 | MAKE_ARGS+= _NOWRAPPER=1 |
83 | .endif | | 83 | .endif |
84 | BUILD_COMMAND= ${BUILD_ENV} ${MAKE} ${MAKE_ARGS} | | 84 | BUILD_COMMAND= ${BUILD_ENV} ${MAKE} ${MAKE_ARGS} |
85 | .else | | 85 | .else |
86 | | | 86 | |
87 | # gmake version of this puts MAKE_ARGS in the environment to be sure that | | 87 | # gmake version of this puts MAKE_ARGS in the environment to be sure that |
88 | # sub-gmake's get them, otherwise tools/gcc tries to build libgcc and | | 88 | # sub-gmake's get them, otherwise tools/gcc tries to build libgcc and |
89 | # fails. it also uses "env -i" to entirely clear out MAKEFLAGS. | | 89 | # fails. it also uses "env -i" to entirely clear out MAKEFLAGS. |
90 | GMAKE_J_ARGS?= ${MAKEFLAGS:[*]:M*-j*:C/.*(-j ?[0-9]*).*/\1/W} | | 90 | GMAKE_J_ARGS?= ${MAKEFLAGS:[*]:M*-j*:C/.*(-j ?[0-9]*).*/\1/W} |
91 | BUILD_COMMAND= /usr/bin/env -i ${BUILD_ENV} ${MAKE_ARGS} ${TOOL_GMAKE} ${GMAKE_J_ARGS} -e ${MAKE_ARGS} | | 91 | BUILD_COMMAND= /usr/bin/env -i ${BUILD_ENV} ${MAKE_ARGS} ${TOOL_GMAKE} ${GMAKE_J_ARGS} -e ${MAKE_ARGS} |
92 | | | 92 | |
93 | .endif | | 93 | .endif |
94 | | | 94 | |
95 | MAKE_ARGS+= BISON=true DESTDIR= INSTALL=${HOST_INSTALL_FILE:Q} | | 95 | MAKE_ARGS+= BISON=true DESTDIR= INSTALL=${HOST_INSTALL_FILE:Q} |
96 | | | 96 | |
97 | ALL_TARGET?= all | | 97 | ALL_TARGET?= all |
98 | INSTALL_TARGET?=install | | 98 | INSTALL_TARGET?=install |
99 | | | 99 | |
100 | BUILD_PLATFORM!= uname -srm | tr ' ()' '-' | | 100 | BUILD_PLATFORM!= uname -srm | tr ' ()' '-' |
101 | CONFIGURE_PLATFORM!= if [ -s .configure_done ]; then cat .configure_done; else echo none; fi | | 101 | CONFIGURE_PLATFORM!= if [ -s .configure_done ]; then cat .configure_done; else echo none; fi |
102 | .if "${BUILD_PLATFORM}" != "${CONFIGURE_PLATFORM}" | | 102 | .if "${BUILD_PLATFORM}" != "${CONFIGURE_PLATFORM}" |
103 | configure_cleanup: | | 103 | configure_cleanup: |
104 | @mkdir build 2>/dev/null || true | | 104 | @mkdir build 2>/dev/null || true |
105 | @(echo "Cleaning stale cache files ${BUILD_PLATFORM} != ${CONFIGURE_PLATFORM}") | | 105 | @(echo "Cleaning stale cache files ${BUILD_PLATFORM} != ${CONFIGURE_PLATFORM}") |
106 | @(cd build && find . -name config.cache | xargs rm -f) | | 106 | @(cd build && find . -name config.cache | xargs rm -f) |
107 | configure_cleanup=configure_cleanup | | 107 | configure_cleanup=configure_cleanup |
108 | .endif | | 108 | .endif |
109 | | | 109 | |
110 | .configure_done: ${_GNU_CFGSRC} ${.CURDIR}/Makefile ${configure_cleanup} | | 110 | .configure_done: ${_GNU_CFGSRC} ${.CURDIR}/Makefile ${configure_cleanup} |
111 | @mkdir build 2>/dev/null || true | | 111 | @mkdir build 2>/dev/null || true |
112 | @(cd build && ${CONFIGURE_ENV} ${HOST_SH} ${GNUHOSTDIST}/configure ${CONFIGURE_ARGS}) | | 112 | @(cd build && ${CONFIGURE_ENV} ${HOST_SH} ${GNUHOSTDIST}/configure ${CONFIGURE_ARGS}) |
113 | @echo ${BUILD_PLATFORM} > $@ | | 113 | @echo ${BUILD_PLATFORM} > $@ |
114 | | | 114 | |
115 | # The .build_done timestamp is only updated if a file actually changes | | 115 | # The .build_done timestamp is only updated if a file actually changes |
116 | # in the build tree during "make all". This way, if nothing has changed, | | 116 | # in the build tree during "make all". This way, if nothing has changed, |
117 | # a "make install MKUPDATE=yes" will do nothing. | | 117 | # a "make install MKUPDATE=yes" will do nothing. |
118 | | | 118 | |
119 | .build_done: .configure_done | | 119 | .build_done: .configure_done |
120 | @(cd build && ${BUILD_COMMAND} ${ALL_TARGET}) | | 120 | @(cd build && ${BUILD_COMMAND} ${ALL_TARGET}) |
121 | @if [ ! -f $@ ] || [ -n "$$(find build -type f -newer .build_done -print)" ]; \ | | 121 | @if [ ! -f $@ ] || [ -n "$$(find build -type f -newer .build_done -print)" ]; \ |
122 | then touch $@; fi | | 122 | then touch $@; fi |
123 | | | 123 | |
124 | .install_done! ${BUILD:D.build_done} | | 124 | .install_done! ${BUILD:D.build_done} |
125 | @(cd ${.OBJDIR}/build && ${BUILD_COMMAND} ${INSTALL_TARGET}) | | 125 | @(cd ${.OBJDIR}/build && ${BUILD_COMMAND} ${INSTALL_TARGET}) |
126 | @touch $@ | | 126 | @touch $@ |
127 | | | 127 | |
128 | # Mapping to standard targets. | | 128 | # Mapping to standard targets. |
129 | | | 129 | |
130 | .if ${USETOOLS} == "yes" | | 130 | .if ${USETOOLS} == "yes" |
131 | realall: .build_done | | 131 | realall: .build_done |
132 | realinstall: .install_done | | 132 | realinstall: .install_done |
133 | .endif | | 133 | .endif |
134 | | | 134 | |
135 | clean: clean.gnu | | 135 | clean: clean.gnu |
136 | clean.gnu: | | 136 | clean.gnu: |
137 | -rm -r -f .*_done build | | 137 | -rm -r -f .*_done build |
138 | | | 138 | |
139 | .include <bsd.hostprog.mk> | | 139 | .include <bsd.hostprog.mk> |