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.
25 # If CRUNCH_GENERATE_LINKS is set to no, no links will be generated.
28 # $FreeBSD: head/share/mk/bsd.crunchgen.mk 251512 2013-06-07 21:40:02Z emaste $
30 ##################################################################
31 # The following is pretty nearly a generic crunchgen-handling makefile
37 OUTPUTS
=$(OUTMK
) $(OUTC
) $(PROG
).cache
38 CRUNCHOBJS
= ${.OBJDIR
}
39 .if defined
(MAKEOBJDIRPREFIX
)
40 CANONICALOBJDIR
:= ${MAKEOBJDIRPREFIX}${.CURDIR
}
41 .elif defined
(MAKEOBJDIR
) && ${MAKEOBJDIR
:M
/*} != ""
42 CANONICALOBJDIR
:=${MAKEOBJDIR}
44 CANONICALOBJDIR
:= /usr
/obj
${.CURDIR
}
46 CRUNCH_GENERATE_LINKS?
= yes
48 CLEANFILES
+= $(CONF
) *.o
*.lo
*.c
*.mk
*.cache
*.a
*.h
50 # Don't try to extract debug info from ${PROG}.
53 # Program names and their aliases contribute hardlinks to 'rescue' executable,
54 # except for those that get suppressed.
55 .for D in
$(CRUNCH_SRCDIRS
)
56 .for P in
$(CRUNCH_PROGS_
$(D
))
57 .
ifdef CRUNCH_SRCDIR_
${P}
58 $(OUTPUTS
): $(CRUNCH_SRCDIR_
${P})/Makefile
60 $(OUTPUTS
): $(.CURDIR
)/..
/..
/..
/$(D
)/$(P
)/Makefile
62 .if
${CRUNCH_GENERATE_LINKS} == "yes"
63 .
ifndef CRUNCH_SUPPRESS_LINK_
${P}
64 LINKS
+= $(BINDIR
)/$(PROG
) $(BINDIR
)/$(P
)
66 .for A in
$(CRUNCH_ALIAS_
$(P
))
67 .
ifndef CRUNCH_SUPPRESS_LINK_
${A}
68 LINKS
+= $(BINDIR
)/$(PROG
) $(BINDIR
)/$(A
)
79 echo \
# Auto-generated, do not edit >$(.TARGET)
80 .
ifdef CRUNCH_BUILDOPTS
81 echo buildopts
$(CRUNCH_BUILDOPTS
) >>$(.TARGET
)
84 echo libs
$(CRUNCH_LIBS
) >>$(.TARGET
)
87 echo libs_so
$(CRUNCH_SHLIBS
) >>$(.TARGET
)
89 .for D in
$(CRUNCH_SRCDIRS
)
90 .for P in
$(CRUNCH_PROGS_
$(D
))
91 echo progs
$(P
) >>$(.TARGET
)
92 .
ifdef CRUNCH_SRCDIR_
${P}
93 echo special
$(P
) srcdir $(CRUNCH_SRCDIR_
${P}) >>$(.TARGET
)
95 echo special
$(P
) srcdir $(.CURDIR
)/..
/..
/..
/$(D
)/$(P
) >>$(.TARGET
)
97 .
ifdef CRUNCH_BUILDOPTS_
${P}
98 echo special
$(P
) buildopts DIRPRFX
=${DIRPRFX}${P}/ \
99 $(CRUNCH_BUILDOPTS_
${P}) >>$(.TARGET
)
101 echo special
$(P
) buildopts DIRPRFX
=${DIRPRFX}${P}/ >>$(.TARGET
)
103 .
ifdef CRUNCH_KEEP_
${P}
104 echo special
$(P
) keep
$(CRUNCH_KEEP_
${P}) >>$(.TARGET
)
106 .for A in
$(CRUNCH_ALIAS_
$(P
))
107 echo ln
$(P
) $(A
) >>$(.TARGET
)
112 # XXX Make sure we don't pass -P to crunchgen(1).
113 .MAKEFLAGS
:= ${.MAKEFLAGS
:N-P
}
114 .ORDER
: $(OUTPUTS
) objs
116 MAKE
=${MAKE} MAKEOBJDIRPREFIX
=${CRUNCHOBJS} crunchgen
-fq
-m
$(OUTMK
) \
119 $(PROG
): $(OUTPUTS
) objs
120 MAKEOBJDIRPREFIX
=${CRUNCHOBJS} ${MAKE} -f
$(OUTMK
) exe
123 MAKEOBJDIRPREFIX
=${CRUNCHOBJS} ${MAKE} -f
$(OUTMK
) objs
125 # <sigh> Someone should replace the bin/csh and bin/sh build-tools with
126 # shell scripts so we can remove this nonsense.
128 .for _tool in
$(CRUNCH_BUILDTOOLS
)
129 cd
$(.CURDIR
)/..
/..
/..
/${_tool}; \
130 MAKEOBJDIRPREFIX
=${CRUNCHOBJS} ${MAKE} obj
; \
131 MAKEOBJDIRPREFIX
=${CRUNCHOBJS} ${MAKE} build-tools
134 # Use a separate build tree to hold files compiled for this crunchgen binary
135 # Yes, this does seem to partly duplicate bsd.subdir.mk, but I can't
136 # get that to cooperate with bsd.prog.mk. Besides, many of the standard
137 # targets should NOT be propagated into the components.
138 cleandepend cleandir obj objlink
:
139 .for D in
$(CRUNCH_SRCDIRS
)
140 .for P in
$(CRUNCH_PROGS_
$(D
))
141 .
ifdef CRUNCH_SRCDIR_
${P}
142 cd
${CRUNCH_SRCDIR_
$(P
)} && \
143 MAKEOBJDIRPREFIX
=${CANONICALOBJDIR} ${MAKE} \
144 DIRPRFX
=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET
}
146 cd
$(.CURDIR
)/..
/..
/..
/${D}/${P} && \
147 MAKEOBJDIRPREFIX
=${CANONICALOBJDIR} ${MAKE} \
148 DIRPRFX
=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET
}
155 if
[ -e
${.OBJDIR
}/$(OUTMK
) ]; then \
156 MAKEOBJDIRPREFIX
=${CRUNCHOBJS} ${MAKE} -f
$(OUTMK
) clean; \
158 .for D in
$(CRUNCH_SRCDIRS
)
159 .for P in
$(CRUNCH_PROGS_
$(D
))
160 .
ifdef CRUNCH_SRCDIR_
${P}
161 cd
${CRUNCH_SRCDIR_
$(P
)} && \
162 MAKEOBJDIRPREFIX
=${CANONICALOBJDIR} ${MAKE} \
163 DIRPRFX
=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET
}
165 cd
$(.CURDIR
)/..
/..
/..
/${D}/${P} && \
166 MAKEOBJDIRPREFIX
=${CANONICALOBJDIR} ${MAKE} \
167 DIRPRFX
=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET
}