Makefile revision 1.71
1#	$NetBSD: Makefile,v 1.71 2014/01/09 11:31:12 apb Exp $
2
3HOSTLIB=	nbcompat
4
5.include <bsd.own.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 \
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 snprintb.c snprintf.c \
20		stat_flags.c strlcat.c strlcpy.c strmode.c \
21		strndup.c strnlen.c \
22		strsep.c strsuftoll.c strtoll.c \
23		unvis.c vis.c err.c errx.c verr.c verrx.c \
24		vwarn.c vwarnx.c warn.c warnx.c fts.c glob.c efun.c
25
26BUILD_OSTYPE!=  uname -s
27
28# Disable use of pre-compiled headers on Darwin.
29.if ${BUILD_OSTYPE} == "Darwin"
30CPPFLAGS+=	-no-cpp-precomp
31.endif
32
33# -D_FILE_OFFSET_BITS=64 produces a much more amenable `struct stat', and
34# other file ops, on many systems, without changing function names.
35
36CPPFLAGS+=	-I. -I./include -I${.CURDIR} -I${.CURDIR}/sys \
37		-DHAVE_NBTOOL_CONFIG_H=1 -D_FILE_OFFSET_BITS=64
38
39.PATH:		${.CURDIR}/../../lib/libc/cdb \
40		${.CURDIR}/../../lib/libc/gen \
41		${.CURDIR}/../../lib/libc/hash \
42		${.CURDIR}/../../lib/libc/hash/md2 \
43		${.CURDIR}/../../lib/libc/hash/md5 \
44		${.CURDIR}/../../lib/libc/hash/rmd160 \
45		${.CURDIR}/../../lib/libc/hash/sha1 \
46		${.CURDIR}/../../lib/libc/hash/sha2 \
47		${.CURDIR}/../../lib/libc/md \
48		${.CURDIR}/../../lib/libc/stdio \
49		${.CURDIR}/../../lib/libc/stdlib \
50		${.CURDIR}/../../lib/libc/string \
51		${.CURDIR}/../../lib/libutil \
52		${.CURDIR}/../../common/lib/libc/cdb \
53		${.CURDIR}/../../common/lib/libc/string \
54		${.CURDIR}/../../common/lib/libc/hash/rmd160 \
55		${.CURDIR}/../../common/lib/libc/hash/sha1 \
56		${.CURDIR}/../../common/lib/libc/hash/sha2 \
57		${.CURDIR}/../../common/lib/libc/md \
58		${.CURDIR}/../../common/lib/libc/stdlib \
59		${.CURDIR}/../../common/lib/libutil \
60		${.CURDIR}/../../external/bsd/flex/dist
61
62DPSRCS+=	defs.mk
63CLEANFILES+=	config.log config.status configure.lineno *.stamp
64CLEANDIRFILES+=	defs.mk config.cache confdefs.h
65
66# Get components of Berkeley DB.
67_CURDIR:=	${.CURDIR}
68.CURDIR:=	${_CURDIR}/../../lib/libc
69.include "${.CURDIR}/db/Makefile.inc"
70.CURDIR:=	${_CURDIR}
71
72SRCS:=		${SRCS:M*.c}
73
74config.cache: include/.stamp configure nbtool_config.h.in defs.mk.in
75	rm -f ${.TARGET}
76	CC=${HOST_CC:Q} CFLAGS=${HOST_CFLAGS:Q} LDFLAGS=${HOST_LDFLAGS:Q} \
77		${HOST_SH} ${.CURDIR}/configure --cache-file=config.cache
78
79defs.mk: config.cache
80	@touch ${.TARGET}
81
82INCFILES=	nbtool_config.h
83INCSUBDIRS=	sys machine rpc arpa
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 _d in ${INCSUBDIRS}
118HOST_INCINSTDIRS+= ${HOST_INCSDIR}/compat/${_d}
119${HOST_INCSDIR}/compat/${_d}:
120	${_MKTARGET_INSTALL}
121	${HOST_INSTALL_DIR} ${.TARGET}
122.endfor
123
124# Install include files in ${TOOLDIR}/include/compat
125includes: .PHONY ${HOST_INCINSTDIRS} .WAIT ${HOST_INCINSTFILES}
126	@(cd include && find . -name '*.h' -print | while read f ; do \
127	    ${HOST_INSTALL_FILE} $$f ${HOST_INCSDIR}/compat/$$f ; \
128	done)
129
130
131# Install defs.mk in ${TOOLDIR}/share/compat
132install.defs.mk: .PHONY ${HOST_SHAREDIR}/compat/defs.mk
133${HOST_SHAREDIR}/compat/defs.mk: defs.mk
134	${_MKTARGET_INSTALL}
135	${HOST_INSTALL_DIR} ${HOST_SHAREDIR}
136	${HOST_INSTALL_DIR} ${HOST_SHAREDIR}/compat
137	${HOST_INSTALL_FILE} ${.ALLSRC} ${.TARGET}
138
139# bsd.hostlib.mk wants HOST_CPPFLAGS, not CPPFLAGS
140
141HOST_CPPFLAGS:=	${CPPFLAGS}
142CPPFLAGS:=	# empty
143
144.include <bsd.hostlib.mk>
145
146# Use uninstalled copy of host-mkdep
147HOST_MKDEP_OBJ!= cd ${.CURDIR}/../host-mkdep && ${PRINTOBJDIR}
148HOST_MKDEP=	${HOST_MKDEP_OBJ}/host-mkdep
149MKDEP=		${HOST_MKDEP}
150
151# Use uninstalled copy of the install program
152INSTALL_OBJ!=	cd ${NETBSDSRCDIR}/tools/binstall && ${PRINTOBJDIR}
153INSTALL=	${INSTALL_OBJ}/xinstall
154
155# Run "${TOOLDIR}/bin/nbmake-${MACHINE} regen" by hand after editing
156# configure.ac.  See more detailed instructions in configure.ac.
157regen:
158	cd ${.CURDIR} && ${TOOLDIR}/bin/${_TOOL_PREFIX}autoconf
159	cd ${.CURDIR} && ${TOOLDIR}/bin/${_TOOL_PREFIX}autoheader
160