Home | History | Annotate | Line # | Download | only in tools
Makefile.gmakehost revision 1.1
      1 #	$NetBSD: Makefile.gmakehost,v 1.1 2006/05/11 01:17:53 mrg 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.
     22 BUILD_OSTYPE!=  uname -s
     23 .if ${BUILD_OSTYPE} == "Darwin"
     24 HOST_CFLAGS+=-O2 -no-cpp-precomp
     25 .endif
     26 
     27 GNUHOSTDIST?=	${.CURDIR}/../../gnu/dist/${MODULE}
     28 
     29 FIND_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 
     48 CONFIGURE_ENV+=	CC=${HOST_CC:Q} \
     49 		CFLAGS=${HOST_CFLAGS:Q} \
     50 		CPPFLAGS=${HOST_CPPFLAGS:Q} \
     51 		CXX=${HOST_CXX:Q} \
     52 		CXXFLAGS=${HOST_CXXFLAGS:Q} \
     53 		INSTALL=${HOST_INSTALL_FILE:Q} \
     54 		LDFLAGS=${HOST_LDFLAGS:Q} \
     55 		AR=${HOST_AR:Q} \
     56 		RANLIB=${HOST_RANLIB:Q} \
     57 		LEX=${LEX:Q} \
     58 		MAKE=${TOOL_GMAKE:Q} \
     59 		PATH="${TOOLDIR}/bin:$$PATH" \
     60 		YACC=${YACC:Q}
     61 
     62 BUILD_ENV+=	${CONFIGURE_ENV}
     63 
     64 CONFIGURE_ARGS+=--prefix=${TOOLDIR}
     65 .if ${MKPIC} == "no"
     66 CONFIGURE_ARGS+=--disable-shared
     67 .endif
     68 
     69 # don't need this for gmake? i hope.  might need gmake equiv of -X?
     70 ##.ifndef _NOWRAPPER
     71 ### Some systems have a small ARG_MAX.  On such systems, prevent Make
     72 ### variables set on the command line from being exported in the
     73 ### environment (they will still be set in MAKEOVERRIDES).
     74 ##BUILD_OSTYPE!=	uname -s
     75 ##.if ${BUILD_OSTYPE} == "Darwin" || ${BUILD_OSTYPE} == "FreeBSD"
     76 ##__noenvexport=	-X
     77 ##.endif
     78 ##MAKE_ARGS:=	${__noenvexport} -f ${.PARSEDIR}/Makefile.gnuwrap ${MAKE_ARGS}
     79 ##.else
     80 ##MAKE_ARGS+=	_NOWRAPPER=1
     81 ##.endif
     82 
     83 MAKE_ARGS+=	BISON=true DESTDIR= INSTALL=${HOST_INSTALL_FILE:Q}
     84 
     85 ALL_TARGET?=	all
     86 INSTALL_TARGET?=install
     87 
     88 .configure_done: ${_GNU_CFGSRC} ${.CURDIR}/Makefile
     89 	@mkdir build 2>/dev/null || true
     90 	@(cd build && /usr/bin/env ${CONFIGURE_ENV} ${HOST_SH} ${GNUHOSTDIST}/configure ${CONFIGURE_ARGS})
     91 	@touch $@
     92 
     93 # The .build_done timestamp is only updated if a file actually changes
     94 # in the build tree during "make all".  This way, if nothing has changed,
     95 # a "make install MKUPDATE=yes" will do nothing.
     96 
     97 # gmake version of this puts MAKE_ARGS in the environment to be sure that
     98 # sub-gmake's get them, otherwise tools/gcc tries to build libgcc and
     99 # fails.  it also uses "env -i" to entirely clear out MAKEFLAGS.
    100 
    101 .build_done: .configure_done
    102 	@(cd build && /usr/bin/env -i ${BUILD_ENV} ${MAKE_ARGS} ${TOOL_GMAKE} -e ${ALL_TARGET})
    103 	@if [ ! -f $@ ] || [ -n "$$(find build -type f -newer .build_done -print)" ]; \
    104 		then touch $@; fi
    105 
    106 .install_done! ${BUILD:D.build_done}
    107 	@(cd ${.OBJDIR}/build && /usr/bin/env -i ${BUILD_ENV} ${MAKE_ARGS} ${TOOL_GMAKE} -e ${INSTALL_TARGET})
    108 	@touch $@
    109 
    110 .PHONY: .build_done .install_done
    111 
    112 # Mapping to standard targets.
    113 
    114 .if ${USETOOLS} == "yes"
    115 realall: .build_done
    116 realinstall: .install_done
    117 .endif
    118 
    119 clean: clean.gnu
    120 clean.gnu:
    121 	-rm -r -f .*_done build
    122 
    123 .include <bsd.hostprog.mk>
    124