Makefile revision 1.70
11.70Sjoerg#	$NetBSD: Makefile,v 1.70 2013/12/11 01:24:08 joerg Exp $
21.67Schristos
31.67SchristosHOSTLIB=	nbcompat
41.63Schristos
51.63Schristos.include <bsd.own.mk>
61.1Stv
71.59SjoergSRCS=		atoll.c basename.c cdbr.c cdbw.c dirname.c \
81.68Schristos		dprintf.c fgetln.c flock.c fparseln.c fpurge.c \
91.58Sjoerg		getcap.c getline.c getmode.c getopt_long.c gettemp.c \
101.55Sjoerg		heapsort.c \
111.39Selad		issetugid.c lchflags.c lchmod.c lchown.c libyywrap.c \
121.54Sroy		md2.c md2hl.c md4c.c md4hl.c md5c.c md5hl.c \
131.54Sroy		mi_vector_hash.c mkdtemp.c \
141.22Sthorpej		mkstemp.c pread.c putc_unlocked.c pwcache.c pwrite.c \
151.51Slukem		pw_scan.c \
161.51Slukem		raise_default_signal.c rmd160.c rmd160hl.c \
171.51Slukem		setenv.c setgroupent.c \
181.34Selad		setpassent.c setprogname.c sha1.c sha1hl.c sha2.c \
191.69Sapb		sha256hl.c sha384hl.c sha512hl.c snprintb.c snprintf.c \
201.69Sapb		stat_flags.c strlcat.c strlcpy.c strmode.c strndup.c \
211.69Sapb		strsep.c strsuftoll.c strtoll.c \
221.69Sapb		unvis.c vis.c err.c errx.c verr.c verrx.c \
231.44Schristos		vwarn.c vwarnx.c warn.c warnx.c fts.c glob.c efun.c
241.21Sthorpej
251.21SthorpejBUILD_OSTYPE!=  uname -s
261.21Sthorpej
271.21Sthorpej# Disable use of pre-compiled headers on Darwin.
281.21Sthorpej.if ${BUILD_OSTYPE} == "Darwin"
291.21SthorpejCPPFLAGS+=	-no-cpp-precomp
301.21Sthorpej.endif
311.6Stv
321.6Stv# -D_FILE_OFFSET_BITS=64 produces a much more amenable `struct stat', and
331.6Stv# other file ops, on many systems, without changing function names.
341.6Stv
351.47SdogcowCPPFLAGS+=	-I. -I./include -I${.CURDIR} -I${.CURDIR}/sys \
361.47Sdogcow		-DHAVE_NBTOOL_CONFIG_H=1 -D_FILE_OFFSET_BITS=64
371.3Stv
381.57Sjoerg.PATH:		${.CURDIR}/../../lib/libc/cdb \
391.57Sjoerg		${.CURDIR}/../../lib/libc/gen \
401.9Sbjh21		${.CURDIR}/../../lib/libc/hash \
411.39Selad		${.CURDIR}/../../lib/libc/hash/md2 \
421.38Selad		${.CURDIR}/../../lib/libc/hash/md5 \
431.38Selad		${.CURDIR}/../../lib/libc/hash/rmd160 \
441.38Selad		${.CURDIR}/../../lib/libc/hash/sha1 \
451.34Selad		${.CURDIR}/../../lib/libc/hash/sha2 \
461.9Sbjh21		${.CURDIR}/../../lib/libc/md \
471.15Sthorpej		${.CURDIR}/../../lib/libc/stdio \
481.6Stv		${.CURDIR}/../../lib/libc/stdlib \
491.4Slukem		${.CURDIR}/../../lib/libc/string \
501.44Schristos		${.CURDIR}/../../lib/libutil \
511.70Sjoerg		${.CURDIR}/../../common/lib/libc/cdb \
521.40Schristos		${.CURDIR}/../../common/lib/libc/string \
531.46Smrg		${.CURDIR}/../../common/lib/libc/hash/rmd160 \
541.40Schristos		${.CURDIR}/../../common/lib/libc/hash/sha1 \
551.46Smrg		${.CURDIR}/../../common/lib/libc/hash/sha2 \
561.40Schristos		${.CURDIR}/../../common/lib/libc/md \
571.45Sthorpej		${.CURDIR}/../../common/lib/libc/stdlib \
581.69Sapb		${.CURDIR}/../../common/lib/libutil \
591.56Snjoly		${.CURDIR}/../../external/bsd/flex/dist
601.1Stv
611.6StvDPSRCS+=	defs.mk
621.43SchristosCLEANFILES+=	config.log config.status configure.lineno *.stamp
631.61SapbCLEANDIRFILES+=	defs.mk config.cache confdefs.h
641.3Stv
651.3Stv# Get components of Berkeley DB.
661.3Stv_CURDIR:=	${.CURDIR}
671.3Stv.CURDIR:=	${_CURDIR}/../../lib/libc
681.3Stv.include "${.CURDIR}/db/Makefile.inc"
691.3Stv.CURDIR:=	${_CURDIR}
701.3Stv
711.54SroySRCS:=		${SRCS:M*.c}
721.1Stv
731.42Swizconfig.cache: include/.stamp configure nbtool_config.h.in defs.mk.in
741.20Slukem	rm -f ${.TARGET}
751.3Stv	CC=${HOST_CC:Q} CFLAGS=${HOST_CFLAGS:Q} LDFLAGS=${HOST_LDFLAGS:Q} \
761.27Slukem		${HOST_SH} ${.CURDIR}/configure --cache-file=config.cache
771.20Slukem
781.20Slukemdefs.mk: config.cache
791.20Slukem	@touch ${.TARGET}
801.1Stv
811.61SapbINCFILES=	nbtool_config.h
821.66SchristosINCSUBDIRS=	sys machine rpc arpa
831.61SapbCLEANDIRFILES+= ${INCFILES}
841.61Sapb
851.61Sapb# CLEANDIRFILES may not contain directory names
861.61Sapbcleandir:	cleandir.include
871.61Sapbcleandir.include: .PHONY
881.61Sapb		rm -rf include
891.61Sapb
901.13Stvinclude/.stamp:
911.61Sapb	mkdir -p ${INCSUBDIRS:@d@ include/$d @}
921.20Slukem	@touch ${.TARGET}
931.6Stv
941.61Sapb# Install rules
951.61Sapb
961.61SapbHOST_LIBDIR=	${TOOLDIR}/lib
971.61SapbHOST_INCSDIR=	${TOOLDIR}/include
981.66SchristosHOST_SHAREDIR= ${TOOLDIR}/share
991.61Sapb
1001.64Schristosinstall:	.PHONY install.lib includes install.defs.mk
1011.61Sapb
1021.61Sapb# Install lib${HOSTLIB}.a in ${TOOLDIR}/lib
1031.61Sapbinstall.lib: .PHONY ${HOST_LIBDIR}/lib${HOSTLIB}.a
1041.61Sapb${HOST_LIBDIR}/lib${HOSTLIB}.a: lib${HOSTLIB}.a
1051.61Sapb	${_MKTARGET_INSTALL}
1061.61Sapb	${HOST_INSTALL_DIR} ${HOST_LIBDIR}
1071.61Sapb	${HOST_INSTALL_FILE} -m ${LIBMODE} ${.ALLSRC} ${.TARGET}
1081.61Sapb
1091.64Schristos.for _f in ${INCFILES}
1101.64SchristosHOST_INCINSTFILES+= ${HOST_INCSDIR}/compat/${_f}
1111.64Schristos${HOST_INCSDIR}/compat/${_f}: ${_f}
1121.64Schristos	${_MKTARGET_INSTALL}
1131.64Schristos	${HOST_INSTALL_FILE} ${.ALLSRC} ${.TARGET}
1141.64Schristos.endfor
1151.64Schristos
1161.61Sapb.for _d in ${INCSUBDIRS}
1171.64SchristosHOST_INCINSTDIRS+= ${HOST_INCSDIR}/compat/${_d}
1181.64Schristos${HOST_INCSDIR}/compat/${_d}:
1191.64Schristos	${_MKTARGET_INSTALL}
1201.64Schristos	${HOST_INSTALL_DIR} ${.TARGET}
1211.61Sapb.endfor
1221.64Schristos
1231.64Schristos# Install include files in ${TOOLDIR}/include/compat
1241.64Schristosincludes: .PHONY ${HOST_INCINSTDIRS} .WAIT ${HOST_INCINSTFILES}
1251.66Schristos	@(cd include && find . -name '*.h' -print | while read f ; do \
1261.66Schristos	    ${HOST_INSTALL_FILE} $$f ${HOST_INCSDIR}/compat/$$f ; \
1271.66Schristos	done)
1281.66Schristos
1291.61Sapb
1301.61Sapb# Install defs.mk in ${TOOLDIR}/share/compat
1311.61Sapbinstall.defs.mk: .PHONY ${HOST_SHAREDIR}/compat/defs.mk
1321.61Sapb${HOST_SHAREDIR}/compat/defs.mk: defs.mk
1331.61Sapb	${_MKTARGET_INSTALL}
1341.61Sapb	${HOST_INSTALL_DIR} ${HOST_SHAREDIR}
1351.61Sapb	${HOST_INSTALL_DIR} ${HOST_SHAREDIR}/compat
1361.61Sapb	${HOST_INSTALL_FILE} ${.ALLSRC} ${.TARGET}
1371.61Sapb
1381.61Sapb# bsd.hostlib.mk wants HOST_CPPFLAGS, not CPPFLAGS
1391.6Stv
1401.6StvHOST_CPPFLAGS:=	${CPPFLAGS}
1411.6StvCPPFLAGS:=	# empty
1421.1Stv
1431.1Stv.include <bsd.hostlib.mk>
1441.60Sapb
1451.60Sapb# Use uninstalled copy of host-mkdep
1461.60SapbHOST_MKDEP_OBJ!= cd ${.CURDIR}/../host-mkdep && ${PRINTOBJDIR}
1471.60SapbHOST_MKDEP=	${HOST_MKDEP_OBJ}/host-mkdep
1481.60SapbMKDEP=		${HOST_MKDEP}
1491.60Sapb
1501.61Sapb# Use uninstalled copy of the install program
1511.61SapbINSTALL_OBJ!=	cd ${NETBSDSRCDIR}/tools/binstall && ${PRINTOBJDIR}
1521.61SapbINSTALL=	${INSTALL_OBJ}/xinstall
1531.61Sapb
1541.60Sapb# Run "${TOOLDIR}/bin/nbmake-${MACHINE} regen" by hand after editing
1551.60Sapb# configure.ac.  See more detailed instructions in configure.ac.
1561.60Sapbregen:
1571.60Sapb	cd ${.CURDIR} && ${TOOLDIR}/bin/${_TOOL_PREFIX}autoconf
1581.60Sapb	cd ${.CURDIR} && ${TOOLDIR}/bin/${_TOOL_PREFIX}autoheader
159