]>
Commit | Line | Data |
---|---|---|
1 | .ifndef DSTROOT | |
2 | DSTROOT != x=`pwd`/DSTROOT && mkdir -p $$x && echo $$x | |
3 | .endif | |
4 | .ifndef OBJROOT | |
5 | OBJROOT != x=`pwd`/OBJROOT && mkdir -p $$x && echo $$x | |
6 | .endif | |
7 | .ifndef SRCROOT | |
8 | SRCROOT != dirname `pwd` | |
9 | .endif | |
10 | .ifndef SYMROOT | |
11 | SYMROOT != x=`pwd`/SYMROOT && mkdir -p $$x && echo $$x | |
12 | .endif | |
13 | ARCH != arch | |
14 | .ifndef RC_ARCHS | |
15 | RC_ARCHS = $(ARCH) | |
16 | RC_$(RC_ARCHS) = 1 | |
17 | .endif | |
18 | NARCHS != echo $(RC_ARCHS) | wc -w | |
19 | LIBSYS = $(SDKROOT)/usr/local/lib/system | |
20 | NJOBS != perl -e '$$n = `/usr/sbin/sysctl -n hw.ncpu`; printf "%d\n", $$n < 2 ? 2 : ($$n * 1.5)' | |
21 | BSDMAKE = bsdmake -f Makefile | |
22 | BSDMAKEJ = $(BSDMAKE) -j $(NJOBS) | |
23 | ||
24 | # This variables are to guarantee that the left-hand side of an expression is | |
25 | # always a variable | |
26 | dynamic = dynamic | |
27 | static = static | |
28 | ||
29 | # Remove the arch stuff, since we know better here. | |
30 | LOCAL_CFLAGS != echo $(RC_CFLAGS) | sed 's/ *-arch [^ ][^ ]*//g' | |
31 | ||
32 | FORMS := debug dynamic profile static | |
33 | ||
34 | all: setup build | |
35 | ||
36 | build: build-debug build-dynamic build-profile build-static | |
37 | ||
38 | # These are the non B&I defaults | |
39 | .ifndef RC_ProjectName | |
40 | install: installhdrs install-all | |
41 | ||
42 | .else # RC_ProjectName | |
43 | ||
44 | install: setup | |
45 | .for F in $(FORMS) | |
46 | install: BI-install-$(F) | |
47 | .endfor # FORMS | |
48 | install: | |
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) | |
54 | SUFFIX$(F) = | |
55 | .else | |
56 | SUFFIX$(F) = _$(F) | |
57 | .endif | |
58 | LIPOARGS$(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) | |
61 | build-$(F): build-$(A)-$(F) | |
62 | .endfor # RC_ARCHS | |
63 | build-$(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) | |
71 | build-$(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 | ||
79 | installhdrs: | |
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) | |
91 | BI-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 | ||
101 | install-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 | ||
107 | install-all: setup build install-man | |
108 | .for F in $(FORMS) | |
109 | install-all: BI-install-$(F) | |
110 | .endfor # FORMS | |
111 | ||
112 | clean: | |
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 | ||
120 | INCLUDEDIR = $(OBJROOT)/include | |
121 | SYSDIR = $(OBJROOT)/sys | |
122 | ||
123 | setup: $(INCLUDEDIR) $(SYSDIR) | |
124 | ||
125 | USR-INCLUDE = /usr/include | |
126 | MOD-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) |