2 # Kernel Module Library code makefile
5 export MakeInc_cmd=${SRCROOT}/makedefs/MakeInc.cmd
6 export MakeInc_def=${SRCROOT}/makedefs/MakeInc.def
7 export MakeInc_rule=${SRCROOT}/makedefs/MakeInc.rule
8 export MakeInc_dir=${SRCROOT}/makedefs/MakeInc.dir
11 include $(MakeInc_cmd)
12 include $(MakeInc_def)
14 INSTALL_DIR = $(DSTROOT)/usr/lib
16 KMODCPP_NAME = libkmodc++
17 LIB_INSTALL_FLAGS = -p -m 444
19 # -mkernel implies -mlong-branch/-mlong-calls/-mno-red-zone as needed for
20 # code linked into kexts
21 CFLAGS_KMOD = $(filter-out -O0 -O1 -O2 -O3 -O4 -Os -Oz,$(CFLAGS)) \
24 ifneq ($(MACHINE_CONFIG), DEFAULT)
25 COMPOBJROOT = $(OBJROOT)/$(KERNEL_CONFIG)_$(ARCH_CONFIG)_$(MACHINE_CONFIG)/$(COMPONENT)/kmod
26 INSTOBJROOT = $(OBJROOT)/$(INSTALL_TYPE)_$(ARCH_CONFIG)_$(MACHINE_CONFIG)/$(COMPONENT)/kmod
28 COMPOBJROOT = $(OBJROOT)/$(KERNEL_CONFIG)_$(ARCH_CONFIG)/$(COMPONENT)/kmod
29 INSTOBJROOT = $(OBJROOT)/$(INSTALL_TYPE)_$(ARCH_CONFIG)/$(COMPONENT)/kmod
33 KMOD_CFILES = c_start.c c_stop.c
34 KMODCPP_CFILES = cplus_start.c cplus_stop.c
36 KMOD_OFILES = $(KMOD_CFILES:.c=.o)
37 KMODCPP_OFILES = $(KMODCPP_CFILES:.c=.o)
39 ALL_OFILES = $(KMOD_OFILES) $(KMODCPP_OFILES)
41 $(ALL_OFILES): %.o : %.c
43 $(_v)${KCC} -c ${CFLAGS_KMOD} ${${join $@,_CFLAGS}} ${INCFLAGS} ${${join $@,_INCFLAGS}} -o $(COMPOBJROOT)/$(*F).o $<
45 $(COMPOBJROOT)/$(KMOD_NAME).a: $(KMOD_OFILES)
46 @echo LIBTOOL $(notdir $@)
47 $(_v)$(LIBTOOL) -static -o $@ $^ $(_vstdout) 2>&1
49 $(COMPOBJROOT)/$(KMODCPP_NAME).a: $(KMODCPP_OFILES)
50 @echo LIBTOOL $(notdir $@)
51 $(_v)$(LIBTOOL) -static -o $@ $^ $(_vstdout) 2>&1
53 do_build_all: $(COMPOBJROOT)/$(KMOD_NAME).a $(COMPOBJROOT)/$(KMODCPP_NAME).a
55 $(INSTALL_DIR)/%.a: $(INSTOBJROOT)/%.a
56 @echo Installing $< in $@;
57 $(_v)$(RM) $@ || true; \
58 ${MKDIR} $(INSTALL_DIR) $(SYMROOT); \
59 if [ $(MACHINE_CONFIG) = DEFAULT ]; then \
61 for onearch in $(INSTALL_ARCHS); do \
62 archdir=$(OBJROOT)/$(KERNEL_CONFIG)_$${onearch}/$(COMPONENT); \
63 if [ -e $${archdir}/kmod/$(*F).a ]; then \
64 allarchs="$${allarchs} $${archdir}/kmod/$(*F).a"; \
67 cmd="$(LIPO) $${allarchs} -create -output $(SYMROOT)/$(*F).a"; \
68 echo $$cmd; eval $$cmd; \
72 outputfile=$(SYMROOT)/$(*F).a; \
73 for my_config in $(TARGET_CONFIGS_UC); do \
74 if [ $${my_counter} -eq 1 ]; then \
76 my_kconfig=$${my_config}; \
77 elif [ $${my_counter} -eq 2 ]; then \
79 my_aconfig=$${my_config}; \
82 inputfile=$(OBJROOT)/$${my_kconfig}_$${my_aconfig}_$${my_config}/$(COMPONENT)/kmod/$(*F).a; \
83 if [ -e $${inputfile} ]; then \
84 if [ $${my_innercounter} -eq 1 ]; then \
86 cmd="$(LIPO) -create $${inputfile} -o $${outputfile}"; \
88 cmd="$(LIPO) -create $${outputfile} $${inputfile} -o $${outputfile} || true"; \
90 echo $$cmd; eval $$cmd; \
95 cmd="$(INSTALL) $(LIB_INSTALL_FLAGS) $(SYMROOT)/$(*F).a $@"; \
96 echo $$cmd; eval $$cmd
98 do_build_install: $(INSTALL_DIR)/$(KMOD_NAME).a $(INSTALL_DIR)/$(KMODCPP_NAME).a
100 # include $(MakeInc_rule)
101 include $(MakeInc_dir)