Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | PWD != pwd .ifdef DSTROOT DESTDIR = $(DSTROOT) .else .ifdef DESTDIR DSTROOT = $(DESTDIR) .else DSTROOT = / DESTDIR = / .endif .endif .ifndef OBJROOT OBJROOT = $(PWD)/OBJROOT .endif .ifndef SRCROOT SRCROOT = $(PWD) .endif .ifndef SYMROOT SYMROOT = $(PWD)/SYMROOT .endif ARCH != arch .ifndef RC_ARCHS RC_ARCHS = $(ARCH) RC_$(RC_ARCHS) = 1 .endif .ifdef ALTUSRLOCALLIBSYSTEM LIBSYS = $(ALTUSRLOCALLIBSYSTEM) .else LIBSYS = $(NEXT_ROOT)/usr/local/lib/system .endif NJOBS != perl -e '$$n = `/usr/sbin/sysctl -n hw.ncpu`; printf "%d\n", $$n < 2 ? 2 : ($$n * 1.5)' BSDMAKE = bsdmake -f Makefile #BSDMAKEJ = $(BSDMAKE) -j $(NJOBS) -P BSDMAKEJ = $(BSDMAKE) -j $(NJOBS) # Set the DONT-BUILD-arch-form variable to non-empty to turn off building #DONT-BUILD-x86_64-static = 1 # These variables are to guarantee that the left-hand side of an expression is # always a variable dynamic = dynamic static = static # Remove the arch stuff, since we know better here. LOCAL_CFLAGS != echo $(RC_CFLAGS) | sed 's/ *-arch [^ ][^ ]*//g' FORMS := dynamic debug profile static all: build ROOTS := DSTROOT OBJROOT SYMROOT .for R in $(ROOTS) # { roots: $($(R)) $($(R)): mkdir -p '$($(R))' .endfor # ROOTS } # These are the non B&I defaults .ifndef RC_ProjectName installhdrs: roots installhdrs-real build: roots build-static build-profile build-debug build-dynamic install: roots installhdrs install-all .else # RC_ProjectName # And these are to deal with B&I building libc differently # based on RC_ProjectName. .if $(RC_ProjectName) == Libc installhdrs: build: roots build-dynamic install: roots BI-install-dynamic .endif .if $(RC_ProjectName) == Libc_headers installhdrs: roots installhdrs-real build: install: roots installhdrs-real .endif .if $(RC_ProjectName) == Libc_man installhdrs: build: install: roots install-man .endif .if $(RC_ProjectName) == Libc_static installhdrs: build: roots build-static install: roots BI-install-static .endif .if $(RC_ProjectName) == Libc_debug installhdrs: build: roots build-debug install: roots BI-install-debug .endif .if $(RC_ProjectName) == Libc_profile installhdrs: build: roots build-profile install: roots BI-install-profile .endif .endif # RC_ProjectName # Make a copy of System.framework/Versions/B/PrivateHeaders, with headers # patched so that we can build variant symbols independently SYSTEMFRAMEWORK = System.framework VERSIONSB = Versions/B PRIVATEHEADERPATH = $(SYSTEMFRAMEWORK)/$(VERSIONSB)/PrivateHeaders FRAMEWORKS = $(OBJROOT)/Frameworks .ifdef ALTFRAMEWORKSPATH FRAMEWORKPATH = ${ALTFRAMEWORKSPATH} .else FRAMEWORKPATH = ${NEXT_ROOT}/System/Library/Frameworks .endif $(FRAMEWORKS): $(SRCROOT)/patchHeaders $(FRAMEWORKPATH)/$(PRIVATEHEADERPATH) $(FRAMEWORKS)/$(PRIVATEHEADERPATH:H) ln -fs $(VERSIONSB)/PrivateHeaders $(FRAMEWORKS)/$(SYSTEMFRAMEWORK)/PrivateHeaders AUTOPATCHED = $(SRCROOT)/.autopatched PARTIAL = -partial .for F in $(FORMS) # { .if $(dynamic) == $(F) # { SUFFIX-$(F) = .else # } { SUFFIX-$(F) = _$(F) .endif # } PSUFFIX-$(F) = $(PARTIAL)$(SUFFIX-$(F)) .for A in $(RC_ARCHS) # { .if empty(DONT-BUILD-$(A)-$(F)) # { ARCHS-$(F) += $(A) build-$(A)-$(F): mkdir -p $(OBJROOT)/obj.$(A) && \ MAKEOBJDIR="$(OBJROOT)/obj.$(A)" MACHINE_ARCH="$(A)" \ DSTROOT=$(DSTROOT) OBJROOT=$(OBJROOT) SYMROOT=$(SYMROOT) \ MAKEFLAGS="" CFLAGS="-arch $(A) $(LOCAL_CFLAGS)" $(BSDMAKEJ) libc$(SUFFIX-$(F)).a .else # } { build-$(A)-$(F): @echo Not building libc$(PSUFFIX-$(F)).a for $(A) .endif # } .endfor # RC_ARCHS } NARCHS-$(F) != echo $(ARCHS-$(F)) | wc -w build-$(F): $(FRAMEWORKS) $(AUTOPATCHED) .for A in $(RC_ARCHS) # { build-$(F): build-$(A)-$(F) .endfor # RC_ARCHS } .if $(NARCHS-$(F)) == 0 # { build-$(F): @echo No libc$(PSUFFIX-$(F)).a built .else # } { LIPOARGS-$(F) != perl -e 'printf "%s\n", join(" ", map(qq(-arch $$_ \"$(OBJROOT)/obj.$$_/libc$(SUFFIX-$(F)).a\"), qw($(ARCHS-$(F)))))' build-$(F): .if $(NARCHS-$(F)) == 1 # { cp -p "$(OBJROOT)/obj.$(RC_ARCHS)/libc$(SUFFIX-$(F)).a" "$(SYMROOT)/libc$(PSUFFIX-$(F)).a" .else # } { lipo -create $(LIPOARGS-$(F)) -output "$(SYMROOT)/libc$(PSUFFIX-$(F)).a" .endif # } .endif # } .endfor # FORMS } # We autopatch the files into the directory containing the Makefile.inc. This # will happen at installsrc. $(AUTOPATCHED): @set -x && \ for m in `find $(SRCROOT) -name Makefile.inc`; do \ cd `dirname $$m` && \ bsdmake -I $(SRCROOT) -f $(SRCROOT)/Makefile.inc -f Makefile.inc -f $(SRCROOT)/Makefile.autopatch autopatch LIB=c SRCROOT=$(SRCROOT) || \ exit 1; \ done touch $(AUTOPATCHED) copysrc: pax -rw -p p . "$(SRCROOT)" installsrc: copysrc $(AUTOPATCHED) installhdrs-real: MAKEOBJDIR="$(OBJROOT)" DESTDIR="$(DSTROOT)" MAKEFLAGS="" \ DSTROOT=$(DSTROOT) OBJROOT=$(OBJROOT) SYMROOT=$(SYMROOT) \ $(BSDMAKEJ) installhdrs .for A in $(RC_ARCHS) # { mkdir -p "$(OBJROOT)/obj.$(A)" && \ MAKEOBJDIR="$(OBJROOT)/obj.$(A)" MACHINE_ARCH="$(A)" \ DSTROOT=$(DSTROOT) OBJROOT=$(OBJROOT) SYMROOT=$(SYMROOT) \ MAKEFLAGS="" $(BSDMAKEJ) installhdrs-md .endfor # RC_ARCHS # } .for F in $(FORMS) # { BI-install-$(F): build-$(F) mkdir -p $(DSTROOT)/usr/local/lib/system if [ -f "$(SYMROOT)/libc$(PSUFFIX-$(F)).a" ]; then \ echo "Installing libc$(PSUFFIX-$(F)).a" && \ install -c -m 444 "$(SYMROOT)/libc$(PSUFFIX-$(F)).a" \ $(DSTROOT)/usr/local/lib/system && \ ranlib "$(DSTROOT)/usr/local/lib/system/libc$(PSUFFIX-$(F)).a" || exit 1; \ fi .if $(dynamic) == $(F) # { .for A in $(RC_ARCHS) # { MAKEOBJDIR="$(OBJROOT)/obj.$(A)" MACHINE_ARCH="$(A)" \ DSTROOT=$(DSTROOT) OBJROOT=$(OBJROOT) SYMROOT=$(SYMROOT) \ DSTROOT=$(DSTROOT) OBJROOT=$(OBJROOT) SYMROOT=$(SYMROOT) \ MAKEFLAGS="" $(BSDMAKE) copyfiles .endfor # RC_ARCHS # } .endif # } .endfor # FORMS } # Don't use -j here; it may try to make links before the files are copied MANARGS != test `id -u` -eq 0 || echo MINSTALL=/usr/bin/install install-man: mkdir -p $(DSTROOT)/usr/share/man/man2 mkdir -p $(DSTROOT)/usr/share/man/man3 mkdir -p $(DSTROOT)/usr/share/man/man4 mkdir -p $(DSTROOT)/usr/share/man/man5 mkdir -p $(DSTROOT)/usr/share/man/man7 MAKEOBJDIR="$(OBJROOT)" DESTDIR="$(DSTROOT)" \ DSTROOT='$(DSTROOT)' OBJROOT='$(OBJROOT)' SYMROOT='$(SYMROOT)' \ MACHINE_ARCH="$(ARCH)" MAKEFLAGS="" \ $(BSDMAKE) autopatchman all-man maninstall $(MANARGS) install-all: build install-man .for F in $(FORMS) # { install-all: BI-install-$(F) .endfor # FORMS } clean: .for F in $(FORMS) # { rm -f $(SYMROOT)/libc$(PSUFFIX-$(F)).a .endfor # FORMS } .for A in $(RC_ARCHS) # { rm -rf $(OBJROOT)/obj.$(A) .endfor # RC_ARCHS # } |