Makefile revision 1.88
1#	$NetBSD: Makefile,v 1.88 2020/06/13 10:49:17 lukem Exp $
2
3HOSTLIB=	nbcompat
4
5.include <bsd.hostinit.mk>
6
7SRCS=		atoll.c basename.c cdbr.c cdbw.c dirname.c \
8		dprintf.c fgetln.c flock.c fparseln.c fpurge.c \
9		getcap.c getline.c getmode.c getopt_long.c gettemp.c \
10		heapsort.c getsubopt.c \
11		issetugid.c lchflags.c lchmod.c lchown.c libyywrap.c \
12		md2.c md2hl.c md4c.c md4hl.c md5c.c md5hl.c \
13		mi_vector_hash.c mkdtemp.c \
14		mkstemp.c pread.c putc_unlocked.c pwcache.c pwrite.c \
15		pw_scan.c \
16		raise_default_signal.c rb.c reallocarr.c rmd160.c rmd160hl.c \
17		regcomp.c regerror.c regexec.c regfree.c \
18		setenv.c setgroupent.c \
19		setpassent.c setprogname.c sha1.c sha1hl.c sha2.c \
20		sha256hl.c sha384hl.c sha512hl.c snprintb.c snprintf.c \
21		stat_flags.c strlcat.c strlcpy.c strmode.c \
22		strcasecmp.c strncasecmp.c strndup.c strnlen.c \
23		strsep.c strsuftoll.c strtoll.c \
24		strtoi.c strtou.c \
25		unvis.c vis.c err.c errx.c errc.c verr.c verrx.c verrc.c \
26		vwarn.c vwarnx.c vwarnc.c warn.c warnx.c warnc.c \
27		fts.c glob.c efun.c
28
29BUILD_OSTYPE!=  uname -s
30
31# Disable use of pre-compiled headers on Darwin.
32.if ${BUILD_OSTYPE} == "Darwin"
33CPPFLAGS+=	-no-cpp-precomp
34.endif
35
36# -D_FILE_OFFSET_BITS=64 produces a much more amenable `struct stat', and
37# other file ops, on many systems, without changing function names.
38
39CPPFLAGS+=	-I. -I./include -I${.CURDIR} -I${.CURDIR}/sys \
40		-DHAVE_NBTOOL_CONFIG_H=1 -D_FILE_OFFSET_BITS=64
41
42.PATH:		${.CURDIR}/../../lib/libc/cdb \
43		${.CURDIR}/../../lib/libc/gen \
44		${.CURDIR}/../../lib/libc/hash \
45		${.CURDIR}/../../lib/libc/hash/md2 \
46		${.CURDIR}/../../lib/libc/hash/md5 \
47		${.CURDIR}/../../lib/libc/hash/rmd160 \
48		${.CURDIR}/../../lib/libc/hash/sha1 \
49		${.CURDIR}/../../lib/libc/hash/sha2 \
50		${.CURDIR}/../../lib/libc/md \
51		${.CURDIR}/../../lib/libc/regex \
52		${.CURDIR}/../../lib/libc/stdio \
53		${.CURDIR}/../../lib/libc/stdlib \
54		${.CURDIR}/../../lib/libc/string \
55		${.CURDIR}/../../lib/libutil \
56		${.CURDIR}/../../common/lib/libc/cdb \
57		${.CURDIR}/../../common/lib/libc/gen \
58		${.CURDIR}/../../common/lib/libc/string \
59		${.CURDIR}/../../common/lib/libc/hash/rmd160 \
60		${.CURDIR}/../../common/lib/libc/hash/sha1 \
61		${.CURDIR}/../../common/lib/libc/hash/sha2 \
62		${.CURDIR}/../../common/lib/libc/md \
63		${.CURDIR}/../../common/lib/libc/stdlib \
64		${.CURDIR}/../../common/lib/libutil \
65		${.CURDIR}/../../external/bsd/flex/dist/src
66
67DPSRCS+=	defs.mk
68CLEANFILES+=	config.log config.status configure.lineno *.stamp
69CLEANDIRFILES+=	defs.mk config.cache confdefs.h
70
71# Get components of Berkeley DB.
72_CURDIR:=	${.CURDIR}
73.CURDIR:=	${_CURDIR}/../../lib/libc
74.include "${.CURDIR}/db/Makefile.inc"
75.CURDIR:=	${_CURDIR}
76
77SRCS:=		${SRCS:M*.c}
78
79CONFIGURE_ARGS=	--cache-file=config.cache
80.if ${MAKEVERBOSE} == 0
81CONFIGURE_ARGS+=--silent
82.endif
83
84config.cache: include/.stamp configure nbtool_config.h.in defs.mk.in
85	rm -f ${.TARGET}
86	CC=${HOST_CC:Q} CFLAGS=${HOST_CFLAGS:Q} LDFLAGS=${HOST_LDFLAGS:Q} \
87		${HOST_SH} ${.CURDIR}/configure ${CONFIGURE_ARGS}
88
89defs.mk: config.cache
90	@touch ${.TARGET}
91
92INCFILES=	nbtool_config.h
93INCSUBDIRS=	sys machine rpc arpa
94CLEANDIRFILES+= ${INCFILES}
95
96# CLEANDIRFILES may not contain directory names
97cleandir:	cleandir.include
98cleandir.include: .PHONY
99		rm -rf include
100
101include/.stamp:
102	mkdir -p ${INCSUBDIRS:@d@ include/$d @}
103	@touch ${.TARGET}
104
105# Install rules
106
107HOST_LIBDIR=	${TOOLDIR}/lib
108HOST_INCSDIR=	${TOOLDIR}/include
109HOST_SHAREDIR= ${TOOLDIR}/share
110
111install:	.PHONY install.lib includes install.defs.mk
112
113# Install lib${HOSTLIB}.a in ${TOOLDIR}/lib
114install.lib: .PHONY ${HOST_LIBDIR}/lib${HOSTLIB}.a
115${HOST_LIBDIR}/lib${HOSTLIB}.a: lib${HOSTLIB}.a
116	${_MKTARGET_INSTALL}
117	${HOST_INSTALL_DIR} ${HOST_LIBDIR}
118	${HOST_INSTALL_FILE} -m ${LIBMODE} ${.ALLSRC} ${.TARGET}
119
120.for _f in ${INCFILES}
121HOST_INCINSTFILES+= ${HOST_INCSDIR}/compat/${_f}
122${HOST_INCSDIR}/compat/${_f}: ${_f}
123	${_MKTARGET_INSTALL}
124	${HOST_INSTALL_FILE} ${.ALLSRC} ${.TARGET}
125.endfor
126
127.for _d in ${INCSUBDIRS}
128HOST_INCINSTDIRS+= ${HOST_INCSDIR}/compat/${_d}
129${HOST_INCSDIR}/compat/${_d}:
130	${_MKTARGET_INSTALL}
131	${HOST_INSTALL_DIR} ${.TARGET}
132.endfor
133
134# Install include files in ${TOOLDIR}/include/compat
135includes: .PHONY ${HOST_INCINSTDIRS} .WAIT ${HOST_INCINSTFILES}
136	@(cd include && find . -name '*.h' -print | while read f ; do \
137	    ${HOST_INSTALL_FILE} $$f ${HOST_INCSDIR}/compat/$$f ; \
138	done)
139
140
141# Install defs.mk in ${TOOLDIR}/share/compat
142install.defs.mk: .PHONY ${HOST_SHAREDIR}/compat/defs.mk
143${HOST_SHAREDIR}/compat/defs.mk: defs.mk
144	${_MKTARGET_INSTALL}
145	${HOST_INSTALL_DIR} ${HOST_SHAREDIR}
146	${HOST_INSTALL_DIR} ${HOST_SHAREDIR}/compat
147	${HOST_INSTALL_FILE} ${.ALLSRC} ${.TARGET}
148
149# bsd.hostlib.mk wants HOST_CPPFLAGS, not CPPFLAGS
150
151HOST_CPPFLAGS:=	${CPPFLAGS}
152CPPFLAGS:=	# empty
153
154.include <bsd.hostlib.mk>
155
156# Use uninstalled copy of host-mkdep
157HOST_MKDEP_OBJ!= cd ${.CURDIR}/../host-mkdep && ${PRINTOBJDIR}
158HOST_MKDEP=	${HOST_MKDEP_OBJ}/host-mkdep
159MKDEP=		${HOST_MKDEP}
160
161# Use uninstalled copy of the install program
162INSTALL_OBJ!=	cd ${NETBSDSRCDIR}/tools/binstall && ${PRINTOBJDIR}
163INSTALL=	${INSTALL_OBJ}/xinstall
164
165# Run "${TOOLDIR}/bin/nbmake-${MACHINE} regen" by hand after editing
166# configure.ac.  See more detailed instructions in configure.ac.
167regen:
168	cd ${.CURDIR} && ${TOOLDIR}/bin/${_TOOL_PREFIX}autoconf
169	cd ${.CURDIR} && ${TOOLDIR}/bin/${_TOOL_PREFIX}autoheader
170