]> git.saurik.com Git - apple/xnu.git/blob - libkern/kmod/Makefile.kmod
xnu-123.5.tar.gz
[apple/xnu.git] / libkern / kmod / Makefile.kmod
1 #
2 # Kernel Module Library code makefile
3 #
4
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
9
10
11 include $(MakeInc_cmd)
12 include $(MakeInc_def)
13
14 INSTALL_DIR = $(DSTROOT)/usr/lib
15 KMOD_NAME = libkmod
16 KMODCPP_NAME = libkmodc++
17 LIB_INSTALL_FLAGS = -c -m 444 -S "-S"
18
19 CFLAGS += -Wall -Wno-four-char-constants
20 CFLAGS_PPC += -mlong-branch
21
22 COMPOBJROOT = $(OBJROOT)/$(KERNEL_CONFIG)_$(ARCH_CONFIG)/$(COMPONENT)/kmod
23 INSTOBJROOT = $(OBJROOT)/$(INSTALL_TYPE)_$(ARCH_CONFIG)/$(COMPONENT)/kmod
24
25 KMOD_CFILES = c_start.c c_stop.c
26 KMODCPP_CFILES = cplus_start.c cplus_stop.c
27
28 KMOD_OFILES = $(KMOD_CFILES:.c=.o)
29 KMODCPP_OFILES = $(KMODCPP_CFILES:.c=.o)
30
31 ALL_OFILES = $(KMOD_OFILES) $(KMODCPP_OFILES)
32
33 $(ALL_OFILES): %.o : %.c
34 ${KCC} -c ${CFLAGS} ${${join $@,_CFLAGS}} ${INCFLAGS} ${${join $@,_INCFLAGS}} -o $(COMPOBJROOT)/$(*F).o $<
35
36 $(COMPOBJROOT)/$(KMOD_NAME).a: $(KMOD_OFILES)
37 libtool -static -o $@ $^
38
39 $(COMPOBJROOT)/$(KMODCPP_NAME).a: $(KMODCPP_OFILES)
40 libtool -static -o $@ $^
41
42 do_build_all: $(COMPOBJROOT)/$(KMOD_NAME).a $(COMPOBJROOT)/$(KMODCPP_NAME).a
43
44 $(INSTALL_DIR)/%.a: $(INSTOBJROOT)/%.a
45 @allarchs=""; \
46 for onearch in $(INSTALL_ARCHS); do \
47 archdir=$(OBJROOT)/$(KERNEL_CONFIG)_$$onearch/$(COMPONENT); \
48 if [ -e $$archdir/kmod/$(*F).a ]; then \
49 allarchs="$$allarchs $$archdir/kmod/$(*F).a"; \
50 fi; \
51 done; \
52 $(RM) $@ || true; \
53 ${MKDIR} $(INSTALL_DIR) $(SYMROOT); \
54 cmd="lipo $$allarchs -create -output $(SYMROOT)/$(*F).a"; \
55 echo $$cmd; eval $$cmd; \
56 cmd="install $(LIB_INSTALL_FLAGS) $(SYMROOT)/$(*F).a $@"; \
57 echo $$cmd; eval $$cmd
58
59
60 do_build_install: $(INSTALL_DIR)/$(KMOD_NAME).a $(INSTALL_DIR)/$(KMODCPP_NAME).a
61
62 # include $(MakeInc_rule)
63 include $(MakeInc_dir)