Makefile revision 1.88
11.88Slukem#	$NetBSD: Makefile,v 1.88 2020/06/13 10:49:17 lukem Exp $
21.67Schristos
31.67SchristosHOSTLIB=	nbcompat
41.63Schristos
51.83Schristos.include <bsd.hostinit.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.86Schristos		heapsort.c getsubopt.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.87Sthorpej		raise_default_signal.c rb.c reallocarr.c rmd160.c rmd160hl.c \
171.81Saymeric		regcomp.c regerror.c regexec.c regfree.c \
181.51Slukem		setenv.c setgroupent.c \
191.34Selad		setpassent.c setprogname.c sha1.c sha1hl.c sha2.c \
201.69Sapb		sha256hl.c sha384hl.c sha512hl.c snprintb.c snprintf.c \
211.71Sapb		stat_flags.c strlcat.c strlcpy.c strmode.c \
221.85Schristos		strcasecmp.c strncasecmp.c strndup.c strnlen.c \
231.69Sapb		strsep.c strsuftoll.c strtoll.c \
241.73Schristos		strtoi.c strtou.c \
251.72Schristos		unvis.c vis.c err.c errx.c errc.c verr.c verrx.c verrc.c \
261.72Schristos		vwarn.c vwarnx.c vwarnc.c warn.c warnx.c warnc.c \
271.72Schristos		fts.c glob.c efun.c
281.21Sthorpej
291.21SthorpejBUILD_OSTYPE!=  uname -s
301.21Sthorpej
311.21Sthorpej# Disable use of pre-compiled headers on Darwin.
321.21Sthorpej.if ${BUILD_OSTYPE} == "Darwin"
331.21SthorpejCPPFLAGS+=	-no-cpp-precomp
341.21Sthorpej.endif
351.6Stv
361.6Stv# -D_FILE_OFFSET_BITS=64 produces a much more amenable `struct stat', and
371.6Stv# other file ops, on many systems, without changing function names.
381.6Stv
391.47SdogcowCPPFLAGS+=	-I. -I./include -I${.CURDIR} -I${.CURDIR}/sys \
401.47Sdogcow		-DHAVE_NBTOOL_CONFIG_H=1 -D_FILE_OFFSET_BITS=64
411.3Stv
421.57Sjoerg.PATH:		${.CURDIR}/../../lib/libc/cdb \
431.57Sjoerg		${.CURDIR}/../../lib/libc/gen \
441.9Sbjh21		${.CURDIR}/../../lib/libc/hash \
451.39Selad		${.CURDIR}/../../lib/libc/hash/md2 \
461.38Selad		${.CURDIR}/../../lib/libc/hash/md5 \
471.38Selad		${.CURDIR}/../../lib/libc/hash/rmd160 \
481.38Selad		${.CURDIR}/../../lib/libc/hash/sha1 \
491.34Selad		${.CURDIR}/../../lib/libc/hash/sha2 \
501.9Sbjh21		${.CURDIR}/../../lib/libc/md \
511.81Saymeric		${.CURDIR}/../../lib/libc/regex \
521.15Sthorpej		${.CURDIR}/../../lib/libc/stdio \
531.6Stv		${.CURDIR}/../../lib/libc/stdlib \
541.4Slukem		${.CURDIR}/../../lib/libc/string \
551.44Schristos		${.CURDIR}/../../lib/libutil \
561.70Sjoerg		${.CURDIR}/../../common/lib/libc/cdb \
571.87Sthorpej		${.CURDIR}/../../common/lib/libc/gen \
581.40Schristos		${.CURDIR}/../../common/lib/libc/string \
591.46Smrg		${.CURDIR}/../../common/lib/libc/hash/rmd160 \
601.40Schristos		${.CURDIR}/../../common/lib/libc/hash/sha1 \
611.46Smrg		${.CURDIR}/../../common/lib/libc/hash/sha2 \
621.40Schristos		${.CURDIR}/../../common/lib/libc/md \
631.45Sthorpej		${.CURDIR}/../../common/lib/libc/stdlib \
641.69Sapb		${.CURDIR}/../../common/lib/libutil \
651.77Schristos		${.CURDIR}/../../external/bsd/flex/dist/src
661.1Stv
671.6StvDPSRCS+=	defs.mk
681.43SchristosCLEANFILES+=	config.log config.status configure.lineno *.stamp
691.61SapbCLEANDIRFILES+=	defs.mk config.cache confdefs.h
701.3Stv
711.3Stv# Get components of Berkeley DB.
721.3Stv_CURDIR:=	${.CURDIR}
731.3Stv.CURDIR:=	${_CURDIR}/../../lib/libc
741.3Stv.include "${.CURDIR}/db/Makefile.inc"
751.3Stv.CURDIR:=	${_CURDIR}
761.3Stv
771.54SroySRCS:=		${SRCS:M*.c}
781.1Stv
791.88SlukemCONFIGURE_ARGS=	--cache-file=config.cache
801.88Slukem.if ${MAKEVERBOSE} == 0
811.88SlukemCONFIGURE_ARGS+=--silent
821.88Slukem.endif
831.88Slukem
841.42Swizconfig.cache: include/.stamp configure nbtool_config.h.in defs.mk.in
851.20Slukem	rm -f ${.TARGET}
861.3Stv	CC=${HOST_CC:Q} CFLAGS=${HOST_CFLAGS:Q} LDFLAGS=${HOST_LDFLAGS:Q} \
871.88Slukem		${HOST_SH} ${.CURDIR}/configure ${CONFIGURE_ARGS}
881.20Slukem
891.20Slukemdefs.mk: config.cache
901.20Slukem	@touch ${.TARGET}
911.1Stv
921.61SapbINCFILES=	nbtool_config.h
931.66SchristosINCSUBDIRS=	sys machine rpc arpa
941.61SapbCLEANDIRFILES+= ${INCFILES}
951.61Sapb
961.61Sapb# CLEANDIRFILES may not contain directory names
971.61Sapbcleandir:	cleandir.include
981.61Sapbcleandir.include: .PHONY
991.61Sapb		rm -rf include
1001.61Sapb
1011.13Stvinclude/.stamp:
1021.61Sapb	mkdir -p ${INCSUBDIRS:@d@ include/$d @}
1031.20Slukem	@touch ${.TARGET}
1041.6Stv
1051.61Sapb# Install rules
1061.61Sapb
1071.61SapbHOST_LIBDIR=	${TOOLDIR}/lib
1081.61SapbHOST_INCSDIR=	${TOOLDIR}/include
1091.66SchristosHOST_SHAREDIR= ${TOOLDIR}/share
1101.61Sapb
1111.64Schristosinstall:	.PHONY install.lib includes install.defs.mk
1121.61Sapb
1131.61Sapb# Install lib${HOSTLIB}.a in ${TOOLDIR}/lib
1141.61Sapbinstall.lib: .PHONY ${HOST_LIBDIR}/lib${HOSTLIB}.a
1151.61Sapb${HOST_LIBDIR}/lib${HOSTLIB}.a: lib${HOSTLIB}.a
1161.61Sapb	${_MKTARGET_INSTALL}
1171.61Sapb	${HOST_INSTALL_DIR} ${HOST_LIBDIR}
1181.61Sapb	${HOST_INSTALL_FILE} -m ${LIBMODE} ${.ALLSRC} ${.TARGET}
1191.61Sapb
1201.64Schristos.for _f in ${INCFILES}
1211.64SchristosHOST_INCINSTFILES+= ${HOST_INCSDIR}/compat/${_f}
1221.64Schristos${HOST_INCSDIR}/compat/${_f}: ${_f}
1231.64Schristos	${_MKTARGET_INSTALL}
1241.64Schristos	${HOST_INSTALL_FILE} ${.ALLSRC} ${.TARGET}
1251.64Schristos.endfor
1261.64Schristos
1271.61Sapb.for _d in ${INCSUBDIRS}
1281.64SchristosHOST_INCINSTDIRS+= ${HOST_INCSDIR}/compat/${_d}
1291.64Schristos${HOST_INCSDIR}/compat/${_d}:
1301.64Schristos	${_MKTARGET_INSTALL}
1311.64Schristos	${HOST_INSTALL_DIR} ${.TARGET}
1321.61Sapb.endfor
1331.64Schristos
1341.64Schristos# Install include files in ${TOOLDIR}/include/compat
1351.64Schristosincludes: .PHONY ${HOST_INCINSTDIRS} .WAIT ${HOST_INCINSTFILES}
1361.76Schristos	@(cd include && find . -name '*.h' -print | while read f ; do \
1371.66Schristos	    ${HOST_INSTALL_FILE} $$f ${HOST_INCSDIR}/compat/$$f ; \
1381.66Schristos	done)
1391.66Schristos
1401.61Sapb
1411.61Sapb# Install defs.mk in ${TOOLDIR}/share/compat
1421.61Sapbinstall.defs.mk: .PHONY ${HOST_SHAREDIR}/compat/defs.mk
1431.61Sapb${HOST_SHAREDIR}/compat/defs.mk: defs.mk
1441.61Sapb	${_MKTARGET_INSTALL}
1451.61Sapb	${HOST_INSTALL_DIR} ${HOST_SHAREDIR}
1461.61Sapb	${HOST_INSTALL_DIR} ${HOST_SHAREDIR}/compat
1471.61Sapb	${HOST_INSTALL_FILE} ${.ALLSRC} ${.TARGET}
1481.61Sapb
1491.61Sapb# bsd.hostlib.mk wants HOST_CPPFLAGS, not CPPFLAGS
1501.6Stv
1511.6StvHOST_CPPFLAGS:=	${CPPFLAGS}
1521.6StvCPPFLAGS:=	# empty
1531.1Stv
1541.1Stv.include <bsd.hostlib.mk>
1551.60Sapb
1561.60Sapb# Use uninstalled copy of host-mkdep
1571.60SapbHOST_MKDEP_OBJ!= cd ${.CURDIR}/../host-mkdep && ${PRINTOBJDIR}
1581.60SapbHOST_MKDEP=	${HOST_MKDEP_OBJ}/host-mkdep
1591.60SapbMKDEP=		${HOST_MKDEP}
1601.60Sapb
1611.61Sapb# Use uninstalled copy of the install program
1621.61SapbINSTALL_OBJ!=	cd ${NETBSDSRCDIR}/tools/binstall && ${PRINTOBJDIR}
1631.61SapbINSTALL=	${INSTALL_OBJ}/xinstall
1641.61Sapb
1651.60Sapb# Run "${TOOLDIR}/bin/nbmake-${MACHINE} regen" by hand after editing
1661.60Sapb# configure.ac.  See more detailed instructions in configure.ac.
1671.60Sapbregen:
1681.60Sapb	cd ${.CURDIR} && ${TOOLDIR}/bin/${_TOOL_PREFIX}autoconf
1691.60Sapb	cd ${.CURDIR} && ${TOOLDIR}/bin/${_TOOL_PREFIX}autoheader
170