additions from Reilly Hayes
[ghc-hetmet.git] / distrib / prep-bin-dist-mingw
1 #!/bin/sh
2 #
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/ ..)
7 #
8 # To use:
9 #
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
14 #
15 #  * - making sure you've initially set BIN_DIST=1 in 
16 #      your build.mk ...
17
18 # User tweakables 
19 #   (settable via environment variables, e.g.,
20 #      mingw_top=<whatever> ../distrib/prep-bin-dist-mingw
21 #   )
22 #
23 #    - mingw_top   -- location of mingw distribution tree
24 #    - old_ghc_top -- top of existing GHC binary diste tree
25 #                     (needed just to copy along perl binary.)
26 #
27 #    - gcc_version -- what gcc version your mingw tree uses.
28 #
29 #
30 if [ "x${old_ghc_top}" == "x" ]; then
31     export old_ghc_top=c:/ghc/ghc-6.2.1
32 fi
33 if [ "x${mingw_top}" == "x" ]; then
34  export mingw_top=c:/mingw3
35 fi
36
37 # The gcc-lib directory of the mingw tree you want to
38 # include with the binary dist.
39 if [ "x${gcc_version}" == "x" ]; then
40   # The default (with mingw3)
41   export gcc_lib=$mingw_top/lib/gcc-lib/mingw32/3.2.3
42 else
43   export gcc_lib=$mingw_top/lib/gcc-lib/mingw32/${gcc_version}
44 fi
45
46 #Directory where a (cygwin-free) perl binary resides.
47 if [ "x${perl_dir}" == "x" ]; then
48   export perl_dir=$old_ghc_top
49 fi
50
51 #
52 # The mingw include, lib, and bin directories; all derived
53 # from ${mingw_top}.
54 #
55 if [ "x${mingw_include}" == "x" ]; then
56   export mingw_include=$mingw_top/include
57 fi
58 if [ "x${mingw_lib}" == "x" ]; then
59   export mingw_lib=$mingw_top/lib
60 fi
61 if [ "x${mingw_bin}" == "x" ]; then
62   export mingw_bin=$mingw_top/bin
63 fi
64
65 # Check that we're in an OK place before starting to re-org
66 # the directory tree..
67 if ! [ -d bin/i386-unknown-mingw32 ] ; then
68   echo "Doesn't look as if I'm in the toplevel directory of a mingw tree"
69   echo "Usage: cd ghc-<version> ; ../distrib/prep-bin-dist-mingw"
70   exit 1;
71 fi;
72
73 echo "Removing configure script files...not needed"
74 rm -f config.guess config.sub configure configure.ac mkdirhier
75 rm -f Makefile-bin.in Makefile.in aclocal.m4 install-sh
76 rm -rf autom4te.cache
77
78 echo "rejig bin/"
79 mv bin/i386-unknown-mingw32/* bin/
80 rmdir bin/i386-unknown-mingw32
81 strip bin/ghc.exe
82
83 echo "rejig lib/"
84 mv lib/i386-unknown-mingw32/* .
85 rmdir lib/i386-unknown-mingw32
86 rmdir lib
87 mv ghc-asm.prl ghc-asm
88 mv ghc-split.prl ghc-split
89
90 echo "create gcc-lib/"
91 #
92 # A bunch of stuff gets lumped into gcc-lib:
93 #
94 #  - the gcc-lib/ + gcc-lib/include of the gcc you
95 #    intend to ship (normally located as 
96 #     lib/gcc-lib/mingw/<gcc version>/ in your mingw tree.)
97 #  - the contents of mingw/lib/ 
98 #  - ld.exe, as.exe, dlltool.exe, dllwrap.exe from mingw/bin
99 #    to gcc-lib/
100 #  - ar.exe from mingw/bin to bin/
101 #
102 mkdir gcc-lib
103 mkdir gcc-lib/include
104 cp $gcc_lib/* gcc-lib/
105 cp $gcc_lib/include/* gcc-lib/include/
106 cp $mingw_lib/* gcc-lib/
107 cp $mingw_bin/as.exe gcc-lib/
108 cp $mingw_bin/ld.exe gcc-lib/
109 cp $mingw_bin/ar.exe bin/
110 # Note: later versions of dlltool.exe depend on a bfd helper DLL.
111 cp $mingw_bin/dllwrap.exe gcc-lib/
112 cp $mingw_bin/dlltool.exe gcc-lib/
113 rm gcc-lib/f771.exe || echo "good - f771.exe not found"
114
115 echo "extra header files inside of include/"
116 #
117 # contains mingw/include
118 mkdir include/mingw
119 cp -Rf $mingw_include/* include/mingw
120 #
121 # g++-3/ subdir causes problems with installer tool (+ being a 
122 # troublesome character); leave out for now.
123 #rm -rf include/mingw/g++-3/ || echo "g++-3/ not there"
124 rm -rf include/mingw/c++/ || echo "c++/ not there"
125 rm -rf include/mingw/ddk/ || echo "ddk/ not there"
126 rm -rf include/mingw/gnu/ || echo "gnu/ not there"
127 rm -rf include/mingw/javax/ || echo "javax/ not there"
128 rm -rf include/mingw/java/ || echo "java/ not there"
129 rm -rf include/mingw/gcj/ || echo "gcj/ not there"
130
131 echo "add gcc"
132 cp ${mingw_bin}/gcc.exe .
133 #cp ${mingw_bin}/gcc-2.exe gcc.exe
134
135 echo "copy in perl too"
136 cp ${perl_dir}/perl.exe .
137 cp ${perl_dir}/perl56.dll .
138
139 # For reasons unknown, duplicate copies of misc package files in share/
140 # (leave them be for now.)
141
142 echo "formatting documentation"
143 cp README README.txt
144 mv share doc
145
146 # Leave out pdf users_guide documentation for now; problematic to build with the versions
147 # of 'xsltproc' and 'fop' I've been able to lay my hands on.
148 #cp ../ghc/docs/users_guide/users_guide.pdf doc/ || 
149 #  (make -C ../ghc/docs/users_guide/ pdf ; cp ../ghc/docs/users_guide/users_guide.pdf doc/) || 
150 #  echo "No User Guide PDF doc found"
151 #cp ../hslibs/doc/hslibs.pdf doc/ || 
152 #  (make -C ../hslibs/doc/ pdf ; cp ../hslibs/doc/hslibs.pdf doc/) ||
153 #  echo "No HSLIBS PDF doc found"