xref: /minix3/share/mk/minix.service.mk (revision 3ac58492b3d3709bad0ae9c60a137f63a90960b7)
1b956c873SArun Thomas# MINIX-specific servers/drivers options
2b956c873SArun Thomas.include <bsd.own.mk>
3b956c873SArun Thomas
484d9c625SLionel Sambuc# LSC: Our minimal c library has no putchar, which is called by the builtin
584d9c625SLionel Sambuc#      functions of the compiler, so prevent using them.
684d9c625SLionel Sambuc
784d9c625SLionel SambucAFLAGS+= -D__ASSEMBLY__
884d9c625SLionel SambucCOPTS+= -fno-builtin
984d9c625SLionel Sambuc
10*3ac58492SDavid van Moolenbroek# For MKCOVERAGE builds, enable coverage options.
11*3ac58492SDavid van Moolenbroek.if ${MKCOVERAGE:Uno} == "yes"
12*3ac58492SDavid van MoolenbroekCPPFLAGS+= ${COVCPPFLAGS}
13*3ac58492SDavid van MoolenbroekLDADD+= ${COVLDADD}
14*3ac58492SDavid van Moolenbroek.endif # ${MKCOVERAGE:Uno} == "yes"
15*3ac58492SDavid van Moolenbroek
168f3fbf7cSLionel Sambuc# LSC Static linking, order matters!
178f3fbf7cSLionel Sambuc# We can't use --start-group/--end-group as they are not supported by our
188f3fbf7cSLionel Sambuc# version of clang.
198f3fbf7cSLionel Sambuc
208f3fbf7cSLionel Sambuc# 1. No default libs
210cdf705cSLionel SambucLDADD:= -nodefaultlibs ${LDADD}
228f3fbf7cSLionel Sambuc
234684ddb6SLionel Sambuc# 2. Services system library
248f3fbf7cSLionel SambucLDADD+= -lsys
251f619c93SKees JongenburgerDPADD+= ${LIBSYS}
268f3fbf7cSLionel Sambuc
274684ddb6SLionel Sambuc# 3. Minimal C library, if libc had not yet been added
284684ddb6SLionel Sambuc.if ${LDADD:M-lc} == ""
298f3fbf7cSLionel SambucLDADD+= -lminc
301f619c93SKees JongenburgerDPADD+= ${LIBMINC}
314684ddb6SLionel Sambuc.endif # empty(${LDADD:M-lc})
328f3fbf7cSLionel Sambuc
3384d9c625SLionel Sambuc.if ${MACHINE_ARCH} == "earm"
3484d9c625SLionel Sambuc
3584d9c625SLionel Sambuc# LSC: On ARM, when compiling statically, with gcc, lgcc_eh is required
3684d9c625SLionel Sambuc.if ${PROG:U} != "kernel" && !empty(CC:M*gcc)
3784d9c625SLionel Sambuc# gcc_eh uses abort(), which is provided by minc
3884d9c625SLionel SambucLDFLAGS+= ${${ACTIVE_CC} == "gcc":? -lgcc_eh:}
3984d9c625SLionel Sambuc.endif # ${PROG:U} != "kernel" && !empty(CC:M*gcc)
4084d9c625SLionel Sambuc
4184d9c625SLionel Sambuc.endif # ${MACHINE_ARCH} == "earm"
4284d9c625SLionel Sambuc
433f38115cSBen Gras# Get (more) internal minix definitions and declarations.
443f38115cSBen GrasCPPFLAGS += -D_MINIX_SYSTEM=1
453f38115cSBen Gras
46bcc17a81SDavid van Moolenbroek# For MKMAGIC builds, link services against libmagicrt and run the magic pass
47bcc17a81SDavid van Moolenbroek# on them, unless they have specifically requested to be built without bitcode.
48bcc17a81SDavid van Moolenbroek.if ${USE_BITCODE:Uno} == "yes" && ${USE_MAGIC:Uno} == "yes"
49bcc17a81SDavid van MoolenbroekLIBMAGICST?= ${DESTDIR}${LIBDIR}/libmagicrt.bcc
50bcc17a81SDavid van MoolenbroekMAGICPASS?= ${NETBSDSRCDIR}/minix/llvm/bin/magic.so
51bcc17a81SDavid van Moolenbroek
52bcc17a81SDavid van MoolenbroekDPADD+= ${LIBMAGICST} ${MAGICPASS}
53bcc17a81SDavid van Moolenbroek
54bcc17a81SDavid van Moolenbroek.for _P in ${PROGS:U${PROG}}
55bcc17a81SDavid van MoolenbroekBITCODE_LD_FLAGS_1ST.${_P}?= ${LIBMAGICST}
56bcc17a81SDavid van Moolenbroek.endfor
57bcc17a81SDavid van Moolenbroek
58bcc17a81SDavid van MoolenbroekMAGICFLAGS?=
59bcc17a81SDavid van MoolenbroekOPTFLAGS+= -load ${MAGICPASS} -magic ${MAGICFLAGS}
6072965c88SDavid van Moolenbroek
6172965c88SDavid van Moolenbroek# For MKASR builds, generate an additional set of rerandomized service
6272965c88SDavid van Moolenbroek# binaries.
6372965c88SDavid van Moolenbroek.if ${USE_ASR:Uno} == "yes"
6472965c88SDavid van MoolenbroekASRPASS?= ${NETBSDSRCDIR}/minix/llvm/bin/asr.so
6572965c88SDavid van MoolenbroekASRCOUNT?= 3
6672965c88SDavid van MoolenbroekASRDIR?= /usr/service/asr
6772965c88SDavid van Moolenbroek
6872965c88SDavid van MoolenbroekDPADD+= ${ASRPASS}
6972965c88SDavid van Moolenbroek
7072965c88SDavid van MoolenbroekOPTFLAGS+= -load ${ASRPASS} -asr
7172965c88SDavid van Moolenbroek
7272965c88SDavid van Moolenbroek# Produce a variable _RANGE that contains "1 2 3 .. ${ASRCOUNT}".  We do not
7372965c88SDavid van Moolenbroek# want to invoke a shell command to do this; what if the host platform does not
7472965c88SDavid van Moolenbroek# have seq(1) ?  So, we do it with built-in BSD make features instead.  There
7572965c88SDavid van Moolenbroek# are probably substantially better ways to do this, though.  Right now the
7672965c88SDavid van Moolenbroek# maximum ASRCOUNT is 65536 (16**4), which should be plenty.  An ASRCOUNT of 0
7772965c88SDavid van Moolenbroek# is not supported, nor would it be very useful.
7872965c88SDavid van Moolenbroek_RANGE= 0
7972965c88SDavid van Moolenbroek_G0= xxxxxxxxxxxxxxxx
8072965c88SDavid van Moolenbroek_G= ${_G0:S/x/${_G0}/g:S/x/${_G0}/g:S/x/${_G0}/g}
8172965c88SDavid van Moolenbroek.for _X in ${_G:C/^(.{${ASRCOUNT}}).*/\1/:S/x/x /g}
8272965c88SDavid van Moolenbroek_RANGE:= ${_RANGE} ${_RANGE:[#]}
8372965c88SDavid van Moolenbroek.endfor
8472965c88SDavid van Moolenbroek_RANGE:= ${_RANGE:[2..-1]}
8572965c88SDavid van Moolenbroek
8672965c88SDavid van Moolenbroek# Add progname-1, progname-2, progname-3 (etc) to the list of programs to
8772965c88SDavid van Moolenbroek# generate, and install (just) these to ASRDIR.
8872965c88SDavid van MoolenbroekPROGS?= ${PROG}
8972965c88SDavid van Moolenbroek_PROGLIST:= ${PROGS}
9072965c88SDavid van Moolenbroek.for _N in ${_RANGE}
9172965c88SDavid van Moolenbroek.for _P in ${_PROGLIST}
9272965c88SDavid van MoolenbroekPROGS+= ${_P}-${_N}
9372965c88SDavid van MoolenbroekSRCS.${_P}-${_N}= ${SRCS.${_P}:U${SRCS}}
9472965c88SDavid van MoolenbroekBITCODE_LD_FLAGS_1ST.${_P}-${_N}:= ${BITCODE_LD_FLAGS_1ST.${_P}}
9572965c88SDavid van MoolenbroekBINDIR.${_P}-${_N}= ${ASRDIR}
9672965c88SDavid van Moolenbroek.endfor
9772965c88SDavid van Moolenbroek.endfor
9872965c88SDavid van Moolenbroek
9972965c88SDavid van Moolenbroek.endif # ${USE_ASR:Uno} == "yes"
100bcc17a81SDavid van Moolenbroek.endif # ${USE_BITCODE:Uno} == "yes" && ${USE_MAGIC:Uno} == "yes"
101bcc17a81SDavid van Moolenbroek
1028f3fbf7cSLionel Sambuc.include <bsd.prog.mk>
103