3 # Running 'binary-dist' gives us a tree which isn't quite right
4 # for the purposes of creating a mingw/win32 install tree.
5 # This script rejigs that tree. The resulting tree is ready for
6 # packaging up in whatever form convenient (MSI installer / tar bundle/ ..)
10 # foo$ cd <top of fptools build tree>
11 # foo$ make binary-dist Project=Ghc (*)
12 # foo$ cd ghc-<version>
13 # foo$ ../distrib/prep-bin-dist-mingw
15 # * - making sure you've initially set BIN_DIST=1 in
19 # Note: you normally don't need to set any of these, the script
20 # will try to figure them out for itself. If the heuristics don't
21 # work for whatever reason, you can override them using environment
23 # mingw_top=<whatever> ../distrib/prep-bin-dist-mingw
25 # - mingw_top -- location of mingw distribution tree (usually c:/mingw)
26 # - perl_dir -- location of non-cygwin perl.exe
27 # - gcc_lib -- c:/mingw/lib/gcc/mingw32/3.4.2, or equivalent
28 # - gcc_libexec -- c:/mingw/libexec/gcc/mingw32/3.4.2, or equivalent
31 #Directory where a (cygwin-free) perl binary resides.
32 if [ "${perl_dir}" == "" ]; then
34 if [ -e $i/perl.exe ]; then
36 echo "Found perl.exe in $i"
40 if [ "${perl_dir}" == "" ]; then
41 echo "Can't find perl.exe; please set \$perl_dir"
46 if [ "${mingw_top}" == "" ]; then
47 if [ -d c:/mingw ]; then
49 echo "Found mingw in $mingw_top"
51 echo "Can't find mingw; please set \$mingw_top"
56 # The gcc-lib directory of the mingw tree you want to
57 # include with the binary dist.
58 if [ "x${gcc_lib}" == "x" ]; then
59 if [ -d "${mingw_top}/lib/gcc-lib/mingw32" ]; then
60 mingw_gcc_lib=${mingw_top}/lib/gcc-lib/mingw32
62 mingw_gcc_lib=${mingw_top}/lib/gcc/mingw32
64 for i in `ls -r ${mingw_gcc_lib}`; do
65 if [ -d "${mingw_gcc_lib}/$i" ]; then
66 gcc_lib=${mingw_gcc_lib}/$i
67 echo "Found gcc lib in $gcc_lib"
71 if [ "${gcc_lib}" == "" ]; then
72 echo "Can't find gcc lib files; please set \$gcc_lib"
77 # The gcc-lib directory of the mingw tree you want to
78 # include with the binary dist.
79 if [ "x${gcc_libexec}" == "x" ]; then
80 if [ -d "${mingw_top}/libexec/gcc-lib/mingw32" ]; then
81 mingw_gcc_libexec=${mingw_top}/libexec/gcc-lib/mingw32
83 mingw_gcc_libexec=${mingw_top}/libexec/gcc/mingw32
85 for i in `ls -r ${mingw_gcc_libexec}`; do
86 if [ -d "${mingw_gcc_libexec}/$i" ]; then
87 gcc_libexec=${mingw_gcc_libexec}/$i
88 echo "Found gcc libexec in $gcc_libexec"
92 if [ "${gcc_libexec}" == "" ]; then
93 echo "Can't find gcc libexec files; please set \$gcc_libexec"
99 # The mingw include, lib, and bin directories; all derived
102 if [ "x${mingw_include}" == "x" ]; then
103 export mingw_include=$mingw_top/include
105 if [ "x${mingw_lib}" == "x" ]; then
106 export mingw_lib=$mingw_top/lib
108 if [ "x${mingw_bin}" == "x" ]; then
109 export mingw_bin=$mingw_top/bin
112 # Check that we're in an OK place before starting to re-org
113 # the directory tree..
114 if ! [ -d bin/i386-unknown-mingw32 ] ; then
115 echo "Doesn't look as if I'm in the toplevel directory of a mingw tree"
116 echo "Usage: cd ghc-<version> ; ../distrib/prep-bin-dist-mingw"
120 echo "Removing configure script files...not needed"
121 rm -f config.guess config.sub configure configure.ac mkdirhier
122 rm -f Makefile-bin.in Makefile.in aclocal.m4 install-sh
123 rm -rf autom4te.cache
126 mv bin/i386-unknown-mingw32/* bin/
127 rmdir bin/i386-unknown-mingw32
131 mv lib/i386-unknown-mingw32/include/* include/
132 rmdir lib/i386-unknown-mingw32/include
133 mv lib/i386-unknown-mingw32/* .
134 rmdir lib/i386-unknown-mingw32
136 mv ghc-asm.prl ghc-asm
137 mv ghc-split.prl ghc-split
139 echo "create gcc-lib/"
141 # A bunch of stuff gets lumped into gcc-lib:
143 # - the gcc-lib/ + gcc-lib/include of the gcc you
144 # intend to ship (normally located as
145 # lib/gcc-lib/mingw/<gcc version>/ in your mingw tree.)
146 # - the contents of mingw/lib/
147 # - ld.exe, as.exe, dlltool.exe, dllwrap.exe from mingw/bin
149 # - ar.exe from mingw/bin to bin/
152 mkdir gcc-lib/include
153 cp $gcc_lib/* gcc-lib/
154 cp $gcc_libexec/* gcc-lib/
155 cp $gcc_lib/include/* gcc-lib/include/
156 cp $mingw_lib/* gcc-lib/
157 cp $mingw_bin/as.exe gcc-lib/
158 cp $mingw_bin/ld.exe gcc-lib/
159 cp $mingw_bin/ar.exe bin/
160 # Note: later versions of dlltool.exe depend on a bfd helper DLL.
161 cp $mingw_bin/dllwrap.exe gcc-lib/
162 cp $mingw_bin/dlltool.exe gcc-lib/
163 # Remove worthy, but unused tools
164 rm gcc-lib/f771.exe || echo "good - f771.exe not found"
165 rm gcc-lib/gnat1.exe || echo "good - gnat1.exe not found"
166 rm gcc-lib/jc1.exe || echo "good - jc1.exe not found"
167 rm gcc-lib/libgcj* || echo "good - libgcj libs not found"
168 rm gcc-lib/jvgenmain.exe || echo "good - jvgenmain.exe not found"
170 echo "extra header files inside of include/"
172 # contains mingw/include
174 cp -Rf $mingw_include/* include/mingw
176 # g++-3/ subdir causes problems with installer tool (+ being a
177 # troublesome character); leave out for now.
178 #rm -rf include/mingw/g++-3/ || echo "g++-3/ not there"
179 rm -rf include/mingw/c++/ || echo "c++/ not there"
180 rm -rf include/mingw/ddk/ || echo "ddk/ not there"
181 rm -rf include/mingw/gnu/ || echo "gnu/ not there"
182 rm -rf include/mingw/javax/ || echo "javax/ not there"
183 rm -rf include/mingw/java/ || echo "java/ not there"
184 rm -rf include/mingw/gcj/ || echo "gcj/ not there"
187 cp ${mingw_bin}/gcc.exe .
188 #cp ${mingw_bin}/gcc-2.exe gcc.exe
190 echo "copy in perl too"
191 cp ${perl_dir}/perl.exe .
192 cp ${perl_dir}/perl56.dll .
194 # For reasons unknown, duplicate copies of misc package files in share/
195 # (leave them be for now.)
197 echo "formatting documentation"
201 # Leave out pdf users_guide documentation for now; problematic to build with the versions
202 # of 'xsltproc' and 'fop' I've been able to lay my hands on.
203 #cp ../ghc/docs/users_guide/users_guide.pdf doc/ ||
204 # (make -C ../ghc/docs/users_guide/ pdf ; cp ../ghc/docs/users_guide/users_guide.pdf doc/) ||
205 # echo "No User Guide PDF doc found"
206 #cp ../hslibs/doc/hslibs.pdf doc/ ||
207 # (make -C ../hslibs/doc/ pdf ; cp ../hslibs/doc/hslibs.pdf doc/) ||
208 # echo "No HSLIBS PDF doc found"