| 1 | OS = $(shell uname -s)
|
|---|
| 2 | GCC_VERSION = 4.0-20050326
|
|---|
| 3 | ARCHIVES = gcc-core-$(GCC_VERSION).tar.bz2 gcc-objc-$(GCC_VERSION).tar.bz2
|
|---|
| 4 |
|
|---|
| 5 | # On LinuxPPC, we want to generate a 32/64-bit compiler (that defaults
|
|---|
| 6 | # to 32-bit.) We need to copy some compiler-specific headers to a
|
|---|
| 7 | # directory that ffigen can find at runtime.
|
|---|
| 8 | ifeq ($(OS),Linux)
|
|---|
| 9 | PLATFORM = linuxppc
|
|---|
| 10 | CONFIGARGS = --target=ppc64-unknown-linux --host=ppc64-unknown-linux --with-cpu=default32 --enable-biarch
|
|---|
| 11 | COPY_OBJC_HEADERS = NO
|
|---|
| 12 | endif
|
|---|
| 13 |
|
|---|
| 14 | ifeq ($(OS),Darwin)
|
|---|
| 15 | PLATFORM=darwinppc
|
|---|
| 16 | CONFIGTARGET = powerpc-apple-darwin8
|
|---|
| 17 | CONFIGARGS = --target=$(CONFIGTARGET) --with-cpu=default32 --enable-biarch
|
|---|
| 18 | MAKE_FUNKY_LINK = YES
|
|---|
| 19 | COPY_OBJC_HEADERS = NO
|
|---|
| 20 | endif
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 | all: package
|
|---|
| 25 | m4 -DPLATFORM=$(PLATFORM) -DGCC_VERSION=$(GCC_VERSION) source/INSTALL-$(PLATFORM).m4 > INSTALL-FFIGEN-$(PLATFORM)-gcc-$(GCC_VERSION).txt
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 | compile: patch
|
|---|
| 29 | mkdir build
|
|---|
| 30 | (cd build ; ../gcc-$(GCC_VERSION)/configure --enable-languages=objc $(CONFIGARGS) )
|
|---|
| 31 | ifeq ($(MAKE_FUNKY_LINK),YES)
|
|---|
| 32 | (cd build ; ln -s . build-`../gcc-$(GCC_VERSION)/config.guess`)
|
|---|
| 33 | endif
|
|---|
| 34 | (cd build ; make maybe-configure-libiberty maybe-configure-gcc maybe-configure-libcpp)
|
|---|
| 35 | (cd build/libiberty ; make)
|
|---|
| 36 | (cd build/intl ; make)
|
|---|
| 37 | (cd build/libcpp ; make)
|
|---|
| 38 | (cd build/gcc ; make cc1obj xlimits.h)
|
|---|
| 39 |
|
|---|
| 40 | patch: extract
|
|---|
| 41 | ln -sf `pwd`/source/ffi.c gcc-$(GCC_VERSION)/gcc
|
|---|
| 42 | for f in source/gcc-$(GCC_VERSION)*.diff ; do \
|
|---|
| 43 | (cd gcc-$(GCC_VERSION)/gcc; patch -p0 <../../$$f); \
|
|---|
| 44 | done
|
|---|
| 45 |
|
|---|
| 46 | package: compile
|
|---|
| 47 | mkdir bin
|
|---|
| 48 | cat source/$(PLATFORM)-gcc-$(GCC_VERSION)-h-to-ffi.sh source/h-to-ffi-common > bin/h-to-ffi.sh
|
|---|
| 49 | chmod +x bin/h-to-ffi.sh
|
|---|
| 50 | mkdir ffigen
|
|---|
| 51 | cp -r -p gcc-$(GCC_VERSION)/gcc/ginclude ffigen
|
|---|
| 52 | mv ffigen/ginclude ffigen/include
|
|---|
| 53 | cp -p build/gcc/xlimits.h ffigen/include/limits.h
|
|---|
| 54 | ifeq ($(COPY_OBJC_HEADERS), YES)
|
|---|
| 55 | cp -r -p gcc-$(GCC_VERSION)/libobjc/objc ffigen/include
|
|---|
| 56 | endif
|
|---|
| 57 | mkdir ffigen/bin
|
|---|
| 58 | cp -p build/gcc/cc1obj ffigen/bin/ffigen
|
|---|
| 59 | strip ffigen/bin/ffigen
|
|---|
| 60 | tar cfz ffigen-bin-$(PLATFORM)-gcc-$(GCC_VERSION).tar.gz bin ffigen
|
|---|
| 61 |
|
|---|
| 62 | clean:
|
|---|
| 63 | rm -rf gcc-$(GCC_VERSION) ffigen build bin ffigen*tar.gz INSTALL-FFIGEN-$(PLATFORM)-gcc-$(GCC_VERSION).txt
|
|---|
| 64 |
|
|---|
| 65 | %.bz2:
|
|---|
| 66 | @echo
|
|---|
| 67 | @echo Obtain the file $@ from a GNU mirror site and copy it to this directory.
|
|---|
| 68 | @echo
|
|---|
| 69 | @exit 2
|
|---|
| 70 |
|
|---|
| 71 | extract: $(ARCHIVES) clean
|
|---|
| 72 | tar foxj gcc-core-$(GCC_VERSION).tar.bz2
|
|---|
| 73 | tar foxj gcc-objc-$(GCC_VERSION).tar.bz2
|
|---|