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