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