2010-11-13 03:11:27 +00:00
|
|
|
#################################################################
|
|
|
|
#
|
|
|
|
# General notes:
|
|
|
|
#
|
|
|
|
# A number of Make variables are used to generate the crunchgen config file.
|
|
|
|
#
|
|
|
|
# CRUNCH_SRCDIRS: lists directories to search for included programs
|
|
|
|
# CRUNCH_PROGS: lists programs to be included
|
|
|
|
# CRUNCH_LIBS: libraries to statically link with
|
|
|
|
# CRUNCH_SHLIBS: libraries to dynamically link with
|
|
|
|
# CRUNCH_BUILDOPTS: generic build options to be added to every program
|
|
|
|
# CRUNCH_BUILDTOOLS: lists programs that need build tools built in the
|
|
|
|
# local architecture.
|
|
|
|
#
|
|
|
|
# Special options can be specified for individual programs
|
|
|
|
# CRUNCH_SRCDIR_$(P): base source directory for program $(P)
|
|
|
|
# CRUNCH_BUILDOPTS_$(P): additional build options for $(P)
|
|
|
|
# CRUNCH_ALIAS_$(P): additional names to be used for $(P)
|
|
|
|
#
|
|
|
|
# By default, any name appearing in CRUNCH_PROGS or CRUNCH_ALIAS_${P}
|
|
|
|
# will be used to generate a hard link to the resulting binary.
|
|
|
|
# Specific links can be suppressed by setting
|
|
|
|
# CRUNCH_SUPPRESS_LINK_$(NAME) to 1.
|
|
|
|
#
|
2012-01-05 21:49:43 +00:00
|
|
|
# If CRUNCH_GENERATE_LINKS is set to no, no links will be generated.
|
|
|
|
#
|
2010-11-13 03:11:27 +00:00
|
|
|
|
|
|
|
# $FreeBSD$
|
|
|
|
|
|
|
|
##################################################################
|
|
|
|
# The following is pretty nearly a generic crunchgen-handling makefile
|
|
|
|
#
|
|
|
|
|
|
|
|
CONF= $(PROG).conf
|
|
|
|
OUTMK= $(PROG).mk
|
|
|
|
OUTC= $(PROG).c
|
|
|
|
OUTPUTS=$(OUTMK) $(OUTC) $(PROG).cache
|
|
|
|
CRUNCHOBJS= ${.OBJDIR}
|
|
|
|
.if defined(MAKEOBJDIRPREFIX)
|
|
|
|
CANONICALOBJDIR:= ${MAKEOBJDIRPREFIX}${.CURDIR}
|
2012-10-06 20:01:05 +00:00
|
|
|
.elif defined(MAKEOBJDIR) && ${MAKEOBJDIR:M/*} != ""
|
|
|
|
CANONICALOBJDIR:=${MAKEOBJDIR}
|
2010-11-13 03:11:27 +00:00
|
|
|
.else
|
|
|
|
CANONICALOBJDIR:= /usr/obj${.CURDIR}
|
|
|
|
.endif
|
2012-01-05 21:49:43 +00:00
|
|
|
CRUNCH_GENERATE_LINKS?= yes
|
2010-11-13 03:11:27 +00:00
|
|
|
|
|
|
|
CLEANFILES+= $(CONF) *.o *.lo *.c *.mk *.cache *.a *.h
|
|
|
|
|
2013-06-07 21:40:02 +00:00
|
|
|
# Don't try to extract debug info from ${PROG}.
|
2014-04-25 19:25:18 +00:00
|
|
|
MK_DEBUG_FILES=no
|
2013-06-07 21:40:02 +00:00
|
|
|
|
2010-11-13 03:11:27 +00:00
|
|
|
# Program names and their aliases contribute hardlinks to 'rescue' executable,
|
|
|
|
# except for those that get suppressed.
|
|
|
|
.for D in $(CRUNCH_SRCDIRS)
|
|
|
|
.for P in $(CRUNCH_PROGS_$(D))
|
|
|
|
.ifdef CRUNCH_SRCDIR_${P}
|
|
|
|
$(OUTPUTS): $(CRUNCH_SRCDIR_${P})/Makefile
|
|
|
|
.else
|
|
|
|
$(OUTPUTS): $(.CURDIR)/../../$(D)/$(P)/Makefile
|
|
|
|
.endif
|
2012-01-05 21:49:43 +00:00
|
|
|
.if ${CRUNCH_GENERATE_LINKS} == "yes"
|
2010-11-16 22:23:20 +00:00
|
|
|
.ifndef CRUNCH_SUPPRESS_LINK_${P}
|
|
|
|
LINKS+= $(BINDIR)/$(PROG) $(BINDIR)/$(P)
|
|
|
|
.endif
|
|
|
|
.for A in $(CRUNCH_ALIAS_$(P))
|
|
|
|
.ifndef CRUNCH_SUPPRESS_LINK_${A}
|
|
|
|
LINKS+= $(BINDIR)/$(PROG) $(BINDIR)/$(A)
|
|
|
|
.endif
|
|
|
|
.endfor
|
2012-01-05 21:49:43 +00:00
|
|
|
.endif
|
2010-11-13 03:11:27 +00:00
|
|
|
.endfor
|
|
|
|
.endfor
|
|
|
|
|
|
|
|
all: $(PROG)
|
|
|
|
exe: $(PROG)
|
|
|
|
|
|
|
|
$(CONF): Makefile
|
|
|
|
echo \# Auto-generated, do not edit >$(.TARGET)
|
|
|
|
.ifdef CRUNCH_BUILDOPTS
|
|
|
|
echo buildopts $(CRUNCH_BUILDOPTS) >>$(.TARGET)
|
|
|
|
.endif
|
|
|
|
.ifdef CRUNCH_LIBS
|
|
|
|
echo libs $(CRUNCH_LIBS) >>$(.TARGET)
|
|
|
|
.endif
|
|
|
|
.ifdef CRUNCH_SHLIBS
|
|
|
|
echo libs_so $(CRUNCH_SHLIBS) >>$(.TARGET)
|
|
|
|
.endif
|
|
|
|
.for D in $(CRUNCH_SRCDIRS)
|
|
|
|
.for P in $(CRUNCH_PROGS_$(D))
|
|
|
|
echo progs $(P) >>$(.TARGET)
|
|
|
|
.ifdef CRUNCH_SRCDIR_${P}
|
|
|
|
echo special $(P) srcdir $(CRUNCH_SRCDIR_${P}) >>$(.TARGET)
|
|
|
|
.else
|
|
|
|
echo special $(P) srcdir $(.CURDIR)/../../$(D)/$(P) >>$(.TARGET)
|
|
|
|
.endif
|
|
|
|
.ifdef CRUNCH_BUILDOPTS_${P}
|
|
|
|
echo special $(P) buildopts DIRPRFX=${DIRPRFX}${P}/ \
|
|
|
|
$(CRUNCH_BUILDOPTS_${P}) >>$(.TARGET)
|
|
|
|
.else
|
|
|
|
echo special $(P) buildopts DIRPRFX=${DIRPRFX}${P}/ >>$(.TARGET)
|
|
|
|
.endif
|
|
|
|
.for A in $(CRUNCH_ALIAS_$(P))
|
|
|
|
echo ln $(P) $(A) >>$(.TARGET)
|
|
|
|
.endfor
|
|
|
|
.endfor
|
|
|
|
.endfor
|
|
|
|
|
2015-06-13 15:36:13 +00:00
|
|
|
CRUNCHGEN?= crunchgen
|
2015-10-22 04:28:22 +00:00
|
|
|
CRUNCHENV?= MK_TESTS=no
|
2010-11-13 03:11:27 +00:00
|
|
|
.ORDER: $(OUTPUTS) objs
|
2015-06-13 15:36:13 +00:00
|
|
|
$(OUTPUTS): $(CONF) .META
|
|
|
|
MAKE=${MAKE} MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${CRUNCHGEN} -fq -m $(OUTMK) \
|
2010-11-13 03:11:27 +00:00
|
|
|
-c $(OUTC) $(CONF)
|
|
|
|
|
2015-10-22 04:28:22 +00:00
|
|
|
# These 2 targets cannot use .MAKE since they depend on the generated
|
|
|
|
# ${OUTMK} above.
|
2010-11-13 03:11:27 +00:00
|
|
|
$(PROG): $(OUTPUTS) objs
|
2015-10-22 04:28:22 +00:00
|
|
|
${CRUNCHENV} MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) exe
|
2010-11-13 03:11:27 +00:00
|
|
|
|
|
|
|
objs: $(OUTMK)
|
2015-10-22 04:28:22 +00:00
|
|
|
${CRUNCHENV} MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) objs
|
2010-11-13 03:11:27 +00:00
|
|
|
|
|
|
|
# <sigh> Someone should replace the bin/csh and bin/sh build-tools with
|
|
|
|
# shell scripts so we can remove this nonsense.
|
|
|
|
build-tools:
|
|
|
|
.for _tool in $(CRUNCH_BUILDTOOLS)
|
2015-10-22 04:28:22 +00:00
|
|
|
${_+_}cd $(.CURDIR)/../../${_tool}; \
|
|
|
|
${CRUNCHENV} MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} obj; \
|
|
|
|
${CRUNCHENV} MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} build-tools
|
2010-11-13 03:11:27 +00:00
|
|
|
.endfor
|
|
|
|
|
|
|
|
# Use a separate build tree to hold files compiled for this crunchgen binary
|
|
|
|
# Yes, this does seem to partly duplicate bsd.subdir.mk, but I can't
|
|
|
|
# get that to cooperate with bsd.prog.mk. Besides, many of the standard
|
|
|
|
# targets should NOT be propagated into the components.
|
|
|
|
cleandepend cleandir obj objlink:
|
|
|
|
.for D in $(CRUNCH_SRCDIRS)
|
|
|
|
.for P in $(CRUNCH_PROGS_$(D))
|
|
|
|
.ifdef CRUNCH_SRCDIR_${P}
|
2015-10-22 04:28:22 +00:00
|
|
|
${_+_}cd ${CRUNCH_SRCDIR_$(P)} && \
|
|
|
|
${CRUNCHENV} MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
|
2010-11-13 03:11:27 +00:00
|
|
|
DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}
|
|
|
|
.else
|
2015-10-22 04:28:22 +00:00
|
|
|
${_+_}cd $(.CURDIR)/../../${D}/${P} && \
|
|
|
|
${CRUNCHENV} MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
|
2010-11-13 03:11:27 +00:00
|
|
|
DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}
|
|
|
|
.endif
|
|
|
|
.endfor
|
|
|
|
.endfor
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -f ${CLEANFILES}
|
2015-10-22 04:28:22 +00:00
|
|
|
${_+_}if [ -e ${.OBJDIR}/$(OUTMK) ]; then \
|
|
|
|
${CRUNCHENV} MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) clean; \
|
2010-11-13 03:11:27 +00:00
|
|
|
fi
|
|
|
|
.for D in $(CRUNCH_SRCDIRS)
|
|
|
|
.for P in $(CRUNCH_PROGS_$(D))
|
|
|
|
.ifdef CRUNCH_SRCDIR_${P}
|
2015-10-22 04:28:22 +00:00
|
|
|
${_+_}cd ${CRUNCH_SRCDIR_$(P)} && \
|
|
|
|
${CRUNCHENV} MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
|
2010-11-13 03:11:27 +00:00
|
|
|
DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}
|
|
|
|
.else
|
2015-10-22 04:28:22 +00:00
|
|
|
${_+_}cd $(.CURDIR)/../../${D}/${P} && \
|
|
|
|
${CRUNCHENV} MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
|
2010-11-13 03:11:27 +00:00
|
|
|
DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}
|
|
|
|
.endif
|
|
|
|
.endfor
|
|
|
|
.endfor
|