xref: /minix/share/mk/minix.service.mk (revision 117b6ea0)
1# MINIX-specific servers/drivers options
2.include <bsd.own.mk>
3
4# LSC: Our minimal c library has no putchar, which is called by the builtin
5#      functions of the compiler, so prevent using them.
6
7AFLAGS+= -D__ASSEMBLY__
8COPTS+= -fno-builtin
9
10# For MKCOVERAGE builds, enable coverage options.
11.if ${MKCOVERAGE:Uno} == "yes"
12CPPFLAGS+= ${COVCPPFLAGS}
13LDADD+= ${COVLDADD}
14.endif # ${MKCOVERAGE:Uno} == "yes"
15
16# LSC Static linking, order matters!
17# We can't use --start-group/--end-group as they are not supported by our
18# version of clang.
19
20# 1. No default libs
21LDADD:= -nodefaultlibs ${LDADD}
22
23# 2. Services system library
24LDADD+= -lsys
25DPADD+= ${LIBSYS}
26
27# 3. Minimal C library, if libc had not yet been added
28.if ${LDADD:M-lc} == ""
29LDADD+= -lminc
30DPADD+= ${LIBMINC}
31.endif # empty(${LDADD:M-lc})
32
33.if ${MACHINE_ARCH} == "earm"
34
35# LSC: On ARM, when compiling statically, with gcc, lgcc_eh is required
36.if ${PROG:U} != "kernel" && !empty(CC:M*gcc)
37# gcc_eh uses abort(), which is provided by minc
38LDFLAGS+= ${${ACTIVE_CC} == "gcc":? -lgcc_eh:}
39.endif # ${PROG:U} != "kernel" && !empty(CC:M*gcc)
40
41.endif # ${MACHINE_ARCH} == "earm"
42
43# Get (more) internal minix definitions and declarations.
44CPPFLAGS += -D_MINIX_SYSTEM=1
45
46# For MKMAGIC builds, link services against libmagicrt and run the magic pass
47# on them, unless they have specifically requested to be built without bitcode.
48.if ${USE_BITCODE:Uno} == "yes" && ${USE_MAGIC:Uno} == "yes"
49LIBMAGICST?= ${DESTDIR}${LIBDIR}/libmagicrt.bcc
50MAGICPASS?= ${NETBSDSRCDIR}/minix/llvm/bin/magic.so
51
52DPADD+= ${LIBMAGICST} ${MAGICPASS}
53
54.for _P in ${PROGS:U${PROG}}
55BITCODE_LD_FLAGS_1ST.${_P}?= ${LIBMAGICST}
56.endfor
57
58MAGICFLAGS?=
59OPTFLAGS+= -load ${MAGICPASS} -magic ${MAGICFLAGS}
60
61# For MKASR builds, generate an additional set of rerandomized service
62# binaries.
63.if ${USE_ASR:Uno} == "yes"
64ASRPASS?= ${NETBSDSRCDIR}/minix/llvm/bin/asr.so
65ASRCOUNT?= 3
66ASRDIR?= /usr/service/asr
67
68DPADD+= ${ASRPASS}
69
70OPTFLAGS+= -load ${ASRPASS} -asr
71
72# Produce a variable _RANGE that contains "1 2 3 .. ${ASRCOUNT}".  We do not
73# want to invoke a shell command to do this; what if the host platform does not
74# have seq(1) ?  So, we do it with built-in BSD make features instead.  There
75# are probably substantially better ways to do this, though.  Right now the
76# maximum ASRCOUNT is 65536 (16**4), which should be plenty.  An ASRCOUNT of 0
77# is not supported, nor would it be very useful.
78_RANGE= 0
79_G0= xxxxxxxxxxxxxxxx
80_G= ${_G0:S/x/${_G0}/g:S/x/${_G0}/g:S/x/${_G0}/g}
81.for _X in ${_G:C/^(.{${ASRCOUNT}}).*/\1/:S/x/x /g}
82_RANGE:= ${_RANGE} ${_RANGE:[#]}
83.endfor
84_RANGE:= ${_RANGE:[2..-1]}
85
86# Add progname-1, progname-2, progname-3 (etc) to the list of programs to
87# generate, and install (just) these to ASRDIR.
88PROGS?= ${PROG}
89_PROGLIST:= ${PROGS}
90.for _N in ${_RANGE}
91.for _P in ${_PROGLIST}
92PROGS+= ${_P}-${_N}
93SRCS.${_P}-${_N}= ${SRCS.${_P}:U${SRCS}}
94BITCODE_LD_FLAGS_1ST.${_P}-${_N}:= ${BITCODE_LD_FLAGS_1ST.${_P}}
95BINDIR.${_P}-${_N}= ${ASRDIR}
96.endfor
97.endfor
98
99.endif # ${USE_ASR:Uno} == "yes"
100.endif # ${USE_BITCODE:Uno} == "yes" && ${USE_MAGIC:Uno} == "yes"
101
102.include <bsd.prog.mk>
103