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