]> git.saurik.com Git - apple/libc.git/blobdiff - GNUmakefile
Libc-339.tar.gz
[apple/libc.git] / GNUmakefile
index 4e756744b983e45327eaab7eb5521cef66042e40..64535b6cfd1b783438ddb9306fc95b0ba0d435be 100644 (file)
@@ -5,17 +5,19 @@ ifndef $(SYMROOT)
 SYMROOT = .
 endif
 ARCH = $(shell arch)
-ifndef RC_ppc 
-ifndef RC_i386
-RC_ppc = 1
+ifndef RC_ARCHS 
+RC_$(ARCH) = 1
+RC_ARCHS = $(ARCH)
 endif
-endif
-BSDMAKE = bsdmake -j 2
+# temporary disable multi-threaded builds, which are failing; see 3683272
+#BSDMAKE = bsdmake -j 2
+BSDMAKE = bsdmake
 
 # Remove the arch stuff, since we know better here.  
-LOCAL_CFLAGS = $(filter-out -arch ppc -arch i386,$(RC_CFLAGS))
+LOCAL_CFLAGS = $(filter-out -arch ppc -arch ppc64 -arch i386,$(RC_CFLAGS))
 
 all: build
+
 # These are the non B&I defaults
 ifndef RC_ProjectName
 installhdrs: installhdrs-real
@@ -26,9 +28,19 @@ endif
 # And these are to deal with B&I building libc differently 
 # based on RC_ProjectName.
 ifeq ($(RC_ProjectName),Libc)
+installhdrs:
+build: build-dynamic
+install: BI-install-dynamic
+endif
+ifeq ($(RC_ProjectName),Libc_headers)
 installhdrs: installhdrs-real
-build: build-man build-dynamic
-install: installhdrs-real BI-install-dynamic install-man
+build:
+install: installhdrs-real
+endif
+ifeq ($(RC_ProjectName),Libc_man)
+installhdrs:
+build:
+install: install-man
 endif
 ifeq ($(RC_ProjectName),Libc_static)
 installhdrs:
@@ -46,61 +58,54 @@ build: build-profile
 install: BI-install-profile
 endif
 
