1 #################################################################
5 # A number of Make variables are used to generate the crunchgen config file.
7 # CRUNCH_SRCDIRS: lists directories to search for included programs
8 # CRUNCH_PROGS: lists programs to be included
9 # CRUNCH_LIBS: libraries to statically link with
10 # CRUNCH_SHLIBS: libraries to dynamically link with
11 # CRUNCH_BUILDOPTS: generic build options to be added to every program
12 # CRUNCH_BUILDTOOLS: lists programs that need build tools built in the
15 # Special options can be specified for individual programs
16 # CRUNCH_SRCDIR_$(P): base source directory for program $(P)
17 # CRUNCH_BUILDOPTS_$(P): additional build options for $(P)
18 # CRUNCH_ALIAS_$(P): additional names to be used for $(P)
20 # By default, any name appearing in CRUNCH_PROGS or CRUNCH_ALIAS_${P}
21 # will be used to generate a hard link to the resulting binary.
22 # Specific links can be suppressed by setting
23 # CRUNCH_SUPPRESS_LINK_$(NAME) to 1.
28 ##################################################################
29 # The following is pretty nearly a generic crunchgen-handling makefile
35 OUTPUTS=$(OUTMK) $(OUTC) $(PROG).cache
36 CRUNCHOBJS= ${.OBJDIR}
37 .if defined(MAKEOBJDIRPREFIX)
38 CANONICALOBJDIR:= ${MAKEOBJDIRPREFIX}${.CURDIR}
39 .elif defined(MAKEOBJDIR) && ${MAKEOBJDIR:M/*} != ""
40 CANONICALOBJDIR:=${MAKEOBJDIR}
42 CANONICALOBJDIR:= /usr/obj${.CURDIR}
45 CLEANFILES+= $(CONF) *.o *.lo *.c *.mk *.cache *.a *.h
47 # Program names and their aliases contribute hardlinks to 'rescue' executable,
48 # except for those that get suppressed.
49 .for D in $(CRUNCH_SRCDIRS)
50 .for P in $(CRUNCH_PROGS_$(D))
51 .ifdef CRUNCH_SRCDIR_${P}
52 $(OUTPUTS): $(CRUNCH_SRCDIR_${P})/Makefile
54 $(OUTPUTS): $(.CURDIR)/../../$(D)/$(P)/Makefile
56 .ifndef CRUNCH_SUPPRESS_LINK_${P}
57 LINKS+= $(BINDIR)/$(PROG) $(BINDIR)/$(P)
59 .for A in $(CRUNCH_ALIAS_$(P))
60 .ifndef CRUNCH_SUPPRESS_LINK_${A}
61 LINKS+= $(BINDIR)/$(PROG) $(BINDIR)/$(A)
71 echo \# Auto-generated, do not edit >$(.TARGET)
72 .ifdef CRUNCH_BUILDOPTS
73 echo buildopts $(CRUNCH_BUILDOPTS) >>$(.TARGET)
76 echo libs $(CRUNCH_LIBS) >>$(.TARGET)
79 echo libs_so $(CRUNCH_SHLIBS) >>$(.TARGET)
81 .for D in $(CRUNCH_SRCDIRS)
82 .for P in $(CRUNCH_PROGS_$(D))
83 echo progs $(P) >>$(.TARGET)
84 .ifdef CRUNCH_SRCDIR_${P}
85 echo special $(P) srcdir $(CRUNCH_SRCDIR_${P}) >>$(.TARGET)
87 echo special $(P) srcdir $(.CURDIR)/../../$(D)/$(P) >>$(.TARGET)
89 .ifdef CRUNCH_BUILDOPTS_${P}
90 echo special $(P) buildopts DIRPRFX=${DIRPRFX}${P}/ \
91 $(CRUNCH_BUILDOPTS_${P}) >>$(.TARGET)
93 echo special $(P) buildopts DIRPRFX=${DIRPRFX}${P}/ >>$(.TARGET)
95 .for A in $(CRUNCH_ALIAS_$(P))
96 echo ln $(P) $(A) >>$(.TARGET)
101 # XXX Make sure we don't pass -P to crunchgen(1).
102 .MAKEFLAGS:= ${.MAKEFLAGS:N-P}
103 .ORDER: $(OUTPUTS) objs
105 MAKE=${MAKE} MAKEOBJDIRPREFIX=${CRUNCHOBJS} crunchgen -fq -m $(OUTMK) \
108 $(PROG): $(OUTPUTS) objs
109 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) exe
112 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) objs
114 # <sigh> Someone should replace the bin/csh and bin/sh build-tools with
115 # shell scripts so we can remove this nonsense.
117 .for _tool in $(CRUNCH_BUILDTOOLS)
118 cd $(.CURDIR)/../../${_tool}; \
119 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} obj; \
120 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} build-tools
123 # Use a separate build tree to hold files compiled for this crunchgen binary
124 # Yes, this does seem to partly duplicate bsd.subdir.mk, but I can't
125 # get that to cooperate with bsd.prog.mk. Besides, many of the standard
126 # targets should NOT be propagated into the components.
127 cleandepend cleandir obj objlink:
128 .for D in $(CRUNCH_SRCDIRS)
129 .for P in $(CRUNCH_PROGS_$(D))
130 .ifdef CRUNCH_SRCDIR_${P}
131 cd ${CRUNCH_SRCDIR_$(P)} && \
132 MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
133 DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}
135 cd $(.CURDIR)/../../${D}/${P} && \
136 MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
137 DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}
144 if [ -e ${.OBJDIR}/$(OUTMK) ]; then \
145 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) clean; \
147 .for D in $(CRUNCH_SRCDIRS)
148 .for P in $(CRUNCH_PROGS_$(D))
149 .ifdef CRUNCH_SRCDIR_${P}
150 cd ${CRUNCH_SRCDIR_$(P)} && \
151 MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
152 DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}
154 cd $(.CURDIR)/../../${D}/${P} && \
155 MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
156 DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}