snj doesn't like my accent, so use proper English month names.
[netbsd-mini2440.git] / tools / Makefile.gnuhost
blob5cc318a6e807731ef516b1dd559a6287ddc6af84
1 #       $NetBSD: Makefile.gnuhost,v 1.32 2005/02/11 15:11:08 jmc 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
26 GNUHOSTDIST?=   ${.CURDIR}/../../gnu/dist/${MODULE}
28 FIND_ARGS+=     \! \( -type d \( \
29                         -name 'CVS' -o \
30                         -name 'config' -o \
31                         -name 'doc' -o \
32                         -name 'po' -o \
33                         -name 'nbsd.mt' -o \
34                         -name 'tests*' \
35                 \) -prune \)
37 # Do this "find" only if actually building something.
38 .if (${USETOOLS} == "yes") && empty(.MAKEFLAGS:M-V*) && \
39     (make(all) || make(realall) || (!make(clean) && !make(cleandir) && !make(obj))) && \
40     !defined(_GNU_CFGSRC)
42 _GNU_CFGSRC!=   find ${GNUHOSTDIST} ${FIND_ARGS} \
43                 -type f \( -name 'config*' -o -name '*.in' \) -print
44 .MAKEOVERRIDES+= _GNU_CFGSRC
45 .endif
47 CONFIGURE_ENV+= \
48                 AR=${HOST_AR:Q} \
49                 AWK=${TOOL_AWK:Q} \
50                 CC=${HOST_CC:Q} \
51                 CFLAGS=${HOST_CFLAGS:Q} \
52                 CPPFLAGS=${HOST_CPPFLAGS:Q} \
53                 CXX=${HOST_CXX:Q} \
54                 CXXFLAGS=${HOST_CXXFLAGS:Q} \
55                 INSTALL=${HOST_INSTALL_FILE:Q} \
56                 LDFLAGS=${HOST_LDFLAGS:Q} \
57                 LEX=${LEX:Q} \
58                 MAKE=${MAKE:Q} \
59                 PATH="${TOOLDIR}/bin:$$PATH" \
60                 RANLIB=${HOST_RANLIB:Q} \
61                 YACC=${YACC:Q}
63 BUILD_ENV+=     ${CONFIGURE_ENV}
65 CONFIGURE_ARGS+=--prefix=${TOOLDIR}
66 .if ${MKPIC} == "no"
67 CONFIGURE_ARGS+=--disable-shared
68 .endif
70 .ifndef _NOWRAPPER
71 # Some systems have a small ARG_MAX.  On such systems, prevent Make
72 # variables set on the command line from being exported in the
73 # environment (they will still be set in MAKEOVERRIDES).
74 BUILD_OSTYPE!=  uname -s
75 .if ${BUILD_OSTYPE} == "Darwin" || ${BUILD_OSTYPE} == "FreeBSD"
76 __noenvexport=  -X
77 .endif
78 MAKE_ARGS:=     ${__noenvexport} -f ${.PARSEDIR}/Makefile.gnuwrap ${MAKE_ARGS}
79 .else
80 MAKE_ARGS+=     _NOWRAPPER=1
81 .endif
83 MAKE_ARGS+=     BISON=true DESTDIR= INSTALL=${HOST_INSTALL_FILE:Q}
85 ALL_TARGET?=    all
86 INSTALL_TARGET?=install
88 .configure_done: ${_GNU_CFGSRC} ${.CURDIR}/Makefile
89         @mkdir build 2>/dev/null || true
90         @(cd build && ${CONFIGURE_ENV} ${HOST_SH} ${GNUHOSTDIST}/configure ${CONFIGURE_ARGS})
91         @touch $@
93 # The .build_done timestamp is only updated if a file actually changes
94 # in the build tree during "make all".  This way, if nothing has changed,
95 # a "make install MKUPDATE=yes" will do nothing.
97 .build_done: .configure_done
98         @(cd build && ${BUILD_ENV} ${MAKE} ${MAKE_ARGS} ${ALL_TARGET})
99         @if [ ! -f $@ ] || [ -n "$$(find build -type f -newer .build_done -print)" ]; \
100                 then touch $@; fi
102 .install_done! ${BUILD:D.build_done}
103         @(cd ${.OBJDIR}/build && ${MAKE} ${MAKE_ARGS} ${INSTALL_TARGET})
104         @touch $@
106 .PHONY: .build_done .install_done
108 # Mapping to standard targets.
110 .if ${USETOOLS} == "yes"
111 realall: .build_done
112 realinstall: .install_done
113 .endif
115 clean: clean.gnu
116 clean.gnu:
117         -rm -r -f .*_done build
119 .include <bsd.hostprog.mk>