-build-man:
-       MAKEOBJDIR="$(OBJROOT)" MACHINE_ARCH="$(shell arch)" \
-               MAKEFLAGS="" $(BSDMAKE) buildman
-build-static: build-ppc-static build-i386-static
-       @echo "Checking for libc_static.a"
-       @if [ -f "$(OBJROOT)/obj.ppc/libc_static.a" -a -f "$(OBJROOT)/obj.i386/libc_static.a" ]; then\
-               lipo -create -arch ppc "$(OBJROOT)/obj.ppc/libc_static.a" \
-                       -arch i386 "$(OBJROOT)/obj.i386/libc_static.a" \
-                       -output $(SYMROOT)/libc_static.a;\
-       elif [ -f "$(OBJROOT)/obj.ppc/libc_static.a" ]; then \
-               cp -p "$(OBJROOT)/obj.ppc/libc_static.a" "$(SYMROOT)"; \
-       elif [ -f "$(OBJROOT)/obj.i386/libc_static.a" ]; then \
-               cp -p "$(OBJROOT)/obj.i386/libc_static.a" "$(SYMROOT)"; \
-       fi
-build-profile: build-ppc-profile build-i386-profile
-       @echo "Checking for libc_profile.a"
-       @if [ -f "$(OBJROOT)/obj.ppc/libc_profile.a" -a -f "$(OBJROOT)/obj.i386/libc_profile.a" ]; then\
-               lipo -create -arch ppc "$(OBJROOT)/obj.ppc/libc_profile.a" \
-                       -arch i386 "$(OBJROOT)/obj.i386/libc_profile.a" \
-                       -output $(SYMROOT)/libc_profile.a;\
-       elif [ -f "$(OBJROOT)/obj.ppc/libc_profile.a" ]; then \
-               cp -p "$(OBJROOT)/obj.ppc/libc_profile.a" "$(SYMROOT)"; \
-       elif [ -f "$(OBJROOT)/obj.i386/libc_profile.a" ]; then \
-               cp -p "$(OBJROOT)/obj.i386/libc_profile.a" "$(SYMROOT)"; \
-       fi
-build-debug: build-ppc-debug build-i386-debug
-       @echo "Checking for libc_debug.a"
-       @if [ -f "$(OBJROOT)/obj.ppc/libc_debug.a" -a -f "$(OBJROOT)/obj.i386/libc_debug.a" ]; then\
-               lipo -create -arch ppc "$(OBJROOT)/obj.ppc/libc_debug.a" \
-                       -arch i386 "$(OBJROOT)/obj.i386/libc_debug.a" \
-                       -output $(SYMROOT)/libc_debug.a;\
-       elif [ -f "$(OBJROOT)/obj.ppc/libc_debug.a" ]; then \
-               cp -p "$(OBJROOT)/obj.ppc/libc_debug.a" "$(SYMROOT)"; \
-       elif [ -f "$(OBJROOT)/obj.i386/libc_debug.a" ]; then \
-               cp -p "$(OBJROOT)/obj.i386/libc_debug.a" "$(SYMROOT)"; \
-       fi
-build-dynamic: build-ppc-dynamic build-i386-dynamic
-       @echo "Checking for libc.a"
-       @if [ -f "$(OBJROOT)/obj.ppc/libc.a" -a -f "$(OBJROOT)/obj.i386/libc.a" ]; then\
-               echo "Creating FAT libc.a"; \
-               lipo -create -arch ppc "$(OBJROOT)/obj.ppc/libc.a" -arch i386 \
-                       "$(OBJROOT)/obj.i386/libc.a" -output $(SYMROOT)/libc.a;\
-       elif [ -f "$(OBJROOT)/obj.ppc/libc.a" ]; then \
-               echo "Using thin PPC libc.a" ;\
-               cp -p "$(OBJROOT)/obj.ppc/libc.a" "$(SYMROOT)"; \
-       elif [ -f "$(OBJROOT)/obj.i386/libc.a" ]; then \
-               echo "Using thin i386 libc.a" ;\
-               cp -p "$(OBJROOT)/obj.i386/libc.a" "$(SYMROOT)"; \
-       fi
+build-static: autopatch build-ppc-static build-ppc64-static build-i386-static
+       @echo "Creating final libc_static.a"
+ifeq ($(words $(RC_ARCHS)),1)
+       cp -p "$(OBJROOT)/obj.$(RC_ARCHS)/libc_static.a" "$(SYMROOT)"
+else
+       lipo -create \
+               $(foreach A,$(RC_ARCHS),-arch $(A) "$(OBJROOT)/obj.$(A)/libc_static.a") \
+               -output $(SYMROOT)/libc_static.a
+endif
+build-profile: autopatch build-ppc-profile build-ppc64-profile build-i386-profile
+       @echo "Creating final libc_profile.a"
+ifeq ($(words $(RC_ARCHS)),1)
+       cp -p "$(OBJROOT)/obj.$(RC_ARCHS)/libc_profile.a" "$(SYMROOT)"
+else
+       lipo -create \
+               $(foreach A,$(RC_ARCHS),-arch $(A) "$(OBJROOT)/obj.$(A)/libc_profile.a") \
+               -output $(SYMROOT)/libc_profile.a
+endif
+build-debug: autopatch build-ppc-debug build-ppc64-debug build-i386-debug
+       @echo "Creating final libc_debug.a"
+ifeq ($(words $(RC_ARCHS)),1)
+       cp -p "$(OBJROOT)/obj.$(RC_ARCHS)/libc_debug.a" "$(SYMROOT)"
+else
+       lipo -create \
+               $(foreach A,$(RC_ARCHS),-arch $(A) "$(OBJROOT)/obj.$(A)/libc_debug.a") \
+               -output $(SYMROOT)/libc_debug.a
+endif
+build-dynamic: autopatch build-ppc-dynamic build-ppc64-dynamic build-i386-dynamic
+       @echo "Creating final libc.a"
+ifeq ($(words $(RC_ARCHS)),1)
+       cp -p "$(OBJROOT)/obj.$(RC_ARCHS)/libc.a" "$(SYMROOT)"
+else
+       lipo -create \
+               $(foreach A,$(RC_ARCHS),-arch $(A) "$(OBJROOT)/obj.$(A)/libc.a") \
+               -output $(SYMROOT)/libc.a
+endif
 build-ppc-static:
        @if [ ! -z "$(RC_ppc)" ]; then \
                mkdir -p $(OBJROOT)/obj.ppc ; \
                MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \
                        MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" $(BSDMAKE) libc_static.a;\
        fi
+build-ppc64-static:
+       @if [ ! -z "$(RC_ppc64)" ]; then \
+               mkdir -p $(OBJROOT)/obj.ppc64 ; \
+               MAKEOBJDIR="$(OBJROOT)/obj.ppc64" MACHINE_ARCH="ppc64" \
+                       MAKEFLAGS="" CFLAGS="-arch ppc64 $(LOCAL_CFLAGS)" $(BSDMAKE) libc_static.a;\
+       fi
 build-i386-static:
        @if [ ! -z "$(RC_i386)" ]; then \
                mkdir -p $(OBJROOT)/obj.i386 ; \
@@ -113,6 +118,12 @@ build-ppc-profile:
                MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \
                        MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" $(BSDMAKE) libc_profile.a;\
        fi
+build-ppc64-profile:
+       @if [ ! -z "$(RC_ppc64)" ]; then \
+               mkdir -p $(OBJROOT)/obj.ppc64 ; \
+               MAKEOBJDIR="$(OBJROOT)/obj.ppc64" MACHINE_ARCH="ppc64" \
+                       MAKEFLAGS="" CFLAGS="-arch ppc64 $(LOCAL_CFLAGS)" $(BSDMAKE) libc_profile.a;\
+       fi
 build-i386-profile:
        @if [ ! -z "$(RC_i386)" ]; then \
                mkdir -p $(OBJROOT)/obj.i386 ; \
