1 # Makefile for libmagicrt
3 # The magic runtime library is the runtime state transfer component for live
4 # update. It is not a regular library. First of all, it is only built when
5 # MKMAGIC is enabled, which also implies that we are building bitcode.
6 # Second, the produced file is a single bitcode object containing basically the
7 # concatenation of the individual bitcode objects produced from the source
8 # files. The final bitcode object is used to link against system services
9 # during the rest of the compilation process. It is installed only because
10 # this makes it easier to refer to it during the rest of the compilation
11 # process. However, both the library's generation and its installation cannot
12 # be done with regular bsd.lib.mk rules, which is why this Makefile is rather
17 LIBNAME
= libmagicrt.bcc
19 SRCS
= magic.c magic_analysis.c magic_asr.c magic_ds.c
20 SRCS
+= magic_eval.c magic_eval_lib.c magic_mem.c magic_range.c
21 SRCS
+= magic_selement.c magic_sentry.c magic_splay_tree.c
22 SRCS
+= magic_st.c magic_util.c
26 CPPFLAGS
+= -D__MINIX
-D_MINIX_SYSTEM
-D_SYSTEM
27 CPPFLAGS
+= -I
${.CURDIR
}/include
28 CPPFLAGS
+= -I
${NETBSDSRCDIR}/minix
/llvm
/include # for magic_common.h
29 CPPFLAGS.magic_ds.c
+= -I
${NETBSDSRCDIR}/minix
/servers
# for ds/store.h
31 # XXX: there is essential code in assert() statements, so force asserts on..
34 # All functions and data must be assigned to nonstandard sections. However,
35 # the magic_st module has different rules from the rest.
36 SECTIONIFY
= -sectionify-no-override \
37 -sectionify-data-section-map
=^_____magic_instr_.
*/magic_instr_data
,.
*/magic_data \
38 -sectionify-function-section-map
=.
*/magic_functions
39 SECTIONIFY.magic_st.c
= \
40 -sectionify-data-section-map
=.
*/magic_data_st \
41 -sectionify-function-section-map
=.
*/magic_functions_st
43 # HACK: keep the "temporary" .bc.o files generated as part of running the
44 # sectionify pass, so that we can trick clang into taking bitcode objects
45 # during the linking phase, because its driver refuses to take objects with
46 # the .bc suffix even when using the gold plugin. This works only because
47 # we are using sectionify on all objects here, and because bsd.lib.mk uses
48 # temporary names convenient for us. See also the comment in bsd.lib.mk.
51 LDFLAGS
+=-nostdlib
-rdynamic
-shared
-Wl
,--plugin \
52 -Wl
,${NETBSDSRCDIR}/minix
/llvm
/bin
/LLVMgold.so \
53 -Wl
,-plugin-opt
=-disable-fp-elim
-Wl
,-plugin-opt
=emit-llvm
59 ${LINK.c
} -o
${.TARGET
} ${OBJS
:.bc
=.bc.o
}
61 # The following block is a modified copy of similar blocks in bsd.lib.mk.
62 _LIB
=${DESTDIR}/${LIBDIR}/${LIBNAME}
65 .if
${MKUPDATE} == "no"
66 .if
!defined
(BUILD
) && !make
(all) && !make
(${LIBNAME})
69 ${_LIB}! ${LIBNAME} __archiveinstall
71 .if
!defined
(BUILD
) && !make
(all) && !make
(${LIBNAME})
74 ${_LIB}: ${LIBNAME} __archiveinstall
77 CLEANFILES
+= ${LIBNAME} ${OBJS
:.bc
=.bc.o
}