Add "Support SMP" and "RTS ways" to the compiler --info output
[ghc-hetmet.git] / distrib / prep-bin-dist-mingw
1 #!/bin/sh
2 #
3 # Modify a GHC binary distribution for the purposes of creating a
4 # mingw/win32 install tree.  The resulting tree is ready for packaging
5 # up in whatever form is convenient (MSI installer / tar bundle/ ..)
6 #
7 # To use:
8 #
9 #   $ cd <top of GHC build tree>
10 #   $ make binary-dist
11 #
12 # This script is called at the appropriate point during 'make binary-dist'.
13 # The result is a tarball at the top of your GHC build tree, named something
14 # like ghc-6.6.1-i386-unknown-mingw32.tar.bz2.
15
16 # User tweakables 
17 #    Note: you normally don't need to set any of these, the script
18 #    will try to figure them out for itself.  If the heuristics don't
19 #    work for whatever reason, you can override them using environment
20 #    variables, e.g.
21 #      mingw_top=<whatever> make binary-dist
22 #
23 #    - mingw_top   -- location of mingw distribution tree (usually c:/mingw)
24 #    - perl_dir    -- location of non-cygwin perl.exe
25 #    - gcc_lib     -- c:/mingw/lib/gcc/mingw32/3.4.2, or equivalent
26 #    - gcc_libexec -- c:/mingw/libexec/gcc/mingw32/3.4.2, or equivalent
27 #
28
29 #Directory where a (cygwin-free) perl binary resides.
30 if [ "${perl_dir}" == "" ]; then
31     for i in c:/ghc/*; do
32        if [ -e $i/perl.exe ]; then
33            perl_dir=$i
34            echo "Found perl.exe in $i"
35            break
36        fi
37     done
38     if [ "${perl_dir}" == "" ]; then
39         echo "Can't find perl.exe; please set \$perl_dir"
40         exit 1
41     fi
42 fi
43
44 if [ "${mingw_top}" == "" ]; then
45     if [ -d c:/mingw ]; then
46         mingw_top=c:/mingw
47         echo "Found mingw in $mingw_top"
48     else
49         echo "Can't find mingw; please set \$mingw_top"
50         exit 1
51     fi
52 fi
53
54 # The gcc-lib directory of the mingw tree you want to
55 # include with the binary dist.
56 if [ "x${gcc_lib}" == "x" ]; then
57     if [ -d "${mingw_top}/lib/gcc-lib/mingw32" ]; then
58         mingw_gcc_lib=${mingw_top}/lib/gcc-lib/mingw32
59     else
60         mingw_gcc_lib=${mingw_top}/lib/gcc/mingw32
61     fi
62     for i in `ls -r ${mingw_gcc_lib}`; do
63         if [ -d "${mingw_gcc_lib}/$i" ]; then
64             gcc_lib=${mingw_gcc_lib}/$i
65             echo "Found gcc lib in $gcc_lib"
66             break
67         fi
68     done
69     if [ "${gcc_lib}" == "" ]; then
70         echo "Can't find gcc lib files; please set \$gcc_lib"
71         exit 1
72     fi
73 fi
74     
75 # The gcc-lib directory of the mingw tree you want to
76 # include with the binary dist.
77 if [ "x${gcc_libexec}" == "x" ]; then
78     if [ -d "${mingw_top}/libexec/gcc-lib/mingw32" ]; then
79         mingw_gcc_libexec=${mingw_top}/libexec/gcc-lib/mingw32
80     else
81         mingw_gcc_libexec=${mingw_top}/libexec/gcc/mingw32
82     fi
83     for i in `ls -r ${mingw_gcc_libexec}`; do
84         if [ -d "${mingw_gcc_libexec}/$i" ]; then
85             gcc_libexec=${mingw_gcc_libexec}/$i
86             echo "Found gcc libexec in $gcc_libexec"
87             break
88         fi
89     done
90     if [ "${gcc_libexec}" == "" ]; then
91         echo "Can't find gcc libexec files; please set \$gcc_libexec"
92         exit 1
93     fi
94 fi
95     
96 #
97 # The mingw include, lib, and bin directories; all derived
98 # from ${mingw_top}.
99 #
100 if [ "x${mingw_include}" == "x" ]; then
101   export mingw_include=$mingw_top/include
102 fi
103 if [ "x${mingw_lib}" == "x" ]; then
104   export mingw_lib=$mingw_top/lib
105 fi
106 if [ "x${mingw_bin}" == "x" ]; then
107   export mingw_bin=$mingw_top/bin
108 fi
109
110 # Check that we're in an OK place before starting to re-org
111 # the directory tree..
112 if ! [ -d bin ] ; then
113   echo "Doesn't look as if I'm in the toplevel directory of a mingw tree"
114   echo "Usage: cd ghc-<version> ; ../distrib/prep-bin-dist-mingw"
115   exit 1;
116 fi;
117
118 echo "Removing configure script files...not needed"
119 rm -f config.guess config.sub configure configure.ac mkdirhier
120 rm -f Makefile-bin.in Makefile.in aclocal.m4 install-sh
121 rm -rf autom4te.cache
122
123 echo "strip ghc"
124 strip bin/ghc.exe
125
126 echo "create gcc-lib/"
127 #
128 # A bunch of stuff gets lumped into gcc-lib:
129 #
130 #  - the gcc-lib/ + gcc-lib/include of the gcc you
131 #    intend to ship (normally located as 
132 #     lib/gcc-lib/mingw/<gcc version>/ in your mingw tree.)
133 #  - the contents of mingw/lib/ 
134 #  - ld.exe, as.exe, dlltool.exe, dllwrap.exe from mingw/bin
135 #    to gcc-lib/
136 #  - ar.exe from mingw/bin to bin/
137 #
138 mkdir gcc-lib
139 mkdir gcc-lib/include
140 cp $gcc_lib/* gcc-lib/
141 cp $gcc_libexec/* gcc-lib/
142 cp $gcc_lib/include/* gcc-lib/include/
143 cp $mingw_lib/* gcc-lib/
144 cp $mingw_bin/as.exe gcc-lib/
145 cp $mingw_bin/ld.exe gcc-lib/
146 cp $mingw_bin/ar.exe bin/
147 cp $mingw_bin/windres.exe bin/
148 # Note: later versions of dlltool.exe depend on a bfd helper DLL.
149 cp $mingw_bin/dllwrap.exe gcc-lib/
150 cp $mingw_bin/dlltool.exe gcc-lib/
151 # Remove worthy, but unused tools
152 rm gcc-lib/f771.exe || echo "good - f771.exe not found"
153 rm gcc-lib/gnat1.exe || echo "good - gnat1.exe not found"
154 rm gcc-lib/jc1.exe || echo "good - jc1.exe not found"
155 rm gcc-lib/libgcj* || echo "good - libgcj libs not found"
156 rm gcc-lib/jvgenmain.exe || echo "good - jvgenmain.exe not found"
157
158 echo "extra header files inside of include/"
159 #
160 # contains mingw/include
161 mkdir include/mingw
162 cp -Rf $mingw_include/* include/mingw
163 #
164 # g++-3/ subdir causes problems with installer tool (+ being a 
165 # troublesome character); leave out for now.
166 #rm -rf include/mingw/g++-3/ || echo "g++-3/ not there"
167 #rm -rf include/mingw/c++/ || echo "c++/ not there"
168 rm -rf include/mingw/ddk/ || echo "ddk/ not there"
169 rm -rf include/mingw/gnu/ || echo "gnu/ not there"
170 rm -rf include/mingw/javax/ || echo "javax/ not there"
171 rm -rf include/mingw/java/ || echo "java/ not there"
172 rm -rf include/mingw/gcj/ || echo "gcj/ not there"
173
174 echo "add gcc"
175 cp ${mingw_bin}/gcc.exe .
176 #cp ${mingw_bin}/gcc-2.exe gcc.exe
177
178 echo "copy in perl too"
179 cp ${perl_dir}/perl.exe .
180 cp ${perl_dir}/perl56.dll .
181
182 # For reasons unknown, duplicate copies of misc package files in share/
183 # (leave them be for now.)
184
185 echo "formatting documentation"
186 unix2dos < README > README.txt
187 rm README
188
189 # Leave out pdf users_guide documentation for now; problematic to build with the versions
190 # of 'xsltproc' and 'fop' I've been able to lay my hands on.
191 #cp ../ghc/docs/users_guide/users_guide.pdf doc/ || 
192 #  (make -C ../ghc/docs/users_guide/ pdf ; cp ../ghc/docs/users_guide/users_guide.pdf doc/) || 
193 #  echo "No User Guide PDF doc found"
194 #cp ../hslibs/doc/hslibs.pdf doc/ || 
195 #  (make -C ../hslibs/doc/ pdf ; cp ../hslibs/doc/hslibs.pdf doc/) ||
196 #  echo "No HSLIBS PDF doc found"