]> git.saurik.com Git - apple/xnu.git/blame - libsyscall/BSDmakefile
xnu-1228.12.14.tar.gz
[apple/xnu.git] / libsyscall / BSDmakefile
CommitLineData
2d21ac55
A
1.ifndef DSTROOT
2DSTROOT != x=`pwd`/DSTROOT && mkdir -p $$x && echo $$x
3.endif
4.ifndef OBJROOT
5OBJROOT != x=`pwd`/OBJROOT && mkdir -p $$x && echo $$x
6.endif
7.ifndef SRCROOT
8SRCROOT != dirname `pwd`
9.endif
10.ifndef SYMROOT
11SYMROOT != x=`pwd`/SYMROOT && mkdir -p $$x && echo $$x
12.endif
13ARCH != arch
14.ifndef RC_ARCHS
15RC_ARCHS = $(ARCH)
16RC_$(RC_ARCHS) = 1
17.endif
18NARCHS != echo $(RC_ARCHS) | wc -w
c910b4d9 19LIBSYS = $(SDKROOT)/usr/local/lib/system
2d21ac55
A
20NJOBS != perl -e '$$n = `/usr/sbin/sysctl -n hw.ncpu`; printf "%d\n", $$n < 2 ? 2 : ($$n * 1.5)'
21BSDMAKE = bsdmake -f Makefile
22BSDMAKEJ = $(BSDMAKE) -j $(NJOBS)
23
24# This variables are to guarantee that the left-hand side of an expression is
25# always a variable
26dynamic = dynamic
27static = static
28
29# Remove the arch stuff, since we know better here.
30LOCAL_CFLAGS != echo $(RC_CFLAGS) | sed 's/ *-arch [^ ][^ ]*//g'
31
32FORMS := debug dynamic profile static
33
34all: setup build
35
36build: build-debug build-dynamic build-profile build-static
37
38# These are the non B&I defaults
39.ifndef RC_ProjectName
40install: installhdrs install-all
41
42.else # RC_ProjectName
43
44install: setup
45.for F in $(FORMS)
46install: BI-install-$(F)
47.endfor # FORMS
48install:
49 install -c -m 444 $(OBJROOT)/sys/libsyscall.list $(DSTROOT)/usr/local/lib/system
50.endif # RC_ProjectName
51
52.for F in $(FORMS)
53.if $(dynamic) == $(F)
54SUFFIX$(F) =
55.else
56SUFFIX$(F) = _$(F)
57.endif
58LIPOARGS$(F) != perl -e 'printf "%s\n", join(" ", map(qq(-arch $$_ \"$(OBJROOT)/obj.$$_/libsyscall$(SUFFIX$(F)).a\"), qw($(RC_ARCHS))))'
59
60.for A in $(RC_ARCHS)
61build-$(F): build-$(A)-$(F)
62.endfor # RC_ARCHS
63build-$(F):
64.if $(NARCHS) == 1
65 cp -p "$(OBJROOT)/obj.$(RC_ARCHS)/libsyscall$(SUFFIX$(F)).a" "$(SYMROOT)"
66.else
67 lipo -create $(LIPOARGS$(F)) -output $(SYMROOT)/libsyscall$(SUFFIX$(F)).a
68.endif
69
70.for A in $(RC_ARCHS)
71build-$(A)-$(F):
72 mkdir -p $(OBJROOT)/obj.$(A) && \
73 MAKEOBJDIR="$(OBJROOT)/obj.$(A)" MACHINE_ARCH="$(A)" \
74 DSTROOT='$(DSTROOT)' OBJROOT='$(OBJROOT)' SYMROOT='$(SYMROOT)' \
75 MAKEFLAGS="" CFLAGS="-arch $(A) $(LOCAL_CFLAGS)" $(BSDMAKEJ) libsyscall$(SUFFIX$(F)).a
76.endfor # RC_ARCHS
77.endfor # FORMS
78
79installhdrs:
80 MAKEOBJDIR="$(OBJROOT)" DESTDIR="$(DSTROOT)" MAKEFLAGS="" \
81 DSTROOT='$(DSTROOT)' OBJROOT='$(OBJROOT)' SYMROOT='$(SYMROOT)' \
82 $(BSDMAKE) installhdrs
83.for A in $(RC_ARCHS)
84 mkdir -p "$(OBJROOT)/obj.$(A)" && \
85 MAKEOBJDIR="$(OBJROOT)/obj.$(A)" MACHINE_ARCH="$(A)" \
86 DSTROOT='$(DSTROOT)' OBJROOT='$(OBJROOT)' SYMROOT='$(SYMROOT)' \
87 MAKEFLAGS="" $(BSDMAKE) installhdrs-md
88.endfor # RC_ARCHS
89
90.for F in $(FORMS)
91BI-install-$(F): build-$(F)
92 mkdir -p $(DSTROOT)/usr/local/lib/system
93 if [ -f "$(SYMROOT)/libsyscall$(SUFFIX$(F)).a" ]; then \
94 echo "Installing libsyscall$(SUFFIX$(F)).a" && \
95 install -c -m 444 "$(SYMROOT)/libsyscall$(SUFFIX$(F)).a" \
96 $(DSTROOT)/usr/local/lib/system && \
97 ranlib "$(DSTROOT)/usr/local/lib/system/libsyscall$(SUFFIX$(F)).a"; \
98 fi
99.endfor # FORMS
100
101install-man:
102 mkdir -p $(DSTROOT)/usr/share/man/man2
103 MAKEOBJDIR="$(OBJROOT)" DESTDIR="$(DSTROOT)" \
104 DSTROOT='$(DSTROOT)' OBJROOT='$(OBJROOT)' SYMROOT='$(SYMROOT)' \
105 MACHINE_ARCH="$(ARCH)" MAKEFLAGS="" $(BSDMAKE) all-man maninstall
106
107install-all: setup build install-man
108.for F in $(FORMS)
109install-all: BI-install-$(F)
110.endfor # FORMS
111
112clean:
113.for F in $(FORMS)
114 rm -f $(OBJROOT)/libsyscall$(SUFFIX$(F)).a
115.endfor # FORMS
116.for A in $(RC_ARCHS)
117 rm -rf $(OBJROOT)/obj.$(A)
118.endfor # RC_ARCHS
119
120INCLUDEDIR = $(OBJROOT)/include
121SYSDIR = $(OBJROOT)/sys
122
123setup: $(INCLUDEDIR) $(SYSDIR)
124
125USR-INCLUDE = /usr/include
126MOD-HEADERS = architecture/ppc/mode_independent_asm.h architecture/i386/asm_help.h
127
128$(INCLUDEDIR):
129 mkdir -p $(INCLUDEDIR)
130.for h in $(MOD-HEADERS)
131 mkdir -p $(INCLUDEDIR)/$(h:H)
132 sed 's/\.globl/.private_extern/g' $(USR-INCLUDE)/$(h) > $(INCLUDEDIR)/$(h)
133.endfor # MOD-HEADERS
134
135$(SYSDIR):
136 mkdir -p $(SYSDIR)
137 $(SRCROOT)/libsyscall/create-syscalls.pl $(SRCROOT)/bsd/kern/syscalls.master $(SRCROOT)/libsyscall/custom $(SYSDIR)