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 # Don't try to extract debug info from ${PROG}.
50 # Program names and their aliases contribute hardlinks to 'rescue' executable,
51 # except for those that get suppressed.
52 .for D in $(CRUNCH_SRCDIRS)
53 .for P in $(CRUNCH_PROGS_$(D))
54 .ifdef CRUNCH_SRCDIR_${P}
55 $(OUTPUTS): $(CRUNCH_SRCDIR_${P})/Makefile
57 $(OUTPUTS): $(.CURDIR)/../../$(D)/$(P)/Makefile
59 .ifndef CRUNCH_SUPPRESS_LINK_${P}
60 LINKS+= $(BINDIR)/$(PROG) $(BINDIR)/$(P)
62 .for A in $(CRUNCH_ALIAS_$(P))
63 .ifndef CRUNCH_SUPPRESS_LINK_${A}
64 LINKS+= $(BINDIR)/$(PROG) $(BINDIR)/$(A)
74 echo \# Auto-generated, do not edit >$(.TARGET)
75 .ifdef CRUNCH_BUILDOPTS
76 echo buildopts $(CRUNCH_BUILDOPTS) >>$(.TARGET)
79 echo libs $(CRUNCH_LIBS) >>$(.TARGET)
82 echo libs_so $(CRUNCH_SHLIBS) >>$(.TARGET)
84 .for D in $(CRUNCH_SRCDIRS)
85 .for P in $(CRUNCH_PROGS_$(D))
86 echo progs $(P) >>$(.TARGET)
87 .ifdef CRUNCH_SRCDIR_${P}
88 echo special $(P) srcdir $(CRUNCH_SRCDIR_${P}) >>$(.TARGET)
90 echo special $(P) srcdir $(.CURDIR)/../../$(D)/$(P) >>$(.TARGET)
92 .ifdef CRUNCH_BUILDOPTS_${P}
93 echo special $(P) buildopts DIRPRFX=${DIRPRFX}${P}/ \
94 $(CRUNCH_BUILDOPTS_${P}) >>$(.TARGET)
96 echo special $(P) buildopts DIRPRFX=${DIRPRFX}${P}/ >>$(.TARGET)
98 .for A in $(CRUNCH_ALIAS_$(P))
99 echo ln $(P) $(A) >>$(.TARGET)
104 # XXX Make sure we don't pass -P to crunchgen(1).
105 .MAKEFLAGS:= ${.MAKEFLAGS:N-P}
106 .ORDER: $(OUTPUTS) objs
108 MAKE=${MAKE} MAKEOBJDIRPREFIX=${CRUNCHOBJS} crunchgen -fq -m $(OUTMK) \
111 $(PROG): $(OUTPUTS) objs
112 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) exe
115 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) objs
117 # <sigh> Someone should replace the bin/csh and bin/sh build-tools with
118 # shell scripts so we can remove this nonsense.
120 .for _tool in $(CRUNCH_BUILDTOOLS)
121 cd $(.CURDIR)/../../${_tool}; \
122 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} obj; \
123 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} build-tools
126 # Use a separate build tree to hold files compiled for this crunchgen binary
127 # Yes, this does seem to partly duplicate bsd.subdir.mk, but I can't
128 # get that to cooperate with bsd.prog.mk. Besides, many of the standard
129 # targets should NOT be propagated into the components.
130 cleandepend cleandir obj objlink:
131 .for D in $(CRUNCH_SRCDIRS)
132 .for P in $(CRUNCH_PROGS_$(D))
133 .ifdef CRUNCH_SRCDIR_${P}
134 cd ${CRUNCH_SRCDIR_$(P)} && \
135 MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
136 DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}
138 cd $(.CURDIR)/../../${D}/${P} && \
139 MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
140 DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}
147 if [ -e ${.OBJDIR}/$(OUTMK) ]; then \
148 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) clean; \
150 .for D in $(CRUNCH_SRCDIRS)
151 .for P in $(CRUNCH_PROGS_$(D))
152 .ifdef CRUNCH_SRCDIR_${P}
153 cd ${CRUNCH_SRCDIR_$(P)} && \
154 MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
155 DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}
157 cd $(.CURDIR)/../../${D}/${P} && \
158 MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
159 DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}