2016-01-16 21:38:53 +03:00
|
|
|
# $NetBSD: Makefile.gnuhost,v 1.44 2016/01/16 18:38:53 christos Exp $
|
2001-11-13 02:16:17 +03:00
|
|
|
#
|
|
|
|
# Rules used when building a GNU host package. Expects MODULE to be set.
|
|
|
|
#
|
|
|
|
# There's not a lot we can do to build reliably in the face of many
|
|
|
|
# available configuration options. To be as low-overhead as possible,
|
|
|
|
# we follow the following scheme:
|
|
|
|
#
|
|
|
|
# * Configuration is only re-run when an autoconf source file (such as
|
|
|
|
# "configure" or "config.sub") is changed.
|
|
|
|
#
|
|
|
|
# * "config.status" is run to rebuild Makefiles and .h files if an
|
|
|
|
# autoconf-parsed file (such as Makefile.in) is changed.
|
|
|
|
#
|
2003-07-18 12:26:01 +04:00
|
|
|
# * If MKUPDATE != "no", "make install" is only run if a build has happened
|
2001-11-13 02:16:17 +03:00
|
|
|
# since the last install in the current directory.
|
|
|
|
|
|
|
|
.include <bsd.own.mk>
|
|
|
|
|
2003-10-07 18:12:36 +04:00
|
|
|
# Disable use of pre-compiled headers on Darwin.
|
2012-01-21 03:01:05 +04:00
|
|
|
BUILD_OSTYPE!= uname -s
|
2003-10-07 18:12:36 +04:00
|
|
|
.if ${BUILD_OSTYPE} == "Darwin"
|
2003-10-11 01:49:59 +04:00
|
|
|
HOST_CFLAGS+=-O2 -no-cpp-precomp
|
2003-10-07 18:12:36 +04:00
|
|
|
.endif
|
2012-01-21 03:01:05 +04:00
|
|
|
MAKE_PROGRAM?= ${MAKE}
|
2003-10-07 18:12:36 +04:00
|
|
|
|
2016-01-16 21:38:53 +03:00
|
|
|
.for i in 3 2
|
|
|
|
.if exists(${.CURDIR}/../../external/gpl${i}/${MODULE}/dist)
|
|
|
|
GNUHOSTDIST?= ${.CURDIR}/../../external/gpl${i}/${MODULE}/dist
|
2016-01-14 02:01:15 +03:00
|
|
|
.endif
|
2016-01-16 21:38:53 +03:00
|
|
|
.endfor
|
2001-11-13 02:16:17 +03:00
|
|
|
|
|
|
|
FIND_ARGS+= \! \( -type d \( \
|
|
|
|
-name 'CVS' -o \
|
|
|
|
-name 'config' -o \
|
|
|
|
-name 'doc' -o \
|
|
|
|
-name 'po' -o \
|
2001-11-16 19:41:46 +03:00
|
|
|
-name 'nbsd.mt' -o \
|
2001-11-13 02:16:17 +03:00
|
|
|
-name 'tests*' \
|
|
|
|
\) -prune \)
|
|
|
|
|
|
|
|
# Do this "find" only if actually building something.
|
|
|
|
.if (${USETOOLS} == "yes") && empty(.MAKEFLAGS:M-V*) && \
|
|
|
|
(make(all) || make(realall) || (!make(clean) && !make(cleandir) && !make(obj))) && \
|
|
|
|
!defined(_GNU_CFGSRC)
|
|
|
|
|
2003-02-07 04:52:51 +03:00
|
|
|
_GNU_CFGSRC!= find ${GNUHOSTDIST} ${FIND_ARGS} \
|
2001-11-13 02:16:17 +03:00
|
|
|
-type f \( -name 'config*' -o -name '*.in' \) -print
|
|
|
|
.MAKEOVERRIDES+= _GNU_CFGSRC
|
|
|
|
.endif
|
|
|
|
|
2008-10-20 02:05:19 +04:00
|
|
|
CONFIGURE_ENV+= \
|
|
|
|
AR=${HOST_AR:Q} \
|
|
|
|
AWK=${TOOL_AWK:Q} \
|
|
|
|
CC=${HOST_CC:Q} \
|
2001-11-13 02:16:17 +03:00
|
|
|
CFLAGS=${HOST_CFLAGS:Q} \
|
2013-08-14 00:41:25 +04:00
|
|
|
CONFIG_SHELL=${HOST_SH:Q} \
|
2001-11-13 02:16:17 +03:00
|
|
|
CPPFLAGS=${HOST_CPPFLAGS:Q} \
|
|
|
|
CXX=${HOST_CXX:Q} \
|
|
|
|
CXXFLAGS=${HOST_CXXFLAGS:Q} \
|
2001-11-19 07:47:42 +03:00
|
|
|
INSTALL=${HOST_INSTALL_FILE:Q} \
|
2001-11-13 02:16:17 +03:00
|
|
|
LDFLAGS=${HOST_LDFLAGS:Q} \
|
2002-01-31 05:42:25 +03:00
|
|
|
LEX=${LEX:Q} \
|
2013-08-07 21:50:55 +04:00
|
|
|
M4=${TOOL_M4:Q} \
|
2012-01-21 03:01:05 +04:00
|
|
|
MAKE=${MAKE_PROGRAM:Q} \
|
2002-01-31 05:42:25 +03:00
|
|
|
PATH="${TOOLDIR}/bin:$$PATH" \
|
2008-10-20 02:05:19 +04:00
|
|
|
RANLIB=${HOST_RANLIB:Q} \
|
2002-01-31 05:42:25 +03:00
|
|
|
YACC=${YACC:Q}
|
2001-11-13 02:16:17 +03:00
|
|
|
|
2005-02-11 18:01:03 +03:00
|
|
|
BUILD_ENV+= ${CONFIGURE_ENV}
|
|
|
|
|
2004-02-15 22:52:27 +03:00
|
|
|
CONFIGURE_ARGS+=--prefix=${TOOLDIR}
|
2004-02-27 17:52:01 +03:00
|
|
|
.if ${MKPIC} == "no"
|
|
|
|
CONFIGURE_ARGS+=--disable-shared
|
|
|
|
.endif
|
2001-11-13 02:16:17 +03:00
|
|
|
|
2012-01-21 03:01:05 +04:00
|
|
|
.if ${MAKE_PROGRAM} == ${MAKE}
|
2001-11-13 07:28:27 +03:00
|
|
|
.ifndef _NOWRAPPER
|
2003-03-14 08:22:50 +03:00
|
|
|
# Some systems have a small ARG_MAX. On such systems, prevent Make
|
|
|
|
# variables set on the command line from being exported in the
|
|
|
|
# environment (they will still be set in MAKEOVERRIDES).
|
|
|
|
.if ${BUILD_OSTYPE} == "Darwin" || ${BUILD_OSTYPE} == "FreeBSD"
|
|
|
|
__noenvexport= -X
|
|
|
|
.endif
|
|
|
|
MAKE_ARGS:= ${__noenvexport} -f ${.PARSEDIR}/Makefile.gnuwrap ${MAKE_ARGS}
|
2001-11-13 07:28:27 +03:00
|
|
|
.else
|
|
|
|
MAKE_ARGS+= _NOWRAPPER=1
|
2012-01-21 03:01:05 +04:00
|
|
|
.endif
|
|
|
|
BUILD_COMMAND= ${BUILD_ENV} ${MAKE} ${MAKE_ARGS}
|
|
|
|
.else
|
|
|
|
|
|
|
|
# gmake version of this puts MAKE_ARGS in the environment to be sure that
|
|
|
|
# sub-gmake's get them, otherwise tools/gcc tries to build libgcc and
|
|
|
|
# fails. it also uses "env -i" to entirely clear out MAKEFLAGS.
|
|
|
|
GMAKE_J_ARGS?= ${MAKEFLAGS:[*]:M*-j*:C/.*(-j ?[0-9]*).*/\1/W}
|
|
|
|
BUILD_COMMAND= /usr/bin/env -i ${BUILD_ENV} ${MAKE_ARGS} ${TOOL_GMAKE} ${GMAKE_J_ARGS} -e ${MAKE_ARGS}
|
|
|
|
|
2001-11-13 07:28:27 +03:00
|
|
|
.endif
|
|
|
|
|
2002-02-01 01:43:33 +03:00
|
|
|
MAKE_ARGS+= BISON=true DESTDIR= INSTALL=${HOST_INSTALL_FILE:Q}
|
2001-11-13 07:43:25 +03:00
|
|
|
|
2001-11-13 02:16:17 +03:00
|
|
|
ALL_TARGET?= all
|
|
|
|
INSTALL_TARGET?=install
|
|
|
|
|
2012-04-18 15:28:30 +04:00
|
|
|
BUILD_PLATFORM!= uname -srm | tr ' ()' '-'
|
2012-01-21 03:01:05 +04:00
|
|
|
CONFIGURE_PLATFORM!= if [ -s .configure_done ]; then cat .configure_done; else echo none; fi
|
|
|
|
.if "${BUILD_PLATFORM}" != "${CONFIGURE_PLATFORM}"
|
|
|
|
configure_cleanup:
|
|
|
|
@mkdir build 2>/dev/null || true
|
|
|
|
@(echo "Cleaning stale cache files ${BUILD_PLATFORM} != ${CONFIGURE_PLATFORM}")
|
2012-06-20 01:48:33 +04:00
|
|
|
@(cd build && find . -name config.cache | xargs rm -f)
|
2012-01-21 03:01:05 +04:00
|
|
|
configure_cleanup=configure_cleanup
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.configure_done: ${_GNU_CFGSRC} ${.CURDIR}/Makefile ${configure_cleanup}
|
2001-11-13 02:16:17 +03:00
|
|
|
@mkdir build 2>/dev/null || true
|
2005-02-11 18:11:08 +03:00
|
|
|
@(cd build && ${CONFIGURE_ENV} ${HOST_SH} ${GNUHOSTDIST}/configure ${CONFIGURE_ARGS})
|
2012-01-21 03:01:05 +04:00
|
|
|
@echo ${BUILD_PLATFORM} > $@
|
2001-11-13 02:16:17 +03:00
|
|
|
|
2002-01-03 19:45:18 +03:00
|
|
|
# The .build_done timestamp is only updated if a file actually changes
|
|
|
|
# in the build tree during "make all". This way, if nothing has changed,
|
2003-07-18 12:26:01 +04:00
|
|
|
# a "make install MKUPDATE=yes" will do nothing.
|
2002-01-03 19:45:18 +03:00
|
|
|
|
2001-11-13 02:16:17 +03:00
|
|
|
.build_done: .configure_done
|
2012-01-21 03:01:05 +04:00
|
|
|
@(cd build && ${BUILD_COMMAND} ${ALL_TARGET})
|
2002-02-01 01:43:33 +03:00
|
|
|
@if [ ! -f $@ ] || [ -n "$$(find build -type f -newer .build_done -print)" ]; \
|
2002-01-03 19:47:08 +03:00
|
|
|
then touch $@; fi
|
2001-11-13 02:16:17 +03:00
|
|
|
|
2004-06-12 18:56:30 +04:00
|
|
|
.install_done! ${BUILD:D.build_done}
|
2012-01-21 03:01:05 +04:00
|
|
|
@(cd ${.OBJDIR}/build && ${BUILD_COMMAND} ${INSTALL_TARGET})
|
2001-11-13 02:16:17 +03:00
|
|
|
@touch $@
|
|
|
|
|
|
|
|
# Mapping to standard targets.
|
|
|
|
|
|
|
|
.if ${USETOOLS} == "yes"
|
|
|
|
realall: .build_done
|
|
|
|
realinstall: .install_done
|
|
|
|
.endif
|
|
|
|
|
|
|
|
clean: clean.gnu
|
|
|
|
clean.gnu:
|
2004-06-21 22:20:08 +04:00
|
|
|
-rm -r -f .*_done build
|
2001-11-13 02:16:17 +03:00
|
|
|
|
|
|
|
.include <bsd.hostprog.mk>
|