NetBSD/tools/Makefile.gnuhost

112 lines
3.2 KiB
Makefile
Raw Normal View History

# $NetBSD: Makefile.gnuhost,v 1.18 2003/03/14 05:22:51 thorpej Exp $
#
# 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.
#
# * If UPDATE is set, "make install" is only run if a build has happened
# since the last install in the current directory.
.include <bsd.own.mk>
GNUHOSTDIST?= ${.CURDIR}/../../gnu/dist/${MODULE}
FIND_ARGS+= \! \( -type d \( \
-name 'CVS' -o \
-name 'config' -o \
-name 'doc' -o \
-name 'po' -o \
-name 'nbsd.mt' -o \
-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)
_GNU_CFGSRC!= find ${GNUHOSTDIST} ${FIND_ARGS} \
-type f \( -name 'config*' -o -name '*.in' \) -print
.MAKEOVERRIDES+= _GNU_CFGSRC
.endif
CONFIGURE_ENV+= CC=${HOST_CC:Q} \
CFLAGS=${HOST_CFLAGS:Q} \
CPPFLAGS=${HOST_CPPFLAGS:Q} \
CXX=${HOST_CXX:Q} \
CXXFLAGS=${HOST_CXXFLAGS:Q} \
INSTALL=${HOST_INSTALL_FILE:Q} \
LDFLAGS=${HOST_LDFLAGS:Q} \
LEX=${LEX:Q} \
PATH="${TOOLDIR}/bin:$$PATH" \
YACC=${YACC:Q}
CONFIGURE_ARGS+=--prefix=${TOOLDIR} --disable-shared
.ifndef _NOWRAPPER
# 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).
BUILD_OSTYPE!= uname -s
.if ${BUILD_OSTYPE} == "Darwin" || ${BUILD_OSTYPE} == "FreeBSD"
__noenvexport= -X
.endif
MAKE_ARGS:= ${__noenvexport} -f ${.PARSEDIR}/Makefile.gnuwrap ${MAKE_ARGS}
.else
MAKE_ARGS+= _NOWRAPPER=1
.endif
MAKE_ARGS+= BISON=true DESTDIR= INSTALL=${HOST_INSTALL_FILE:Q}
ALL_TARGET?= all
INSTALL_TARGET?=install
.configure_done: ${_GNU_CFGSRC} ${.CURDIR}/Makefile
@mkdir build 2>/dev/null || true
@(cd build && ${CONFIGURE_ENV} sh ${GNUHOSTDIST}/configure ${CONFIGURE_ARGS})
@touch $@
# 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,
# a "make install UPDATE=" will do nothing.
.build_done: .configure_done
@(cd build && ${MAKE} ${MAKE_ARGS} ${ALL_TARGET})
@if [ ! -f $@ ] || [ -n "$$(find build -type f -newer .build_done -print)" ]; \
2002-01-03 19:47:08 +03:00
then touch $@; fi
.install_done: ${BUILD:D.build_done}
.if defined(UPDATE)
@cd ${.OBJDIR}; \
if [ ! -f .install_done ] || [ ! -f .build_done ] || \
[ -n "$$(find .build_done -prune -newer .install_done -print)" ]; then \
(cd build && ${MAKE} ${MAKE_ARGS} ${INSTALL_TARGET}); \
fi
.else
@(cd ${.OBJDIR}/build && ${MAKE} ${MAKE_ARGS} ${INSTALL_TARGET})
.endif
@touch $@
.PHONY: .build_done .install_done
# Mapping to standard targets.
.if ${USETOOLS} == "yes"
realall: .build_done
realinstall: .install_done
.endif
clean: clean.gnu
clean.gnu:
-rm -r -f .*_done build
.include <bsd.hostprog.mk>