Stop treating -static as overriding -fPIC: they are distinct.
[lldb.git] / llgo / update_third_party.sh
1 #!/bin/sh -e
2
3 scriptpath=$(readlink -f "$0")
4 llgosrcdir=$(dirname "$scriptpath")
5 cd $llgosrcdir
6
7 gofrontendrepo=https://code.google.com/p/gofrontend
8 gofrontendrev=15a24202fa42
9
10 gccrepo=svn://gcc.gnu.org/svn/gcc/trunk
11 gccrev=219477
12
13 gotoolsrepo=https://go.googlesource.com/tools
14 gotoolsrev=d4e70101500b43ffe705d4c45e50dd4f1c8e3b2e
15
16 linerrepo=https://github.com/peterh/liner.git
17 linerrev=1bb0d1c1a25ed393d8feb09bab039b2b1b1fbced
18
19 tempdir=$(mktemp -d /tmp/update_third_party.XXXXXX)
20 gofrontenddir=$tempdir/gofrontend
21 gotoolsdir=$tempdir/go.tools
22 linerdir=third_party/liner
23
24 rm -rf third_party
25 mkdir -p third_party/gofrontend third_party/gotools
26
27 # --------------------- gofrontend ---------------------
28
29 hg clone -r $gofrontendrev $gofrontendrepo $gofrontenddir
30
31 cp -r $gofrontenddir/LICENSE $gofrontenddir/libgo third_party/gofrontend
32
33 # Apply a diff that eliminates use of the unnamed struct extension beyond what
34 # -fms-extensions supports.
35 (cd third_party/gofrontend && patch -p1) < libgo-noext.diff
36 # Apply a diff that disables testing of packages known to fail.
37 (cd third_party/gofrontend && patch -p1) < libgo-check-failures.diff
38 find third_party/gofrontend -name '*.orig' -exec rm \{\} \;
39
40 # Remove GPL licensed files.
41 rm \
42   third_party/gofrontend/libgo/testsuite/libgo.testmain/testmain.exp \
43   third_party/gofrontend/libgo/testsuite/lib/libgo.exp \
44   third_party/gofrontend/libgo/testsuite/config/default.exp
45
46 # --------------------- gcc ---------------------
47
48 # Some dependencies are stored in the gcc repository.
49 # TODO(pcc): Ask iant about mirroring these dependencies into gofrontend.
50
51 for f in config-ml.in depcomp install-sh ltmain.sh missing ; do
52   svn cat -r $gccrev $gccrepo/$f > third_party/gofrontend/$f
53 done
54
55 mkdir -p third_party/gofrontend/include third_party/gofrontend/libgcc
56
57 # Copy in our versions of GCC files.
58 cp include/dwarf2.h third_party/gofrontend/include/
59 cp include/filenames.h third_party/gofrontend/include/
60 cp include/unwind-pe.h third_party/gofrontend/libgcc/
61
62 # Note: this expects the llgo source tree to be located at llvm/tools/llgo.
63 cp ../../autoconf/config.guess third_party/gofrontend/
64 cp ../../autoconf/config.sub third_party/gofrontend/
65
66 for d in libbacktrace libffi ; do
67   svn export -r $gccrev $gccrepo/$d third_party/gofrontend/$d
68 done
69
70 # Remove GPL licensed files, and files that confuse our license check.
71 rm \
72   third_party/gofrontend/libffi/ChangeLog \
73   third_party/gofrontend/libffi/doc/libffi.texi \
74   third_party/gofrontend/libffi/msvcc.sh \
75   third_party/gofrontend/libffi/testsuite/config/default.exp \
76   third_party/gofrontend/libffi/testsuite/libffi.call/call.exp \
77   third_party/gofrontend/libffi/testsuite/libffi.complex/complex.exp \
78   third_party/gofrontend/libffi/testsuite/libffi.go/go.exp \
79   third_party/gofrontend/libffi/testsuite/libffi.special/special.exp \
80   third_party/gofrontend/libffi/testsuite/lib/libffi.exp \
81   third_party/gofrontend/libffi/testsuite/lib/target-libpath.exp \
82   third_party/gofrontend/libffi/testsuite/lib/wrapper.exp
83
84 # The build requires these files to exist.
85 touch \
86   third_party/gofrontend/include/dwarf2.def \
87   third_party/gofrontend/libffi/doc/libffi.texi
88
89 # --------------------- go.tools ---------------------
90
91 git clone $gotoolsrepo $gotoolsdir
92 (cd $gotoolsdir && git checkout $gotoolsrev)
93
94 cp -r $gotoolsdir/LICENSE $gotoolsdir/go third_party/gotools
95
96 # Vendor the go.tools repository.
97 find third_party/gotools -name '*.go' | xargs sed -i -e \
98   's,"golang.org/x/tools/,"llvm.org/llgo/third_party/gotools/,g'
99
100 # --------------------- peterh/liner -----------------
101
102 git clone $linerrepo $linerdir
103 (cd $linerdir && git checkout $linerrev && rm -rf .git)
104
105 # --------------------- license check ---------------------
106
107 # We don't want any GPL licensed code without an autoconf/libtool
108 # exception, or any GPLv3 licensed code.
109
110 for i in `grep -lr 'General Public License' third_party` ; do
111   if grep -q 'configuration script generated by Autoconf, you may include it under' $i || \
112      grep -q 'is built using GNU Libtool, you may include this file under the' $i ; then
113     :
114   else
115     echo "$i: license check failed"
116     exit 1
117   fi
118 done
119
120 if grep -qr GPLv3 third_party ; then
121   echo "`grep -lr GPLv3 third_party`: license check failed"
122   exit 1
123 fi
124
125 rm -rf $tempdir