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