|
23 | 23 | # Copyright (c) 2013, Joyent, Inc. All rights reserved.
|
24 | 24 | #
|
25 | 25 |
|
26 |
| -# |
27 |
| -# This makefile has not been adapted to use the infrastructure because of |
28 |
| -# the need to build in a separate subdirectory from the source. This could |
29 |
| -# be accommodated without excessive effort but is a highly unusual pattern. |
30 |
| -# |
31 |
| - |
32 | 26 | VER = gcc-4.4.4
|
| 27 | +MPFR_VER = mpfr-3.1.2 |
| 28 | +GMP_VER = gmp-5.1.1 |
33 | 29 |
|
34 | 30 | include ../Makefile.defs
|
35 | 31 |
|
36 |
| -CLEANFILES += $(VER)-i386-build |
| 32 | +SEPARATE_BUILD = yes |
37 | 33 |
|
38 | 34 | GCC = /opt/local/bin/gcc
|
39 | 35 | GXX = /bin/false
|
| 36 | +CFLAGS = -nostdinc -isystem /usr/include -g -O2 |
40 | 37 |
|
41 |
| -include ../Makefile.targ |
| 38 | +AUTOCONF_OPTS += \ |
| 39 | + --with-ld=/usr/bin/ld \ |
| 40 | + --without-gnu-ld \ |
| 41 | + --with-gnu-as \ |
| 42 | + --with-as=$(DESTDIR)/usr/gnu/bin/gas \ |
| 43 | + --enable-languages="c,c++" \ |
| 44 | + --enable-shared \ |
| 45 | + --disable-nls |
| 46 | + |
| 47 | +AUTOCONF_ENV += \ |
| 48 | + DESTDIR=$(DESTDIR) \ |
| 49 | + MAKE=$(MAKE) |
| 50 | + |
| 51 | +OVERRIDES += \ |
| 52 | + $(AUTOCONF_CFLAGS) \ |
| 53 | + STAGE1_CFLAGS="$(CFLAGS)" \ |
| 54 | + CFLAGS_FOR_TARGET="$(CFLAGS)" |
| 55 | + |
| 56 | +# |
| 57 | +# Unlike everything else, gcc is built to be a cross-compiler, really. It |
| 58 | +# never runs on the target system, only the build system. So it should not |
| 59 | +# be using the proto area's headers or libraries. Its own libraries will be |
| 60 | +# built by the new compiler, and generally aren't using system headers anyway. |
| 61 | +# This is not really completely true; for example, libstdc++, and this will |
| 62 | +# need more work to be really right. We only deliver the libraries. |
| 63 | +# |
| 64 | +AUTOCONF_CPPFLAGS = |
| 65 | +AUTOCONF_LIBS = |
| 66 | +GENLDFLAGS = |
| 67 | + |
| 68 | +PATCHES = Patches/* |
| 69 | +ALL_TGT = bootstrap |
42 | 70 |
|
43 |
| -all: $(VER)-i386-build/config.status |
44 |
| - (cd $(VER)-i386-build; env - \ |
45 |
| - CC=$(GCC) \ |
46 |
| - CFLAGS="-g -O2" \ |
47 |
| - DESTDIR=$(DESTDIR) \ |
48 |
| - PATH=$(PATH) \ |
49 |
| - STAGE1_CFLAGS="-g -O2" \ |
50 |
| - CFLAGS_FOR_TARGET="-g -O2" \ |
51 |
| - MAKE=gmake gmake \ |
52 |
| - CFLAGS="-g -O2" \ |
53 |
| - STAGE1_CFLAGS="-g -O2" \ |
54 |
| - CFLAGS_FOR_TARGET="-g -O2" $(PARALLEL) bootstrap) |
| 71 | +include ../Makefile.targ |
| 72 | +include ../Makefile.targ.autoconf |
55 | 73 |
|
56 |
| -install: all |
57 |
| - (cd $(VER)-i386-build; env - \ |
58 |
| - CC=$(GCC) \ |
59 |
| - CFLAGS="-g -O2" \ |
60 |
| - STAGE1_CFLAGS="-g -O2" \ |
61 |
| - CFLAGS_FOR_TARGET="-g -O2" \ |
62 |
| - DESTDIR=$(DESTDIR) \ |
63 |
| - PATH=$(PATH) \ |
64 |
| - MAKE=gmake gmake \ |
65 |
| - CFLAGS="-g -O2" \ |
66 |
| - STAGE1_CFLAGS="-g -O2" \ |
67 |
| - CFLAGS_FOR_TARGET="-g -O2" $(PARALLEL) install) |
| 74 | +# |
| 75 | +# We could use the mpfr and gmp from the build system (since the compiler will |
| 76 | +# be run here), but there's no good way to make gcc build itself correctly if |
| 77 | +# we do. There are two main problems: |
| 78 | +# |
| 79 | +# 1. Stage2 and later cc1 and company don't honour any combination of LDFLAGS, |
| 80 | +# LDFLAGS_FOR_TARGET, BOOT_LDFLAGS, STAGE2_LDFLAGS, etc. So the only ways to |
| 81 | +# get these things built with -R/opt/local/lib are to use LD_OPTIONS which will |
| 82 | +# yield the wrong results for libraries or to hack configure. |
| 83 | +# |
| 84 | +# 2. Even if we could get -R/opt/local/lib into these programs without building |
| 85 | +# the libraries incorrectly, it would still be wrong. The pkgsrc lib directory |
| 86 | +# on many systems contains libgcc_s.so.1; however, cc1 was built by the stage2 |
| 87 | +# compiler and should find the libgcc that matches that compiler. That happens |
| 88 | +# to be the one we just built, not the pkgsrc one. |
| 89 | +# |
| 90 | +# So Instead we have mpfr and gmp built as part of the gcc build itself. |
| 91 | +# |
| 92 | +$(AUTOCONF_OUT.32): | $(VER.32)/mpfr $(VER.32)/gmp |
68 | 93 |
|
69 |
| -$(VER)-i386-build/config.status: $(VER)-i386-build $(VER.32)/configure |
70 |
| - (cd $(VER)-i386-build; env - \ |
71 |
| - CC=$(GCC) \ |
72 |
| - CFLAGS="-g -O2" \ |
73 |
| - DESTDIR=$(DESTDIR) \ |
74 |
| - PATH=$(PATH) \ |
75 |
| - MAKE=gmake \ |
76 |
| - ../$(VER.32)/configure \ |
77 |
| - --prefix=/usr \ |
78 |
| - --with-ld=/usr/bin/ld \ |
79 |
| - --without-gnu-ld \ |
80 |
| - --with-gnu-as \ |
81 |
| - --with-as=$(DESTDIR)/usr/gnu/bin/gas \ |
82 |
| - --enable-languages="c,c++" \ |
83 |
| - --enable-shared \ |
84 |
| - --with-gmp=/opt/local \ |
85 |
| - --with-mpfr=/opt/local \ |
86 |
| - --disable-nls \ |
87 |
| - --with-included-gettext) |
| 94 | +$(VER.32)/mpfr: $(MPFR_VER).tar.gz | $(VER.32) |
| 95 | + -rm -rf $@ |
| 96 | + mkdir -p .unpack32 |
| 97 | + gtar x -C .unpack32 -z --no-same-owner -f $(MPFR_VER).tar.gz |
| 98 | + mv -f .unpack32/$(MPFR_VER) ./$@ |
| 99 | + -rmdir .unpack32 |
| 100 | + chmod 755 $@/configure |
| 101 | + touch $@/configure |
88 | 102 |
|
89 |
| -$(VER)-i386-build: |
90 |
| - mkdir -p $@ |
| 103 | +$(VER.32)/gmp: $(GMP_VER).tar.bz2 | $(VER.32) |
| 104 | + -rm -rf $@ |
| 105 | + mkdir -p .unpack32 |
| 106 | + gtar x -C .unpack32 -j --no-same-owner -f $(GMP_VER).tar.bz2 |
| 107 | + mv -f .unpack32/$(GMP_VER) ./$@ |
| 108 | + -rmdir .unpack32 |
| 109 | + chmod 755 $@/configure |
| 110 | + touch $@/configure |
0 commit comments