@@ -125,6 +136,12 @@ build-ppc-debug:
                MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \
                        MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" $(BSDMAKE) libc_debug.a;\
        fi
+build-ppc64-debug:
+       @if [ ! -z "$(RC_ppc64)" ]; then \
+               mkdir -p $(OBJROOT)/obj.ppc64 ; \
+               MAKEOBJDIR="$(OBJROOT)/obj.ppc64" MACHINE_ARCH="ppc64" \
+                       MAKEFLAGS="" CFLAGS="-arch ppc64 $(LOCAL_CFLAGS)" $(BSDMAKE) libc_debug.a;\
+       fi
 build-i386-debug:
        @if [ ! -z "$(RC_i386)" ]; then \
                mkdir -p $(OBJROOT)/obj.i386 ; \
@@ -137,6 +154,12 @@ build-ppc-dynamic:
                MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \
                        MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" $(BSDMAKE) libc.a;\
        fi
+build-ppc64-dynamic:
+       @if [ ! -z "$(RC_ppc64)" ]; then \
+               mkdir -p $(OBJROOT)/obj.ppc64 ; \
+               MAKEOBJDIR="$(OBJROOT)/obj.ppc64" MACHINE_ARCH="ppc64" \
+                       MAKEFLAGS="" CFLAGS="-arch ppc64 $(LOCAL_CFLAGS)" $(BSDMAKE) libc.a;\
+       fi
 build-i386-dynamic:
        @if [ ! -z "$(RC_i386)" ]; then \
                mkdir -p $(OBJROOT)/obj.i386 ; \
@@ -150,12 +173,33 @@ build-ppc:
                MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \
                        MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" $(BSDMAKE) build;\
        fi
+build-ppc64:
+       @if [ ! -z "$(RC_ppc64)" ]; then \
+               mkdir -p $(OBJROOT)/obj.ppc64 ; \
+               MAKEOBJDIR="$(OBJROOT)/obj.ppc64" MACHINE_ARCH="ppc64" \
+                       MAKEFLAGS="" CFLAGS="-arch ppc64 $(LOCAL_CFLAGS)" $(BSDMAKE) build;\
+       fi
 build-i386:
        @if [ ! -z "$(RC_i386)" ]; then \
                mkdir -p $(OBJROOT)/obj.i386 ; \
                MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \
                        MAKEFLAGS="" CFLAGS="-arch i386 $(LOCAL_CFLAGS)" $(BSDMAKE) build;\
        fi
+
+# We have to separately call bsdmake to patch the FreeBSD files, because of
+# the way its cache works, it would otherwise pick a file in ${SYMROOT}, even
+# over a .s file.
+autopatch:
+       @if [ ! -z "$(RC_i386)" ]; then \
+           MACHINE_ARCH="i386" $(BSDMAKE) autopatch; \
+       fi
+       @if [ ! -z "$(RC_ppc)" ]; then \
+           MACHINE_ARCH="ppc" $(BSDMAKE) autopatch; \
+       fi
+       @if [ ! -z "$(RC_ppc64)" ]; then \
+           MACHINE_ARCH="ppc64" $(BSDMAKE) autopatch; \
+       fi
+
 installsrc:
        $(_v) pax -rw . "$(SRCROOT)"
 
@@ -172,6 +216,11 @@ installhdrs-real:
                MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \
                MAKEFLAGS="" $(BSDMAKE) installhdrs-md ; \
        fi
+       @if [ ! -z "$(RC_ppc64)" ]; then \
+               mkdir -p "$(OBJROOT)/obj.ppc64" ; \
+               MAKEOBJDIR="$(OBJROOT)/obj.ppc64" MACHINE_ARCH="ppc64" \
+               MAKEFLAGS="" $(BSDMAKE) installhdrs-md ; \
+       fi
 
 BI-install-static: build-static
        mkdir -p $(DSTROOT)/usr/local/lib/system
@@ -214,9 +263,9 @@ install-man:
        mkdir -p $(DSTROOT)/usr/share/man/man5
        mkdir -p $(DSTROOT)/usr/share/man/man7
        MAKEOBJDIR="$(OBJROOT)" DESTDIR="$(DSTROOT)" NOMANCOMPRESS=1 \
-               MACHINE_ARCH="$(shell arch)" MAKEFLAGS="" bsdmake fbsdman maninstall
+               MACHINE_ARCH="$(shell arch)" MAKEFLAGS="" bsdmake autopatchman maninstall
 
-install-all: build install-man BI-install-dynamic BI-install-static BI-install-profile
+install-all: build install-man BI-install-dynamic BI-install-static BI-install-profile BI-install-debug
 
 clean:
        rm -rf $(OBJROOT)/obj.ppc $(OBJROOT)/obj.i386 $(OBJROOT)/libc.a \