]> git.saurik.com Git - apple/xnu.git/blame - libkern/kmod/Makefile.kmod
xnu-792.12.6.tar.gz
[apple/xnu.git] / libkern / kmod / Makefile.kmod
CommitLineData
1c79356b
A
1#
2# Kernel Module Library code makefile
3#
4
5export MakeInc_cmd=${SRCROOT}/makedefs/MakeInc.cmd
6export MakeInc_def=${SRCROOT}/makedefs/MakeInc.def
7export MakeInc_rule=${SRCROOT}/makedefs/MakeInc.rule
8export MakeInc_dir=${SRCROOT}/makedefs/MakeInc.dir
9
10
11include $(MakeInc_cmd)
12include $(MakeInc_def)
13
14INSTALL_DIR = $(DSTROOT)/usr/lib
15KMOD_NAME = libkmod
16KMODCPP_NAME = libkmodc++
0b4e3aa0 17LIB_INSTALL_FLAGS = -p -m 444
1c79356b
A
18
19CFLAGS += -Wall -Wno-four-char-constants
20CFLAGS_PPC += -mlong-branch
21
22COMPOBJROOT = $(OBJROOT)/$(KERNEL_CONFIG)_$(ARCH_CONFIG)/$(COMPONENT)/kmod
23INSTOBJROOT = $(OBJROOT)/$(INSTALL_TYPE)_$(ARCH_CONFIG)/$(COMPONENT)/kmod
24
25KMOD_CFILES = c_start.c c_stop.c
26KMODCPP_CFILES = cplus_start.c cplus_stop.c
27
28KMOD_OFILES = $(KMOD_CFILES:.c=.o)
29KMODCPP_OFILES = $(KMODCPP_CFILES:.c=.o)
30
31ALL_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
42do_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
60do_build_install: $(INSTALL_DIR)/$(KMOD_NAME).a $(INSTALL_DIR)/$(KMODCPP_NAME).a
61
62# include $(MakeInc_rule)
63include $(MakeInc_dir)