]> git.saurik.com Git - apple/libsystem.git/blame - libsys/Makefile
Libsystem-111.1.1.tar.gz
[apple/libsystem.git] / libsys / Makefile
CommitLineData
7a301563
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
19.ifdef ALTUSRLOCALLIBSYSTEM
20LIBSYS = $(ALTUSRLOCALLIBSYSTEM)
21.else
22LIBSYS = $(NEXT_ROOT)/usr/local/lib/system
23.endif
24NJOBS != perl -e '$$n = `/usr/sbin/sysctl -n hw.ncpu`; printf "%d\n", $$n < 2 ? 2 : ($$n * 1.5)'
25BSDMAKE = bsdmake -f Makefile
26BSDMAKEJ = $(BSDMAKE) -j $(NJOBS)
27
28# This variables are to guarantee that the left-hand side of an expression is
29# always a variable
30dynamic = dynamic
31
32# Remove the arch stuff, since we know better here.
33LOCAL_CFLAGS != echo $(RC_CFLAGS) | sed 's/ *-arch [^ ][^ ]*//g'
34
35FORMS := debug dynamic profile
36
37all: build
38
39build: build-debug build-dynamic build-profile
40
41# These are the non B&I defaults
42.ifndef RC_ProjectName
43install: installhdrs install-all
44
45.else # RC_ProjectName
46
47.for F in $(FORMS)
48install: BI-install-$(F)
49.endfor # FORMS
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)/$$_/$(F)/libc$(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)/$(RC_ARCHS)/$(F)/libc$(SUFFIX$(F)).a" "$(SYMROOT)"
66.else
67 lipo -create $(LIPOARGS$(F)) -output "$(SYMROOT)/libc$(SUFFIX$(F)).a"
68.endif
69 ranlib "$(SYMROOT)/libc$(SUFFIX$(F)).a"
70
71.for A in $(RC_ARCHS)
72build-$(A)-$(F): $(OBJROOT)/$(A)/libsystem.o
73 mkdir -p '$(OBJROOT)/$(A)/$(F)'
74 @set -x && \
75 cd '$(OBJROOT)/$(A)/$(F)' && \
76 ditto -arch $(A) '$(LIBSYS)/libc-partial$(SUFFIX$(F)).a' . && \
77 ar x 'libc-partial$(SUFFIX$(F)).a' && \
78 ditto -arch $(A) '$(LIBSYS)/libsyscall$(SUFFIX$(F)).a' . && \
79 ar x 'libsyscall$(SUFFIX$(F)).a' && \
80 '$(SRCROOT)/libsys/build-libc.pl' '$(LIBSYS)' '$(OBJROOT)/$(A)/$(F)' && \
81 ln -s ../libsystem.o && \
82 $(BSDMAKEJ)
83.endfor # RC_ARCHS
84.endfor # FORMS
85
86.for A in $(RC_ARCHS)
87$(OBJROOT)/$(A)/libsystem.o: $(OBJROOT)/libsystem.c
88 mkdir -p '$(OBJROOT)/$(A)'
89 cc -c -o '$(.TARGET)' -arch $(A) '$(.ALLSRC)'
90.endfor # RC_ARCHS
91
92$(OBJROOT)/libsystem.c:
93 /Developer/Makefiles/bin/version.pl Libsystem > $(.TARGET)
94
95installhdrs:
96
97.for F in $(FORMS)
98BI-install-$(F): build-$(F)
99 mkdir -p "$(DSTROOT)/usr/local/lib/system"
100 @echo "Installing libc$(SUFFIX$(F)).a"
101 install "$(SYMROOT)/libc$(SUFFIX$(F)).a" "$(DSTROOT)/usr/local/lib/system"
102 ranlib "$(DSTROOT)/usr/local/lib/system/libc$(SUFFIX$(F)).a"
103 chmod 0444 "$(DSTROOT)/usr/local/lib/system/libc$(SUFFIX$(F)).a"
104.endfor # FORMS
105
106install-all: build
107.for F in $(FORMS)
108install-all: BI-install-$(F)
109.endfor # FORMS
110
111clean:
112.for A in $(RC_ARCHS)
113 rm -rf $(OBJROOT)/$(A)
114.endfor # RC_ARCHS