Makefile.gnuhost revision 1.45
1# $NetBSD: Makefile.gnuhost,v 1.45 2018/04/13 06:15:26 snj 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 MKUPDATE != "no", "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# Disable use of pre-compiled headers on Darwin. 21# GCC build exceeds the macOS clang default bracket nesting level of 256. 22BUILD_OSTYPE!= uname -s 23.if ${BUILD_OSTYPE} == "Darwin" 24HOST_CFLAGS+=-O2 -no-cpp-precomp 25HOST_CFLAGS+=-O2 -no-cpp-precomp -fbracket-depth=512 26HOST_CXXFLAGS+= -fbracket-depth=512 27.endif 28MAKE_PROGRAM?= ${MAKE} 29 30.for i in 3 2 31.if exists(${.CURDIR}/../../external/gpl${i}/${MODULE}/dist) 32GNUHOSTDIST?= ${.CURDIR}/../../external/gpl${i}/${MODULE}/dist 33.endif 34.endfor 35 36FIND_ARGS+= \! \( -type d \( \ 37 -name 'CVS' -o \ 38 -name 'config' -o \ 39 -name 'doc' -o \ 40 -name 'po' -o \ 41 -name 'nbsd.mt' -o \ 42 -name 'tests*' \ 43 \) -prune \) 44 45# Do this "find" only if actually building something. 46.if (${USETOOLS} == "yes") && empty(.MAKEFLAGS:M-V*) && \ 47 (make(all) || make(realall) || (!make(clean) && !make(cleandir) && !make(obj))) && \ 48 !defined(_GNU_CFGSRC) 49 50_GNU_CFGSRC!= find ${GNUHOSTDIST} ${FIND_ARGS} \ 51 -type f \( -name 'config*' -o -name '*.in' \) -print 52.MAKEOVERRIDES+= _GNU_CFGSRC 53.endif 54 55CONFIGURE_ENV+= \ 56 AR=${HOST_AR:Q} \ 57 AWK=${TOOL_AWK:Q} \ 58 CC=${HOST_CC:Q} \ 59 CFLAGS=${HOST_CFLAGS:Q} \ 60 CONFIG_SHELL=${HOST_SH:Q} \ 61 CPPFLAGS=${HOST_CPPFLAGS:Q} \ 62 CXX=${HOST_CXX:Q} \ 63 CXXFLAGS=${HOST_CXXFLAGS:Q} \ 64 INSTALL=${HOST_INSTALL_FILE:Q} \ 65 LDFLAGS=${HOST_LDFLAGS:Q} \ 66 LEX=${LEX:Q} \ 67 M4=${TOOL_M4:Q} \ 68 MAKE=${MAKE_PROGRAM:Q} \ 69 PATH="${TOOLDIR}/bin:$$PATH" \ 70 RANLIB=${HOST_RANLIB:Q} \ 71 YACC=${YACC:Q} 72 73BUILD_ENV+= ${CONFIGURE_ENV} 74 75CONFIGURE_ARGS+=--prefix=${TOOLDIR} 76.if ${MKPIC} == "no" 77CONFIGURE_ARGS+=--disable-shared 78.endif 79 80.if ${MAKE_PROGRAM} == ${MAKE} 81.ifndef _NOWRAPPER 82# Some systems have a small ARG_MAX. On such systems, prevent Make 83# variables set on the command line from being exported in the 84# environment (they will still be set in MAKEOVERRIDES). 85.if ${BUILD_OSTYPE} == "Darwin" || ${BUILD_OSTYPE} == "FreeBSD" 86__noenvexport= -X 87.endif 88MAKE_ARGS:= ${__noenvexport} -f ${.PARSEDIR}/Makefile.gnuwrap ${MAKE_ARGS} 89.else 90MAKE_ARGS+= _NOWRAPPER=1 91.endif 92BUILD_COMMAND= ${BUILD_ENV} ${MAKE} ${MAKE_ARGS} 93.else 94 95# gmake version of this puts MAKE_ARGS in the environment to be sure that 96# sub-gmake's get them, otherwise tools/gcc tries to build libgcc and 97# fails. it also uses "env -i" to entirely clear out MAKEFLAGS. 98GMAKE_J_ARGS?= ${MAKEFLAGS:[*]:M*-j*:C/.*(-j ?[0-9]*).*/\1/W} 99BUILD_COMMAND= /usr/bin/env -i ${BUILD_ENV} ${MAKE_ARGS} ${TOOL_GMAKE} ${GMAKE_J_ARGS} -e ${MAKE_ARGS} 100 101.endif 102 103MAKE_ARGS+= BISON=true DESTDIR= INSTALL=${HOST_INSTALL_FILE:Q} 104 105ALL_TARGET?= all 106INSTALL_TARGET?=install 107 108BUILD_PLATFORM!= uname -srm | tr ' ()' '-' 109CONFIGURE_PLATFORM!= if [ -s .configure_done ]; then cat .configure_done; else echo none; fi 110.if "${BUILD_PLATFORM}" != "${CONFIGURE_PLATFORM}" 111configure_cleanup: 112 @mkdir build 2>/dev/null || true 113 @(echo "Cleaning stale cache files ${BUILD_PLATFORM} != ${CONFIGURE_PLATFORM}") 114 @(cd build && find . -name config.cache | xargs rm -f) 115configure_cleanup=configure_cleanup 116.endif 117 118.configure_done: ${_GNU_CFGSRC} ${.CURDIR}/Makefile ${configure_cleanup} 119 @mkdir build 2>/dev/null || true 120 @(cd build && ${CONFIGURE_ENV} ${HOST_SH} ${GNUHOSTDIST}/configure ${CONFIGURE_ARGS}) 121 @echo ${BUILD_PLATFORM} > $@ 122 123# The .build_done timestamp is only updated if a file actually changes 124# in the build tree during "make all". This way, if nothing has changed, 125# a "make install MKUPDATE=yes" will do nothing. 126 127.build_done: .configure_done 128 @(cd build && ${BUILD_COMMAND} ${ALL_TARGET}) 129 @if [ ! -f $@ ] || [ -n "$$(find build -type f -newer .build_done -print)" ]; \ 130 then touch $@; fi 131 132.install_done! ${BUILD:D.build_done} 133 @(cd ${.OBJDIR}/build && ${BUILD_COMMAND} ${INSTALL_TARGET}) 134 @touch $@ 135 136# Mapping to standard targets. 137 138.if ${USETOOLS} == "yes" 139realall: .build_done 140realinstall: .install_done 141.endif 142 143clean: clean.gnu 144clean.gnu: 145 -rm -r -f .*_done build 146 147.include <bsd.hostprog.mk> 148