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