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