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

Last change on this file was 151945, checked in by ryandesign@…, 15 months ago

apple-gcc42: requires Xcode 2.5 on Tiger (#48178)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 11.7 KB
Line 
1# $Id: Portfile 151945 2016-08-24 17:46:30Z ryandesign@macports.org $
2
3PortSystem 1.0
4PortGroup select 1.0
5PortGroup xcodeversion 1.0
6
7name                    apple-gcc42
8version                 5666.3
9set gcc_version         4.2.1
10revision                15
11categories              lang
12platforms               darwin
13license                 {GPL-2+ Permissive}
14maintainers             jeremyhu openmaintainer
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-v2.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-v2.patch \
44                    rmd160  f33804c6f04e853a6248bf4941f4a0ace1e3f30f \
45                    sha256  0f22916b8b1c96bafaccbb17b4350530d4ae903475ae934efe76a26b9c35e03f \
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
74depends_run             port:gcc_select
75
76use_configure no
77variant universal {}
78
79minimum_xcodeversions   {8 2.5}
80
81if {${os.platform} eq "darwin" && ${os.major} > 15} {
82    depends_lib
83    depends_run
84    archive_sites
85    pre-fetch {
86        ui_error "${name} is not supported on OS X versions newer than El Capitan."
87        return -code error {unsupported platform}
88    }
89}
90
91# Building universal with a ppc slice doesn't work (Tried on Leopard)
92if {${build_arch} eq "i386" || ${build_arch} eq "x86_64"} {
93    supported_archs i386 x86_64
94} elseif {${build_arch} eq "ppc" || ${build_arch} eq "ppc64"} {
95    supported_archs ppc ppc64
96}
97
98select.group    gcc
99select.file     ${filespath}/${name}
100
101set srcroot ${worksrcpath}
102set objroot ${workpath}/objroot
103set symroot ${workpath}/symroot
104
105# werror-*.patch                     : Fix compilation errors when building for x86_64
106# incpath.patch                      : Don't prepend the -isysroot option argument to the compiler's own search paths
107# driverdriver-num_infiles.patch     : Fix linking with no input files (ie all static archives passed with -l...)
108# driverdriver-armcheck.patch        : Build fix for the driverdriver when arm support is not available (eg: Tiger)
109# tiger-Unwind_GetIPInfo.patch       : https://trac.macports.org/ticket/36226
110# remove-kernel-version-check.patch  : Don't complain about Yosemite and later (#45449)
111# version-min.patch                  : Interpret OS X and iOS versions correctly (#43978, #45449)
112# autogen.patch                      : Update to work with modern AutoGen (necessary to create fixincludes.patch)
113# fixincludes.patch                  : Stub out unrecognized macros in system headers (#45449)
114
115patchfiles-append \
116        werror-c-incpath.patch \
117        werror-local-alloc.patch \
118        incpath.patch \
119        driverdriver-num_infiles.patch \
120        driverdriver-armcheck.patch \
121        tiger-Unwind_GetIPInfo.patch \
122        remove-kernel-version-check.patch \
123        version-min.patch \
124        autogen.patch \
125        fixincludes.patch
126
127# gcj fails to build:
128# gcc/java/lang.c: In function 'java_init':
129# gcc/java/lang.c:378: error: 'force_align_functions_log' undeclared (first use in this function)
130# gcc/java/lang.c:378: error: (Each undeclared identifier is reported only once
131# gcc/java/lang.c:378: error: for each function it appears in.)
132#
133# gfortrain fails to link due to functionality moving around in core in a way the module doesn't expect
134
135#extract {
136#       system "cd ${workpath} && tar xzf ${distpath}/${dfort}"
137#       system "cd ${workpath} && tar xzf ${distpath}/${djava}"
138#       file rename ${workpath}/gcc-${gcc_version} ${worksrcpath}
139#       system "cd ${workpath} && tar xjf ${distpath}/${dcore}"
140#}
141
142post-extract {
143    xinstall -W ${filespath} build_gcc ${worksrcpath}
144}
145
146post-patch {
147    # Install documentation in a MacPorts location
148    #reinplace "/^HTMLDIR=/ s:=.*$:=\"${prefix}/share/doc/${name}/html\":" ${worksrcpath}/build_gcc
149
150    # arch returns i386 even when we want x86_64
151    reinplace "/^BUILD=/ s:arch:echo ${build_arch}:" ${worksrcpath}/build_gcc
152
153    # This is set to isysroot/Developer/SDKs/MacOSX10.5.sdk mmacosx-version-min=10.5
154    # which is not always right.  Our CFLAGS should take care of this instead
155    reinplace "/^MULTILIB_EXTRA_OPTS/d" ${worksrcpath}/gcc/config/rs6000/t-darwin
156
157    # Brand our compiler
158    reinplace "/VERSUFFIX/s/)\"/) (MacPorts ${name} ${version}_${revision}${portvariants})\"/" \
159        ${worksrcpath}/gcc/version.c
160    reinplace "/bug_report_url/s|http:.*>|https://trac.macports.org/newticket>|" \
161        ${worksrcpath}/gcc/version.c
162
163    if {${build_arch} eq "ppc"} {
164        reinplace "/^PPC_SYSROOT=/ s:=.*$:=/:" ${worksrcpath}/build_gcc
165    } elseif {[file exists ${developer_dir}/SDKs/MacOSX10.5.sdk]} {
166        reinplace "/^PPC_SYSROOT=/ s:=.*$:=${developer_dir}/SDKs/MacOSX10.5.sdk:" ${worksrcpath}/build_gcc
167    } elseif {[file exists ${developer_dir}/SDKs/MacOSX10.4u.sdk]} {
168        reinplace "/^PPC_SYSROOT=/ s:=.*$:=${developer_dir}/SDKs/MacOSX10.4u.sdk:" ${worksrcpath}/build_gcc
169    } elseif {[file exists ${developer_dir}/SDKs/MacOSX10.3.9.sdk]} {
170        reinplace "/^PPC_SYSROOT=/ s:=.*$:=${developer_dir}/SDKs/MacOSX10.3.9.sdk:" ${worksrcpath}/build_gcc
171    }
172
173    if {${os.major} < 9} {
174        reinplace "/vproc.h/d" ${worksrcpath}/gcc/libgcov.c
175    }
176
177    # Disable -Werror for our bootstrap gcc
178    if {[string match "*clang*" ${configure.compiler}]} {
179        reinplace "s:--enable-werror : :" ${worksrcpath}/build_gcc
180    }
181}
182
183compiler.cpath /usr/include
184compiler.library_path /usr/lib
185
186platform darwin 8 {
187    if {![file exists ${prefix}/bin/gcc-apple-4.2]} {
188        configure.compiler gcc-4.0
189        if {![file exists ${prefix}/bin/ld] || ![file exists ${prefix}/bin/as]} {
190            default_variants +bootstrap
191        }
192    }
193}
194
195build.env \
196    PATH="/bin:/usr/bin:/sbin:/usr/sbin" \
197    LANGUAGES="c,c++,objc,obj-c++"
198
199if {![variant_isset bootstrap]} {
200    #depends_lib-append              port:libiconv
201    depends_lib-append              port:ld64 port:cctools
202    depends_skip_archcheck-append   ld64 cctools
203   
204    # TODO: Better use of MacPorts dependencies
205    build.env-append \
206        AR_FOR_TARGET=${prefix}/bin/ar \
207        AS_FOR_TARGET=${prefix}/bin/as \
208        LD_FOR_TARGET=${prefix}/bin/ld \
209        NM_FOR_TARGET=${prefix}/bin/nm \
210        OBJDUMP_FOR_TARGET=${prefix}/bin/objdump \
211        RANLIB_FOR_TARGET=${prefix}/bin/ranlib \
212        STRIP_FOR_TARGET=${prefix}/bin/strip \
213        DSYMUTIL_FOR_HOST=${prefix}/bin/dsymutil \
214        RANLIB_FOR_HOST=${prefix}/bin/ranlib \
215        STRIP_FOR_HOST=${prefix}/bin/strip \
216        OTOOL=${prefix}/bin/otool \
217        OTOOL64=${prefix}/bin/otool
218}
219
220build.args-append \
221    CC="${configure.cc} -pipe -std=gnu89" \
222    PREFIX="${prefix}" \
223    SRCROOT="${srcroot}" \
224    OBJROOT="${objroot}" \
225    SYMROOT="${symroot}" \
226    DSTROOT="${destroot}" \
227    RC_NONARCH_CFLAGS="-pipe -std=gnu89" \
228    RC_OS="macos" \
229    RC_ARCHS="[get_canonical_archs]" \
230    RC_ProjectSourceVersion="[lindex [split ${version} .] 0]" \
231    RC_ProjectSourceSubversion="[lindex [split ${version} .] 1]"
232
233# On Tiger, we need apple-gcc42 to build ld64, which is needed for cctools
234variant bootstrap description {Variant to break a dependency cycle on Tiger by first building an apple-gcc42 using host ld and cctools} {
235    if {([file exists ${prefix}/bin/ld] && [file exists ${prefix}/bin/as]) || ${os.major} > 8} {
236        pre-fetch {
237            ui_error "Please install this port without the bootstrap variant."
238            error "Please install this port without the bootstrap variant."
239        }
240    } else {
241        notes-append "
242Now please reinstall ${name} without the bootstrap variant by running:
243
244sudo port install ${name}
245
246This will ensure that ${name} uses MacPorts versions of cctools and ld64\
247which are newer than the ones included with Xcode and will work better\
248and prevent some ports from failing to build.
249"
250    }
251}
252
253set build_targets {}
254
255if {${os.major} > 8 || ${os.arch} eq "i386"} {
256    lappend build_targets i386
257}
258
259# Support for PPC was dropped in Darwin 11 (Mac OS X 10.7)
260# Additionally, we dropped support for PPC from MacPorts cctools on SnowLeopard
261if {${os.major} < 10} {
262    if {[file exists ${developer_dir}/SDKs/MacOSX10.3.9.sdk] ||
263            [file exists ${developer_dir}/SDKs/MacOSX10.4u.sdk] ||
264            [file exists ${developer_dir}/SDKs/MacOSX10.5.sdk] ||
265            ${build_arch} eq "ppc"} {
266        lappend build_targets ppc
267    }
268}
269
270# TODO: arm?
271
272build.args-append \
273    TARGETS="${build_targets}"
274
275# Yes, use "install" ... the build system does make/install in one go
276# TODO: split the build_gcc script into two to better match MacPorts
277build.target install
278destroot {}
279post-destroot {
280    if {[string match "*i386*" ${build_targets}]} {
281        delete ${destroot}${prefix}/libexec/${name}/gcc/i686-apple-darwin${os.major}/${gcc_version}/as
282        ln -s ../../../../../bin/as ${destroot}${prefix}/libexec/${name}/gcc/i686-apple-darwin${os.major}/${gcc_version}/as
283        delete ${destroot}${prefix}/libexec/${name}/gcc/i686-apple-darwin${os.major}/${gcc_version}/ld
284        ln -s ../../../../../bin/ld ${destroot}${prefix}/libexec/${name}/gcc/i686-apple-darwin${os.major}/${gcc_version}/ld
285
286        # http://trac.macports.org/ticket/35770
287        delete  ${destroot}${prefix}/lib/${name}/gcc/i686-apple-darwin${os.major}/${gcc_version}/libstdc++.dylib
288        ln -s /usr/lib/libstdc++.6.dylib ${destroot}${prefix}/lib/${name}/gcc/i686-apple-darwin${os.major}/${gcc_version}/libstdc++.dylib
289    }
290
291    if {[string match "*ppc*" ${build_targets}]} {
292        delete ${destroot}${prefix}/libexec/${name}/gcc/powerpc-apple-darwin${os.major}/${gcc_version}/as
293        ln -s ../../../../../bin/as ${destroot}${prefix}/libexec/${name}/gcc/powerpc-apple-darwin${os.major}/${gcc_version}/as
294        delete ${destroot}${prefix}/libexec/${name}/gcc/powerpc-apple-darwin${os.major}/${gcc_version}/ld
295        ln -s ../../../../../bin/ld ${destroot}${prefix}/libexec/${name}/gcc/powerpc-apple-darwin${os.major}/${gcc_version}/ld
296
297        # http://trac.macports.org/ticket/35770
298        delete  ${destroot}${prefix}/lib/${name}/gcc/powerpc-apple-darwin${os.major}/${gcc_version}/libstdc++.dylib
299        ln -s /usr/lib/libstdc++.6.dylib ${destroot}${prefix}/lib/${name}/gcc/powerpc-apple-darwin${os.major}/${gcc_version}/libstdc++.dylib
300    }
301}
302
303livecheck.type          regex
304livecheck.url           http://opensource.apple.com/tarballs/gcc
305livecheck.regex         gcc-(\\d+(?:\\.\\d+)*)\\.tar
Note: See TracBrowser for help on using the repository browser.