source: trunk/dports/lang/apple-gcc42/Portfile @ 113993

Last change on this file since 113993 was 112955, checked in by ryandesign@…, 6 years ago

apple-gcc42, llvm-gcc42: don't rely on correct permissions on files in the files directory (#40886)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 10.6 KB
Line 
1# $Id: Portfile 112955 2013-11-05 03:11:56Z ryandesign@macports.org $
2
3PortSystem 1.0
4PortGroup select 1.0
5
6name                    apple-gcc42
7version                 5666.3
8set gcc_version         4.2.1
9revision                13
10categories              lang
11platforms               darwin
12license                 {GPL-2+ Permissive}
13maintainers             jeremyhu openmaintainer
14license_noconflict      ld64
15
16description             Apple's version of gcc 4.2
17long_description        Apple's version of the GNU compiler collection, \
18                        version 4.2. Supports C, Objective-C, and C++
19
20variant gpl3 description {Merge in changes from gcc-4.2.4} {
21        license         {GPL-3+ Permissive}
22        maintainers     googlemail.com:tobias.netzel openmaintainer
23
24        patchfiles-append    gcc-4.2.1-4.2.4.patch gcc-4.2.4-emmintrin.patch
25}
26if {[variant_isset gpl3]} {
27        set gcc_version 4.2.4
28}
29
30homepage                http://opensource.apple.com/
31master_sites            gnu:/gcc/gcc-${gcc_version}:gnu \
32                        http://opensource.apple.com/tarballs/gcc/:apple
33
34distname                gcc-${version}
35
36set dcore               ${distname}.tar.gz
37set dfort               gcc-fortran-${gcc_version}.tar.bz2
38set djava               gcc-java-${gcc_version}.tar.bz2
39
40distfiles               ${dcore}:apple
41# ${dfort}:gnu ${djava}:gnu
42
43checksums           gcc-4.2.1-4.2.4.patch \
44                    rmd160  17cb0baeab3ba081a7cbf87635c2794a76263f40 \
45                    sha256  f4c99f897acd2c64b872223b375e6e87add48fe0d6b017552855585250df6671 \
46                    gcc-5666.3.tar.gz \
47                    rmd160  a01d000f89c0e89dd0079dcd202bba7629ba78dc \
48                    sha256  6c46f4376d11ada5be0cfc3894b9296edf574af3c616ab71803ea78edfd7015b
49
50#                    gcc-fortran-4.2.1.tar.bz2 \
51#                    md5     2a91d467b50a404ca0cd3b10b413f9b2 \
52#                    sha1    37a0466b393ade9291dcec315c69c371e42db7f5 \
53#                    rmd160  2475594dad66277fd0c5fe42389fb8fa2665e5ce \
54#                    gcc-java-4.2.1.tar.bz2 \
55#                    md5     3fc64e96388b939fada65fe3bffb5924 \
56#                    sha1    4615c85ef9010304bf412adc2f2c33d256e177fd \
57#                    rmd160  bb4b256f7e7779361214593343821a127ee78d1a
58
59#                    gcc-fortran-4.2.4.tar.bz2 \
60#                    md5     d8896f33f91eca12135df2c1e5aa0887 \
61#                    sha1    ? \
62#                    rmd160  ? \
63#                    gcc-java-4.2.4.tar.bz2 \
64#                    md5     dd05ac72f8563c98af6946f9334668f1 \
65#                    sha1    ? \
66#                    rmd160  ?
67
68# Needed for gfortran:
69#files/other_langs.patch:
70#+  --with-gmp=$DEST_ROOT \
71#+  --with-mpfr=$DEST_ROOT \
72#depends_lib             port:gmp port:mpfr
73
74#depends_lib             port:libiconv
75depends_lib             port:ld64 port:cctools
76depends_run             port:gcc_select
77depends_skip_archcheck  ld64 cctools
78
79use_configure no
80variant universal {}
81
82# Building universal with a ppc slice doesn't work (Tried on Leopard)
83if {${build_arch} == "i386" || ${build_arch} == "x86_64"} {
84    supported_archs i386 x86_64
85} elseif {${build_arch} == "ppc" || ${build_arch} == "ppc64"} {
86    supported_archs ppc ppc64
87}
88
89select.group    gcc
90select.file     ${filespath}/${name}
91
92set srcroot ${worksrcpath}
93set objroot ${workpath}/objroot
94set symroot ${workpath}/symroot
95
96# werror-*.patch                 : Fix compilation errors when building for x86_64
97# incpath.patch                  : Don't prepend the -isysroot option argument to the compiler's own search paths
98# driverdriver-num_infiles.patch : Fix linking with no input files (ie all static archives passed with -l...)
99# driverdriver-armcheck.patch    : Build fix for the driverdriver when arm support is not available (eg: Tiger)
100# tiger-Unwind_GetIPInfo.patch   : https://trac.macports.org/ticket/36226
101
102patchfiles-append \
103        werror-c-incpath.patch \
104        werror-local-alloc.patch \
105        incpath.patch \
106        driverdriver-num_infiles.patch \
107        driverdriver-armcheck.patch \
108        tiger-Unwind_GetIPInfo.patch
109
110# gcj fails to build:
111# gcc/java/lang.c: In function 'java_init':
112# gcc/java/lang.c:378: error: 'force_align_functions_log' undeclared (first use in this function)
113# gcc/java/lang.c:378: error: (Each undeclared identifier is reported only once
114# gcc/java/lang.c:378: error: for each function it appears in.)
115#
116# gfortrain fails to link due to functionality moving around in core in a way the module doesn't expect
117
118#extract {
119#       system "cd ${workpath} && tar xzf ${distpath}/${dfort}"
120#       system "cd ${workpath} && tar xzf ${distpath}/${djava}"
121#       file rename ${workpath}/gcc-${gcc_version} ${worksrcpath}
122#       system "cd ${workpath} && tar xjf ${distpath}/${dcore}"
123#}
124
125post-extract {
126    xinstall -W ${filespath} build_gcc ${worksrcpath}
127}
128
129post-patch {
130    # Install documentation in a MacPorts location
131    #reinplace "/^HTMLDIR=/ s:=.*$:=\"${prefix}/share/doc/${name}/html\":" ${worksrcpath}/build_gcc
132
133    # arch returns i386 even when we want x86_64
134    reinplace "/^BUILD=/ s:arch:echo ${build_arch}:" ${worksrcpath}/build_gcc
135
136    # This is set to isysroot/Developer/SDKs/MacOSX10.5.sdk mmacosx-version-min=10.5
137    # which is not always right.  Our CFLAGS should take care of this instead
138    reinplace "/^MULTILIB_EXTRA_OPTS/d" ${worksrcpath}/gcc/config/rs6000/t-darwin
139
140    # Brand our compiler
141    reinplace "/VERSUFFIX/s/)\"/) (MacPorts ${name} ${version}_${revision}${portvariants})\"/" \
142        ${worksrcpath}/gcc/version.c
143    reinplace "/bug_report_url/s|http:.*>|https://trac.macports.org/newticket>|" \
144        ${worksrcpath}/gcc/version.c
145
146    if {${build_arch} == "ppc"} {
147        reinplace "/^PPC_SYSROOT=/ s:=.*$:=/:" ${worksrcpath}/build_gcc
148    } elseif {[file exists ${developer_dir}/SDKs/MacOSX10.5.sdk]} {
149        reinplace "/^PPC_SYSROOT=/ s:=.*$:=${developer_dir}/SDKs/MacOSX10.5.sdk:" ${worksrcpath}/build_gcc
150    } elseif {[file exists ${developer_dir}/SDKs/MacOSX10.4u.sdk]} {
151        reinplace "/^PPC_SYSROOT=/ s:=.*$:=${developer_dir}/SDKs/MacOSX10.4u.sdk:" ${worksrcpath}/build_gcc
152    } elseif {[file exists ${developer_dir}/SDKs/MacOSX10.3.9.sdk]} {
153        reinplace "/^PPC_SYSROOT=/ s:=.*$:=${developer_dir}/SDKs/MacOSX10.3.9.sdk:" ${worksrcpath}/build_gcc
154    }
155
156    if {${os.major} < 9} {
157        reinplace "/vproc.h/d" ${worksrcpath}/gcc/libgcov.c
158    }
159
160    # Disable -Werror for our bootstrap gcc
161    if {[string match "*clang*" ${configure.compiler}]} {
162        reinplace "s:--enable-werror : :" ${worksrcpath}/build_gcc
163    }
164}
165
166compiler.cpath /usr/include
167compiler.library_path /usr/lib
168
169# TODO: Better use of MacPorts dependencies
170build.env \
171    LIBRARY_PATH="/usr/lib" \
172    CPATH="/usr/include" \
173    PATH="/bin:/usr/bin:/sbin:/usr/sbin" \
174    LANGUAGES="c,c++,objc,obj-c++" \
175    AR_FOR_TARGET=${prefix}/bin/ar \
176    AS_FOR_TARGET=${prefix}/bin/as \
177    LD_FOR_TARGET=${prefix}/bin/ld \
178    NM_FOR_TARGET=${prefix}/bin/nm \
179    OBJDUMP_FOR_TARGET=${prefix}/bin/objdump \
180    RANLIB_FOR_TARGET=${prefix}/bin/ranlib \
181    STRIP_FOR_TARGET=${prefix}/bin/strip \
182    DSYMUTIL_FOR_HOST=${prefix}/bin/dsymutil \
183    RANLIB_FOR_HOST=${prefix}/bin/ranlib \
184    STRIP_FOR_HOST=${prefix}/bin/strip \
185    OTOOL=${prefix}/bin/otool \
186    OTOOL64=${prefix}/bin/otool
187
188build.args-append \
189    CC="${configure.cc} -pipe -std=gnu89" \
190    PREFIX="${prefix}" \
191    SRCROOT="${srcroot}" \
192    OBJROOT="${objroot}" \
193    SYMROOT="${symroot}" \
194    DSTROOT="${destroot}" \
195    RC_NONARCH_CFLAGS="-pipe -std=gnu89" \
196    RC_OS="macos" \
197    RC_ARCHS="[get_canonical_archs]" \
198    RC_ProjectSourceVersion="[lindex [split ${version} .] 0]" \
199    RC_ProjectSourceSubversion="[lindex [split ${version} .] 1]"
200
201# On Tiger, we need apple-gcc42 to build llvm, which is needed for cctools
202variant bootstrap description {Variant to break a dependency cycle on Tiger by first building an apple-gcc42 using host ld and cctools} {
203#    depends_lib-delete      port:libiconv
204    depends_lib-delete      port:ld64 port:cctools
205
206    build.env \
207        LIBRARY_PATH="/usr/lib" \
208        CPATH="/usr/include" \
209        PATH="/bin:/usr/bin:/sbin:/usr/sbin" \
210        LANGUAGES="c,c++,objc,obj-c++"
211
212    pre-fetch {
213        if {([file exists ${prefix}/bin/ld] && [file exists ${prefix}/bin/as]) || ${os.major} > 8} {
214            ui_error "Please install this port without the bootstrap variant."
215            error "Please install this port without the bootstrap variant."
216        }
217    }
218}
219
220platform darwin 8 {
221    if {![file exists ${prefix}/bin/gcc-apple-4.2] &&
222        (![file exists ${prefix}/bin/ld] || ![file exists ${prefix}/bin/as])} {
223        default_variants +bootstrap
224    }
225}
226
227set build_targets {}
228
229if {${os.major} > 8 || ${os.arch} == "i386"} {
230    lappend build_targets i386
231}
232
233# Support for PPC was dropped in Darwin 11 (Mac OS X 10.7)
234if {${os.major} < 11} {
235    if {[file exists ${developer_dir}/SDKs/MacOSX10.3.9.sdk] ||
236            [file exists ${developer_dir}/SDKs/MacOSX10.4u.sdk] ||
237            [file exists ${developer_dir}/SDKs/MacOSX10.5.sdk] ||
238            ${build_arch} == "ppc"} {
239        lappend build_targets ppc
240    }
241}
242
243# TODO: arm?
244
245build.args-append \
246    TARGETS="${build_targets}"
247
248# Yes, use "install" ... the build system does make/install in one go
249# TODO: split the build_gcc script into two to better match MacPorts
250build.target install
251destroot {}
252post-destroot {
253    if {[string match "*i386*" ${build_targets}]} {
254        delete ${destroot}${prefix}/libexec/${name}/gcc/i686-apple-darwin${os.major}/${gcc_version}/as
255        ln -s ../../../../../bin/as ${destroot}${prefix}/libexec/${name}/gcc/i686-apple-darwin${os.major}/${gcc_version}/as
256        delete ${destroot}${prefix}/libexec/${name}/gcc/i686-apple-darwin${os.major}/${gcc_version}/ld
257        ln -s ../../../../../bin/ld ${destroot}${prefix}/libexec/${name}/gcc/i686-apple-darwin${os.major}/${gcc_version}/ld
258
259        # http://trac.macports.org/ticket/35770
260        delete  ${destroot}${prefix}/lib/${name}/gcc/i686-apple-darwin${os.major}/${gcc_version}/libstdc++.dylib
261        ln -s /usr/lib/libstdc++.6.dylib ${destroot}${prefix}/lib/${name}/gcc/i686-apple-darwin${os.major}/${gcc_version}/libstdc++.dylib
262    }
263
264    if {[string match "*ppc*" ${build_targets}]} {
265        delete ${destroot}${prefix}/libexec/${name}/gcc/powerpc-apple-darwin${os.major}/${gcc_version}/as
266        ln -s ../../../../../bin/as ${destroot}${prefix}/libexec/${name}/gcc/powerpc-apple-darwin${os.major}/${gcc_version}/as
267        delete ${destroot}${prefix}/libexec/${name}/gcc/powerpc-apple-darwin${os.major}/${gcc_version}/ld
268        ln -s ../../../../../bin/ld ${destroot}${prefix}/libexec/${name}/gcc/powerpc-apple-darwin${os.major}/${gcc_version}/ld
269
270        # http://trac.macports.org/ticket/35770
271        delete  ${destroot}${prefix}/lib/${name}/gcc/powerpc-apple-darwin${os.major}/${gcc_version}/libstdc++.dylib
272        ln -s /usr/lib/libstdc++.6.dylib ${destroot}${prefix}/lib/${name}/gcc/powerpc-apple-darwin${os.major}/${gcc_version}/libstdc++.dylib
273    }
274}
275
276livecheck.type          regex
277livecheck.url           http://opensource.apple.com/tarballs/gcc
278livecheck.regex         gcc-(\\d+(?:\\.\\d+)*)\\.tar
Note: See TracBrowser for help on using the repository browser.