Home | History | Annotate | Line # | Download | only in tools
Makefile.gnuhost revision 1.22
      1 #	$NetBSD: Makefile.gnuhost,v 1.22 2003/10/18 16:33:58 lukem 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 BUILD_OSTYPE!=  uname -s
     22 .if ${BUILD_OSTYPE} == "Darwin"
     23 HOST_CFLAGS+=-O2 -no-cpp-precomp
     24 .endif
     25 
     26 GNUHOSTDIST?=	${.CURDIR}/../../gnu/dist/${MODULE}
     27 
     28 FIND_ARGS+=	\! \( -type d \( \
     29 			-name 'CVS' -o \
     30 			-name 'config' -o \
     31 			-name 'doc' -o \
     32 			-name 'po' -o \
     33 			-name 'nbsd.mt' -o \
     34 			-name 'tests*' \
     35 		\) -prune \)
     36 
     37 # Do this "find" only if actually building something.
     38 .if (${USETOOLS} == "yes") && empty(.MAKEFLAGS:M-V*) && \
     39     (make(all) || make(realall) || (!make(clean) && !make(cleandir) && !make(obj))) && \
     40     !defined(_GNU_CFGSRC)
     41 
     42 _GNU_CFGSRC!=	find ${GNUHOSTDIST} ${FIND_ARGS} \
     43 		-type f \( -name 'config*' -o -name '*.in' \) -print
     44 .MAKEOVERRIDES+= _GNU_CFGSRC
     45 .endif
     46 
     47 CONFIGURE_ENV+=	CC=${HOST_CC:Q} \
     48 		CFLAGS=${HOST_CFLAGS:Q} \
     49 		CPPFLAGS=${HOST_CPPFLAGS:Q} \
     50 		CXX=${HOST_CXX:Q} \
     51 		CXXFLAGS=${HOST_CXXFLAGS:Q} \
     52 		INSTALL=${HOST_INSTALL_FILE:Q} \
     53 		LDFLAGS=${HOST_LDFLAGS:Q} \
     54 		LEX=${LEX:Q} \
     55 		PATH="${TOOLDIR}/bin:$$PATH" \
     56 		YACC=${YACC:Q}
     57 
     58 CONFIGURE_ARGS+=--prefix=${TOOLDIR} --disable-shared
     59 
     60 .ifndef _NOWRAPPER
     61 # Some systems have a small ARG_MAX.  On such systems, prevent Make
     62 # variables set on the command line from being exported in the
     63 # environment (they will still be set in MAKEOVERRIDES).
     64 BUILD_OSTYPE!=	uname -s
     65 .if ${BUILD_OSTYPE} == "Darwin" || ${BUILD_OSTYPE} == "FreeBSD"
     66 __noenvexport=	-X
     67 .endif
     68 MAKE_ARGS:=	${__noenvexport} -f ${.PARSEDIR}/Makefile.gnuwrap ${MAKE_ARGS}
     69 .else
     70 MAKE_ARGS+=	_NOWRAPPER=1
     71 .endif
     72 
     73 MAKE_ARGS+=	BISON=true DESTDIR= INSTALL=${HOST_INSTALL_FILE:Q}
     74 
     75 ALL_TARGET?=	all
     76 INSTALL_TARGET?=install
     77 
     78 .configure_done: ${_GNU_CFGSRC} ${.CURDIR}/Makefile
     79 	@mkdir build 2>/dev/null || true
     80 	@(cd build && ${CONFIGURE_ENV} sh ${GNUHOSTDIST}/configure ${CONFIGURE_ARGS})
     81 	@touch $@
     82 
     83 # The .build_done timestamp is only updated if a file actually changes
     84 # in the build tree during "make all".  This way, if nothing has changed,
     85 # a "make install MKUPDATE=yes" will do nothing.
     86 
     87 .build_done: .configure_done
     88 	@(cd build && ${MAKE} ${MAKE_ARGS} ${ALL_TARGET})
     89 	@if [ ! -f $@ ] || [ -n "$$(find build -type f -newer .build_done -print)" ]; \
     90 		then touch $@; fi
     91 
     92 .install_done: ${BUILD:D.build_done}
     93 .if ${MKUPDATE} != "no"
     94 	@cd ${.OBJDIR}; \
     95 	if [ ! -f .install_done ] || [ ! -f .build_done ] || \
     96 	[ -n "$$(find .build_done -prune -newer .install_done -print)" ]; then \
     97 		(cd build && ${MAKE} ${MAKE_ARGS} ${INSTALL_TARGET}); \
     98 	fi
     99 .else
    100 	@(cd ${.OBJDIR}/build && ${MAKE} ${MAKE_ARGS} ${INSTALL_TARGET})
    101 .endif
    102 	@touch $@
    103 
    104 .PHONY: .build_done .install_done
    105 
    106 # Mapping to standard targets.
    107 
    108 .if ${USETOOLS} == "yes"
    109 realall: .build_done
    110 realinstall: .install_done
    111 .endif
    112 
    113 clean: clean.gnu
    114 clean.gnu:
    115 	${_MKCMD}\
    116 	rm -r -f .*_done build
    117 
    118 .include <bsd.hostprog.mk>
    119