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

Last change on this file was 150303, checked in by jeremyhu@…, 12 months ago

llvm-gcc42: Update Sierra marketing name

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 9.5 KB
Line 
1# $Id: Portfile 150303 2016-07-15 08:40:34Z ryandesign@macports.org $
2
3PortSystem 1.0
4PortGroup select 1.0
5PortGroup compiler_blacklist_versions 1.0
6
7name                    llvm-gcc42
8version                 2336.11
9revision                3
10set gcc_version         4.2.1
11categories              lang
12platforms               darwin
13license                 {GPL-2+ Permissive}
14maintainers             jeremyhu
15description             llvm-gcc42 is a gcc compiler frontend for llvm
16long_description        llvm-gcc42 integrates the LLVM optimizers and code \
17                        generator with the GCC 4.2 parser. This allows LLVM to \
18                        compile languages supported by the GCC compiler \
19                        frontends, and provides high-fidelity drop-in \
20                        compatibility with version 4.2 of GCC.
21
22homepage                http://opensource.apple.com/
23master_sites            http://opensource.apple.com/tarballs/llvmgcc42/
24
25distname                llvmgcc42-${version}
26
27checksums               md5     046629f7b3ce59bcb32b5116d29c27cd \
28                        sha1    97b82b328780d1b4f261301dc084bb256172ee2a \
29                        rmd160  90e496dc075ebd3daa088f818e52e7ecbb4a182e
30
31depends_lib             port:ld64 port:cctools
32depends_run             port:gcc_select
33depends_skip_archcheck  ld64 cctools
34
35use_configure no
36variant universal {}
37
38supported_archs i386 x86_64
39
40if {${os.platform} eq "darwin" && ${os.major} > 15} {
41    depends_lib
42    depends_run
43    archive_sites
44    pre-fetch {
45        ui_error "${name} is not supported on macOS Sierra or newer."
46        return -code error {unsupported platform}
47    }
48}
49
50select.group    gcc
51select.file     ${filespath}/mp-llvm-gcc42
52
53set srcroot ${worksrcpath}
54set objroot ${workpath}/objroot
55set symroot ${workpath}/symroot
56
57# Don't compile with self
58compiler.blacklist-append macports-llvm-gcc-4.2
59
60# werror-*.patch                 : Fix compilation errors when building for x86_64
61# incpath.patch                  : Don't prepend the -isysroot option argument to the compiler's own search paths
62# driverdriver-num_infiles.patch : Fix linking with no input files (ie all static archives passed with -l...)
63# driverdriver-armcheck.patch    : Build fix for the driverdriver when arm support is not available (eg: Tiger)
64# deployment_target.patch        : Build fix to correctly get the OS version
65# remove-kernel-version-check.patch : Don't complain on Yosemite and later
66# version-min.patch              : Interpret OS X and iOS versions correctly
67# autogen.patch                  : Update to work with modern autogen (necessary to create fixincludes.patch)
68# fixincludes.patch              : Stub out unrecognized macros in system headers
69
70patchfiles-append \
71        werror-local-alloc.patch \
72        incpath.patch \
73        driverdriver-num_infiles.patch \
74        driverdriver-armcheck.patch \
75        deployment_target.patch \
76        remove-kernel-version-check.patch \
77        version-min.patch \
78        autogen.patch \
79        fixincludes.patch
80
81if {[string match *clang* ${configure.cc}]} {
82    patchfiles-append clang-optimization.patch
83}
84
85post-extract {
86    xinstall -W ${filespath} build_gcc ${worksrcpath}
87}
88
89post-patch {
90    # Set our deployment target
91    reinplace "s/@@DEPLOYMENT_TARGET@@/${macosx_deployment_target}/" \
92        ${worksrcpath}/llvmCore/Makefile.rules
93
94    # Install documentation in a MacPorts location
95    #reinplace "/^HTMLDIR=/ s:=.*$:=\"${prefix}/share/doc/${name}/html\":" ${worksrcpath}/build_gcc
96
97    # arch returns i386 even when we want x86_64
98    reinplace "/^BUILD=/ s:arch:echo ${build_arch}:" ${worksrcpath}/build_gcc
99
100    # This is set to isysroot/Developer/SDKs/MacOSX10.5.sdk mmacosx-version-min=10.5
101    # which is not always right.  Our CFLAGS should take care of this instead
102    reinplace "/^MULTILIB_EXTRA_OPTS/d" ${worksrcpath}/gcc/config/rs6000/t-darwin
103
104    # Brand our compiler
105    reinplace "/VERSUFFIX/s/)\"/) (MacPorts ${name} ${version}_${revision}${portvariants})\"/" \
106        ${worksrcpath}/gcc/version.c
107    reinplace "/bug_report_url/s|http:.*>|https://trac.macports.org/newticket>|" \
108        ${worksrcpath}/gcc/version.c
109
110    # Don't use the DEVELOPER_DIR variable
111    reinplace "s/DEVELOPER_DIR/MP_DEVELOPER_DIR/g" \
112        ${worksrcpath}/GNUmakefile \
113        ${worksrcpath}/llvmCore/utils/buildit/build_llvm
114
115    if {${build_arch} eq "ppc"} {
116        reinplace "/^PPC_SYSROOT=/ s:=.*$:=/:" ${worksrcpath}/build_gcc
117    } elseif {[file exists ${developer_dir}/SDKs/MacOSX10.5.sdk]} {
118        reinplace "/^PPC_SYSROOT=/ s:=.*$:=${developer_dir}/SDKs/MacOSX10.5.sdk:" ${worksrcpath}/build_gcc
119    } elseif {[file exists ${developer_dir}/SDKs/MacOSX10.4u.sdk]} {
120        reinplace "/^PPC_SYSROOT=/ s:=.*$:=${developer_dir}/SDKs/MacOSX10.4u.sdk:" ${worksrcpath}/build_gcc
121    } elseif {[file exists ${developer_dir}/SDKs/MacOSX10.3.9.sdk]} {
122        reinplace "/^PPC_SYSROOT=/ s:=.*$:=${developer_dir}/SDKs/MacOSX10.3.9.sdk:" ${worksrcpath}/build_gcc
123    }
124
125    if {${os.major} < 9} {
126        reinplace "/vproc.h/d" ${worksrcpath}/gcc/libgcov.c
127    }
128
129    # Disable -Werror for our bootstrap gcc
130    if {[string match "*clang*" ${configure.compiler}]} {
131        reinplace "s:--enable-werror : :" ${worksrcpath}/build_gcc
132    }
133
134    # ltmain.sh notes 'On all known operating systems, these are identical', and -module has gone
135    # away with Apple's clang-3.4
136    if {[string match *clang* ${configure.cc}]} {
137         reinplace "s:module:export_dynamic:" ${worksrcpath}/llvmCore/Makefile.rules
138         reinplace "s:-no-undefined::" ${worksrcpath}/llvmCore/tools/lto/Makefile
139    }
140}
141
142compiler.cpath /usr/include
143compiler.library_path /usr/lib
144
145# TODO: Better use of MacPorts dependencies
146build.env \
147    LIBRARY_PATH="/usr/lib" \
148    CPATH="/usr/include" \
149    PATH="/bin:/usr/bin:/sbin:/usr/sbin" \
150    LANGUAGES="c,c++,objc,obj-c++" \
151    AR_FOR_TARGET=${prefix}/bin/ar \
152    AS_FOR_TARGET=${prefix}/bin/as \
153    LD_FOR_TARGET=${prefix}/bin/ld \
154    NM_FOR_TARGET=${prefix}/bin/nm \
155    OBJDUMP_FOR_TARGET=${prefix}/bin/objdump \
156    RANLIB_FOR_TARGET=${prefix}/bin/ranlib \
157    STRIP_FOR_TARGET=${prefix}/bin/strip \
158    DSYMUTIL_FOR_HOST=${prefix}/bin/dsymutil \
159    RANLIB_FOR_HOST=${prefix}/bin/ranlib \
160    STRIP_FOR_HOST=${prefix}/bin/strip \
161    OTOOL=${prefix}/bin/otool \
162    OTOOL64=${prefix}/bin/otool
163
164build.args-append \
165    CC="${configure.cc} -pipe -std=gnu89" \
166    CXX="${configure.cxx} -pipe" \
167    PREFIX="${prefix}" \
168    SRCROOT="${srcroot}" \
169    OBJROOT="${objroot}" \
170    SYMROOT="${symroot}" \
171    DSTROOT="${destroot}" \
172    RC_NONARCH_CFLAGS="-pipe -std=gnu89" \
173    RC_OS="macos" \
174    RC_ARCHS="[get_canonical_archs]" \
175    RC_ProjectSourceVersion="[lindex [split ${version} .] 0]" \
176    RC_ProjectSourceSubversion="[lindex [split ${version} .] 1]"
177
178if {[string match "*clang*" ${configure.compiler}]} {
179    # Build fails using libc++
180
181    build.args-delete \
182        CXX="${configure.cxx} -pipe"
183
184    build.args-append \
185        CXX="${configure.cxx} -pipe -stdlib=libstdc++"
186}
187
188set build_targets {}
189
190if {${os.major} > 8 || ${os.arch} eq "i386"} {
191    lappend build_targets i386
192}
193
194# Support for PPC was dropped in Darwin 11 (Mac OS X 10.7)
195#if {${os.major} < 11} {
196#    if {[file exists ${developer_dir}/SDKs/MacOSX10.3.9.sdk] ||
197#            [file exists ${developer_dir}/SDKs/MacOSX10.4u.sdk] ||
198#            [file exists ${developer_dir}/SDKs/MacOSX10.5.sdk] ||
199#            ${build_arch} eq "ppc"} {
200#        lappend build_targets ppc
201#    }
202#}
203if {${os.major} < 11 && ${build_arch} eq "ppc"} {
204    lappend build_targets ppc
205}
206
207build.args-append \
208    TARGETS="${build_targets}"
209
210# Yes, use "install" ... the build system does make/install in one go
211# TODO: split the build_gcc script into two to better match MacPorts
212build.target install
213destroot {}
214post-destroot {
215    if {[string match "*i386*" ${build_targets}]} {
216        delete ${destroot}${prefix}/libexec/${name}/gcc/i686-apple-darwin${os.major}/${gcc_version}/as
217        ln -s ../../../../../bin/as ${destroot}${prefix}/libexec/${name}/gcc/i686-apple-darwin${os.major}/${gcc_version}/as
218        delete ${destroot}${prefix}/libexec/${name}/gcc/i686-apple-darwin${os.major}/${gcc_version}/ld
219        ln -s ../../../../../bin/ld ${destroot}${prefix}/libexec/${name}/gcc/i686-apple-darwin${os.major}/${gcc_version}/ld
220        delete ${destroot}${prefix}/libexec/${name}/gcc/i686-apple-darwin${os.major}/${gcc_version}/dsymutil
221
222        # http://trac.macports.org/ticket/35770
223        delete  ${destroot}${prefix}/lib/${name}/gcc/i686-apple-darwin${os.major}/${gcc_version}/libstdc++.dylib
224        ln -s /usr/lib/libstdc++.6.dylib ${destroot}${prefix}/lib/${name}/gcc/i686-apple-darwin${os.major}/${gcc_version}/libstdc++.dylib
225    }
226
227    if {[string match "*ppc*" ${build_targets}]} {
228        delete ${destroot}${prefix}/libexec/${name}/gcc/powerpc-apple-darwin${os.major}/${gcc_version}/as
229        ln -s ../../../../../bin/as ${destroot}${prefix}/libexec/${name}/gcc/powerpc-apple-darwin${os.major}/${gcc_version}/as
230        delete ${destroot}${prefix}/libexec/${name}/gcc/powerpc-apple-darwin${os.major}/${gcc_version}/ld
231        ln -s ../../../../../bin/ld ${destroot}${prefix}/libexec/${name}/gcc/powerpc-apple-darwin${os.major}/${gcc_version}/ld
232        delete ${destroot}${prefix}/libexec/${name}/gcc/powerpc-apple-darwin${os.major}/${gcc_version}/dsymutil
233
234        # http://trac.macports.org/ticket/35770
235        delete  ${destroot}${prefix}/lib/${name}/gcc/powerpc-apple-darwin${os.major}/${gcc_version}/libstdc++.dylib
236        ln -s /usr/lib/libstdc++.6.dylib ${destroot}${prefix}/lib/${name}/gcc/powerpc-apple-darwin${os.major}/${gcc_version}/libstdc++.dylib
237    }
238}
239
240livecheck.type          regex
241livecheck.url           [lindex ${master_sites} 0]
242livecheck.regex         llvmgcc42-(\\d+(?:\\.\\d+)*)\\.tar
Note: See TracBrowser for help on using the repository browser.