Ticket #28171: Portfile

File Portfile, 8.5 KB (added by stevecheckoway (Stephen Checkoway), 13 years ago)
Line 
1PortSystem                      1.0
2name                            msp430-gcc
3version                         4.4.5
4
5# Parameters for this port.
6set crossgcc-target             msp430
7set default-languages           --enable-languages=c,c++
8
9description                     gcc cross-compilers for msp430
10long_description                GNU compilers collection (c and c++) for msp430.
11homepage                        http://mspgcc.sourceforge.net/
12platforms                       darwin
13categories                      cross devel
14maintainers                     cs.ucsd.edu:s
15master_sites                    gnu:gcc/gcc-${version}/
16distfiles                       gcc-${version}.tar.bz2
17worksrcdir                      gcc-${version}
18
19# All cross ports violate the mtree layout.
20destroot.violate_mtree          yes
21
22# Download everything to gcc/
23dist_subdir                     gcc
24
25depends_lib                     bin:${crossgcc-target}-ar:${crossgcc-target}-binutils \
26                                bin:${crossgcc-target}-as:${crossgcc-target}-binutils \
27                                bin:${crossgcc-target}-ld:${crossgcc-target}-binutils \
28                                bin:${crossgcc-target}-nm:${crossgcc-target}-binutils \
29                                bin:${crossgcc-target}-ranlib:${crossgcc-target}-binutils \
30                                port:gmp \
31                                port:mpfr
32depends_build                   bin:msgfmt:gettext
33
34# gcc is .bz2.
35use_bzip2                       yes
36checksums                       md5     44b3192c4c584b9be5243d9e8e7e0ed1 \
37                                sha1    2b1427a932a620c909d74f1e4821ed90c90fd350 \
38                                rmd160  87d6fa77d50f23a3359e24bf5b0ddfafa7088478
39
40# Since we don't build gcc and binutils at the same time, gcc's Makefile will try to transform
41# program names as gcc's name (add -${version} with ${version} being the version of gcc).
42# But it won't work because binutils binaries don't have the ${version} suffix, and even if they
43# had, they would actually have the binutils' version suffix (and not gcc's version).
44# So let's tell gcc's Makefile not to do that mistake.
45
46set environment [list AR_FOR_TARGET=${crossgcc-target}-ar \
47                        AS_FOR_TARGET=${crossgcc-target}-as \
48                        LD_FOR_TARGET=${crossgcc-target}-ld \
49                        NM_FOR_TARGET=${crossgcc-target}-nm \
50                        RANLIB_FOR_TARGET=${crossgcc-target}-ranlib]
51
52
53# Build in a different directory, as advised in the README file.
54pre-configure   {
55        file mkdir "${workpath}/build"
56}
57configure.dir                   ${workpath}/build
58configure.cmd                   ${workpath}/gcc-${version}/configure
59configure.cc                    "cc -no-cpp-precomp"
60configure.env                   ${environment}
61configure.args                  --infodir='${prefix}/share/info' \
62                                --mandir='${prefix}/share/man' \
63                                --target=${crossgcc-target} \
64                                --program-prefix=${crossgcc-target}- \
65                                --with-included-gettext \
66                                --enable-obsolete \
67                                --disable-nls \
68                                --with-gxx-include-dir=${prefix}/${crossgcc-target}/include/c++/${version}/ \
69                                ${default-languages}
70if {$build_arch != "" && ${os.platform} == "darwin"} {
71    configure.cc_archflags
72    configure.cxx_archflags
73    configure.objc_archflags
74    configure.args-append       --build=${build_arch}-apple-darwin${os.major} \
75                                --host=${build_arch}-apple-darwin${os.major}
76}
77
78build.dir                       ${workpath}/build
79
80build.args                      ${environment}
81destroot.args                   ${environment}
82
83patchfiles                      patch-mspgcc-4.4.5.diff \
84                                patch-gcc-config.diff
85patch.pre_args                  -p1
86
87post-patch {
88        namespace eval crossgcc {}
89
90        # Fix the info pages and related stuff.
91        #       
92        # path: path to the doc directory (e.g. gas/doc/)
93        # makefile: path to Makefile.in (e.g. gas/doc/Makefile.in)
94        # name: name of the info page (e.g. as)
95        # suffix: suffix of the souce page (texinfo or texi)
96        proc crossgcc::fixinfo { path makefile name suffix } {
97                global crossgcc-target worksrcpath
98
99                # Fix the source
100                reinplace "s|setfilename ${name}.info|setfilename ${crossgcc-target}-${name}.info|g" \
101                        ${worksrcpath}/${path}/${name}.${suffix}
102                reinplace "s|(${name})|(${crossgcc-target}-${name})|g" \
103                        ${worksrcpath}/${path}/${name}.${suffix}
104                reinplace "s|@file{${name}}|@file{${crossgcc-target}-${name}}|g" \
105                        ${worksrcpath}/${path}/${name}.${suffix}
106               
107                # Fix the Makefile
108                reinplace "s| ${name}.info| ${crossgcc-target}-${name}.info|g" \
109                        ${worksrcpath}/${makefile}
110                reinplace "s|/${name}.info|/${crossgcc-target}-${name}.info|g" \
111                        ${worksrcpath}/${makefile}
112                reinplace "s|^${name}.info|${crossgcc-target}-${name}.info|g" \
113                        ${worksrcpath}/${makefile}
114                reinplace "s| ${name}.pod| ${crossgcc-target}-${name}.pod|g" \
115                        ${worksrcpath}/${makefile}
116                reinplace "s|/${name}.pod|/${crossgcc-target}-${name}.pod|g" \
117                        ${worksrcpath}/${makefile}
118                reinplace "s|^${name}.pod|${crossgcc-target}-${name}.pod|g" \
119                        ${worksrcpath}/${makefile}
120                reinplace "s| ${name}.${suffix}| ${crossgcc-target}-${name}.${suffix}|g" \
121                        ${worksrcpath}/${makefile}
122                reinplace "s|/${name}.${suffix}|/${crossgcc-target}-${name}.${suffix}|g" \
123                        ${worksrcpath}/${makefile}
124                reinplace "s|^${name}.${suffix}|${crossgcc-target}-${name}.${suffix}|g" \
125                        ${worksrcpath}/${makefile}
126               
127                # Rename the source
128                file rename ${worksrcpath}/${path}/${name}.${suffix} \
129                        ${worksrcpath}/${path}/${crossgcc-target}-${name}.${suffix}
130               
131                # Fix install-info's dir.
132                # (note: this may be effectless if there was no info dir to be fixed)
133                reinplace "s|--info-dir=\$(DESTDIR)\$(infodir)|--dir-file=\$(DESTDIR)\$(infodir)/${crossgcc-target}-gcc-dir|g" \
134                        "${worksrcpath}/${makefile}"
135        }
136
137        # Fix the gettext files and related stuff.
138        #       
139        # module: name of the module (e.g. gas)
140        proc crossgcc::fixgettext { module } {
141                global crossgcc-target worksrcpath
142
143                if { [ file exists "${worksrcpath}/${module}/Makefile.in" ] } {
144                        reinplace "s|@PACKAGE@|${crossgcc-target}-@PACKAGE@|g" \
145                                "${worksrcpath}/${module}/Makefile.in"
146                }
147                if { [ file exists "${worksrcpath}/${module}/doc/Makefile.in" ] } {
148                        reinplace "s|@PACKAGE@|${crossgcc-target}-@PACKAGE@|g" \
149                                "${worksrcpath}/${module}/doc/Makefile.in"
150                }
151                if { [ file exists "${worksrcpath}/${module}/po/Make-in" ] } {
152                        reinplace "s|@PACKAGE@|${crossgcc-target}-@PACKAGE@|g" \
153                                "${worksrcpath}/${module}/po/Make-in"
154                }
155        }
156
157        # gcc/doc/cpp.texi
158        crossgcc::fixinfo gcc/doc/ gcc/Makefile.in cpp texi
159
160        # gcc/doc/cppinternals.texi
161        crossgcc::fixinfo gcc/doc/ gcc/Makefile.in cppinternals texi
162
163        # gcc/doc/gcc.texi
164        crossgcc::fixinfo gcc/doc/ gcc/Makefile.in gcc texi
165
166        # gcc/doc/gccint.texi
167        crossgcc::fixinfo gcc/doc/ gcc/Makefile.in gccint texi
168
169        # gcc/java/gcj.texi
170        crossgcc::fixinfo gcc/java/ gcc/java/Make-lang.in gcj texi
171
172        # gettext stuff.
173        crossgcc::fixgettext gcc
174}
175
176pre-destroot {
177        # gcc needs the cross directory structure to be present
178        # in order to fill it during installation.
179        file mkdir "${destroot}${prefix}/${crossgcc-target}/bin"
180        file mkdir "${destroot}${prefix}/${crossgcc-target}/lib"
181}
182
183post-destroot {
184        namespace eval crossgcc {}
185
186        # Rename a man page if it exists.
187        #
188        # section: section of the man page (e.g. 1)
189        # manpage: name of the man page (e.g. cpp)
190        proc crossgcc::rename_man_page { section manpage } {
191                global crossgcc-target destroot prefix
192
193                set manpage_path "${destroot}${prefix}/share/man/man${section}/${manpage}.${section}"
194                if { [ file exists ${manpage_path} ] } {
195                        file rename ${manpage_path} \
196                                "${destroot}${prefix}/share/man/man${section}/${crossgcc-target}-${manpage}.${section}"
197                }
198        }
199
200        # Stuff I don't want (either because they're in the system
201        # or because they would conflict with other FSF ports)
202        # (it's easier for maintainability purposes to fix things here)
203
204        # aliases for locales (should be on the system)
205        file delete "${destroot}${prefix}/share/locale/locale.alias"
206       
207        # FSF propaganda (should already be there or would conflict)
208        file delete -force "${destroot}${prefix}/share/man/man7"
209
210        # (host) libiberty
211        file delete "${destroot}${prefix}/lib/libiberty.a"
212
213        # aliases for charsets (should already be there)
214        file delete "${destroot}${prefix}/lib/charset.alias"
215
216        # Remove c++filt which is provided by binutils
217        file delete "${destroot}${prefix}/bin/${crossgcc-target}-c++filt"
218       
219        # Remove man pages for tools that are not built as part of cross-gcc
220        file delete "${destroot}${prefix}/share/man/man1/rmic.1"
221        file delete "${destroot}${prefix}/share/man/man1/rmiregistry.1"
222        file delete "${destroot}${prefix}/share/man/man1/jv-convert.1"
223        file delete "${destroot}${prefix}/share/man/man1/gij.1"
224       
225        # For some reason, some man pages are not prefixed while they should have been
226        # (to avoid conflicting).
227        crossgcc::rename_man_page 1 cpp
228        crossgcc::rename_man_page 1 gcjh
229        crossgcc::rename_man_page 1 gcov
230        crossgcc::rename_man_page 1 jcf-dump
231        crossgcc::rename_man_page 1 jv-scan
232       
233        # There is a bug in gcc/Makefile::install-driver
234        # For cross compilers, $(GCC_INSTALL_NAME) is equal to
235        # $(target_noncanonical)-gcc-$(version)
236        # and hence the driver isn't installed.
237        xinstall -c "${workpath}/build/gcc/xgcc" \
238                "${destroot}${prefix}/bin/${crossgcc-target}-gcc-${version}"
239}
240
241livecheck.type  regex
242livecheck.url   http://gcc.gnu.org/releases.html
243livecheck.regex {<tr><td><a href="gcc-.*/">GCC (.*)</a></td>   <td>.*</td></tr>}