Makefile revision 1.69
11.69Sapb#	$NetBSD: Makefile,v 1.69 2013/08/06 22:04:25 apb 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.40Schristos		${.CURDIR}/../../common/lib/libc/string \
521.46Smrg		${.CURDIR}/../../common/lib/libc/hash/rmd160 \
531.40Schristos		${.CURDIR}/../../common/lib/libc/hash/sha1 \
541.46Smrg		${.CURDIR}/../../common/lib/libc/hash/sha2 \
551.40Schristos		${.CURDIR}/../../common/lib/libc/md \
561.45Sthorpej		${.CURDIR}/../../common/lib/libc/stdlib \
571.69Sapb		${.CURDIR}/../../common/lib/libutil \
581.56Snjoly		${.CURDIR}/../../external/bsd/flex/dist
591.1Stv
601.6StvDPSRCS+=	defs.mk
611.43SchristosCLEANFILES+=	config.log config.status configure.lineno *.stamp
621.61SapbCLEANDIRFILES+=	defs.mk config.cache confdefs.h
631.3Stv
641.3Stv# Get components of Berkeley DB.
651.3Stv_CURDIR:=	${.CURDIR}
661.3Stv.CURDIR:=	${_CURDIR}/../../lib/libc
671.3Stv.include "${.CURDIR}/db/Makefile.inc"
681.3Stv.CURDIR:=	${_CURDIR}
691.3Stv
701.54SroySRCS:=		${SRCS:M*.c}
711.1Stv
721.42Swizconfig.cache: include/.stamp configure nbtool_config.h.in defs.mk.in
731.20Slukem	rm -f ${.TARGET}
741.3Stv	CC=${HOST_CC:Q} CFLAGS=${HOST_CFLAGS:Q} LDFLAGS=${HOST_LDFLAGS:Q} \
751.27Slukem		${HOST_SH} ${.CURDIR}/configure --cache-file=config.cache
761.20Slukem
771.20Slukemdefs.mk: config.cache
781.20Slukem	@touch ${.TARGET}
791.1Stv
801.61SapbINCFILES=	nbtool_config.h
811.66SchristosINCSUBDIRS=	sys machine rpc arpa
821.61SapbCLEANDIRFILES+= ${INCFILES}
831.61Sapb
841.61Sapb# CLEANDIRFILES may not contain directory names
851.61Sapbcleandir:	cleandir.include
861.61Sapbcleandir.include: .PHONY
871.61Sapb		rm -rf include
881.61Sapb
891.13Stvinclude/.stamp:
901.61Sapb	mkdir -p ${INCSUBDIRS:@d@ include/$d @}
911.20Slukem	@touch ${.TARGET}
921.6Stv
931.61Sapb# Install rules
941.61Sapb
951.61SapbHOST_LIBDIR=	${TOOLDIR}/lib
961.61SapbHOST_INCSDIR=	${TOOLDIR}/include
971.66SchristosHOST_SHAREDIR= ${TOOLDIR}/share
981.61Sapb
991.64Schristosinstall:	.PHONY install.lib includes install.defs.mk
1001.61Sapb
1011.61Sapb# Install lib${HOSTLIB}.a in ${TOOLDIR}/lib
1021.61Sapbinstall.lib: .PHONY ${HOST_LIBDIR}/lib${HOSTLIB}.a
1031.61Sapb${HOST_LIBDIR}/lib${HOSTLIB}.a: lib${HOSTLIB}.a
1041.61Sapb	${_MKTARGET_INSTALL}
1051.61Sapb	${HOST_INSTALL_DIR} ${HOST_LIBDIR}
1061.61Sapb	${HOST_INSTALL_FILE} -m ${LIBMODE} ${.ALLSRC} ${.TARGET}
1071.61Sapb
1081.64Schristos.for _f in ${INCFILES}
1091.64SchristosHOST_INCINSTFILES+= ${HOST_INCSDIR}/compat/${_f}
1101.64Schristos${HOST_INCSDIR}/compat/${_f}: ${_f}
1111.64Schristos	${_MKTARGET_INSTALL}
1121.64Schristos	${HOST_INSTALL_FILE} ${.ALLSRC} ${.TARGET}
1131.64Schristos.endfor
1141.64Schristos
1151.61Sapb.for _d in ${INCSUBDIRS}
1161.64SchristosHOST_INCINSTDIRS+= ${HOST_INCSDIR}/compat/${_d}
1171.64Schristos${HOST_INCSDIR}/compat/${_d}:
1181.64Schristos	${_MKTARGET_INSTALL}
1191.64Schristos	${HOST_INSTALL_DIR} ${.TARGET}
1201.61Sapb.endfor
1211.64Schristos
1221.64Schristos# Install include files in ${TOOLDIR}/include/compat
1231.64Schristosincludes: .PHONY ${HOST_INCINSTDIRS} .WAIT ${HOST_INCINSTFILES}
1241.66Schristos	@(cd include && find . -name '*.h' -print | while read f ; do \
1251.66Schristos	    ${HOST_INSTALL_FILE} $$f ${HOST_INCSDIR}/compat/$$f ; \
1261.66Schristos	done)
1271.66Schristos
1281.61Sapb
1291.61Sapb# Install defs.mk in ${TOOLDIR}/share/compat
1301.61Sapbinstall.defs.mk: .PHONY ${HOST_SHAREDIR}/compat/defs.mk
1311.61Sapb${HOST_SHAREDIR}/compat/defs.mk: defs.mk
1321.61Sapb	${_MKTARGET_INSTALL}
1331.61Sapb	${HOST_INSTALL_DIR} ${HOST_SHAREDIR}
1341.61Sapb	${HOST_INSTALL_DIR} ${HOST_SHAREDIR}/compat
1351.61Sapb	${HOST_INSTALL_FILE} ${.ALLSRC} ${.TARGET}
1361.61Sapb
1371.61Sapb# bsd.hostlib.mk wants HOST_CPPFLAGS, not CPPFLAGS
1381.6Stv
1391.6StvHOST_CPPFLAGS:=	${CPPFLAGS}
1401.6StvCPPFLAGS:=	# empty
1411.1Stv
1421.1Stv.include <bsd.hostlib.mk>
1431.60Sapb
1441.60Sapb# Use uninstalled copy of host-mkdep
1451.60SapbHOST_MKDEP_OBJ!= cd ${.CURDIR}/../host-mkdep && ${PRINTOBJDIR}
1461.60SapbHOST_MKDEP=	${HOST_MKDEP_OBJ}/host-mkdep
1471.60SapbMKDEP=		${HOST_MKDEP}
1481.60Sapb
1491.61Sapb# Use uninstalled copy of the install program
1501.61SapbINSTALL_OBJ!=	cd ${NETBSDSRCDIR}/tools/binstall && ${PRINTOBJDIR}
1511.61SapbINSTALL=	${INSTALL_OBJ}/xinstall
1521.61Sapb
1531.60Sapb# Run "${TOOLDIR}/bin/nbmake-${MACHINE} regen" by hand after editing
1541.60Sapb# configure.ac.  See more detailed instructions in configure.ac.
1551.60Sapbregen:
1561.60Sapb	cd ${.CURDIR} && ${TOOLDIR}/bin/${_TOOL_PREFIX}autoconf
1571.60Sapb	cd ${.CURDIR} && ${TOOLDIR}/bin/${_TOOL_PREFIX}autoheader
158