NetBSD/share/mk/bsd.hostlib.mk

60 lines
1.3 KiB
Makefile

# $NetBSD: bsd.hostlib.mk,v 1.13 2004/01/29 01:48:45 lukem Exp $
.include <bsd.init.mk>
.include <bsd.sys.mk>
##### Basic targets
clean: cleanlib
##### Default values
CFLAGS+= ${COPTS}
HOST_MKDEP?= CC=${HOST_CC:Q} mkdep
MKDEP_SUFFIXES?= .o .lo
# Override these:
MKDEP:= ${HOST_MKDEP}
.if ${TOOLCHAIN_MISSING} == "no" || defined(EXTERNAL_TOOLCHAIN)
OBJHOSTMACHINE= # set
.endif
##### Build rules
.if defined(HOSTLIB)
DPSRCS+= ${SRCS:M*.l:.l=.c} ${SRCS:M*.y:.y=.c}
CLEANFILES+= ${SRCS:M*.l:.l=.c} ${SRCS:M*.y:.y=.c}
CLEANFILES+= ${YHEADER:D${SRCS:M*.y:.y=.h}}
.endif # defined(HOSTLIB)
.if !empty(SRCS:N*.h:N*.sh)
OBJS+= ${SRCS:N*.h:N*.sh:R:S/$/.lo/g}
.endif
.if defined(OBJS) && !empty(OBJS)
.NOPATH: ${OBJS} ${HOSTPROG} ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}}
${OBJS}: ${DPSRCS}
lib${HOSTLIB}.a: ${OBJS} ${DPADD}
${_MKTARGET_BUILD}
rm -f ${.TARGET}
${HOST_AR} cq ${.TARGET} ${OBJS}
${HOST_RANLIB} ${.TARGET}
.endif # defined(OBJS) && !empty(OBJS)
realall: lib${HOSTLIB}.a
cleanlib: .PHONY
rm -f a.out [Ee]rrs mklog core *.core \
lib${HOSTLIB}.a ${OBJS} ${CLEANFILES}
beforedepend:
CFLAGS:= ${HOST_CFLAGS}
CPPFLAGS:= ${HOST_CPPFLAGS}
##### Pull in related .mk logic
.include <bsd.obj.mk>
.include <bsd.dep.mk>
${TARGETS}: # ensure existence