Adding TcGadt.lhs
[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_lib}" == "x" ]; then
40  if [ "x${gcc_version}" == "x" ]; then
41    # The default (with mingw3)
42    export gcc_lib=$mingw_top/lib/gcc-lib/mingw32/3.2.3
43  else
44    export gcc_lib=$mingw_top/lib/gcc-lib/mingw32/${gcc_version}
45  fi
46 fi
47 if [ "x${gcc_libexec}" == "x" ]; then
48  if [ "x${gcc_version}" == "x" ]; then
49    # The default (with mingw3)
50    export gcc_libexec=$mingw_top/lib/gcc-lib/mingw32/3.2.3
51  else
52    if [ -d $mingw_top/lib/gcc-lib/mingw32/${gcc_version} ]; then
53      export gcc_libexec=$mingw_top/lib/gcc-lib/mingw32/${gcc_version}
54    elif [ -d $mingw_top/libexec/gcc/mingw32/${gcc_version} ]; then
55      export gcc_libexec=$mingw_top/libexec/gcc/mingw32/${gcc_version}
56    else
57      echo "WARNING: Unable to determine location of your gcc 'libexec' directory"
58      export gcc_libexec=$mingw_top/lib/gcc-lib/mingw32/${gcc_version}
59    fi
60  fi
61 fi
62
63 #Directory where a (cygwin-free) perl binary resides.
64 if [ "x${perl_dir}" == "x" ]; then
65   export perl_dir=$old_ghc_top
66 fi
67
68 #
69 # The mingw include, lib, and bin directories; all derived
70 # from ${mingw_top}.
71 #
72 if [ "x${mingw_include}" == "x" ]; then
73   export mingw_include=$mingw_top/include
74 fi
75 if [ "x${mingw_lib}" == "x" ]; then
76   export mingw_lib=$mingw_top/lib
77 fi
78 if [ "x${mingw_bin}" == "x" ]; then
79   export mingw_bin=$mingw_top/bin
80 fi
81
82 # Check that we're in an OK place before starting to re-org
83 # the directory tree..
84 if ! [ -d bin/i386-unknown-mingw32 ] ; then
85   echo "Doesn't look as if I'm in the toplevel directory of a mingw tree"
86   echo "Usage: cd ghc-<version> ; ../distrib/prep-bin-dist-mingw"
87   exit 1;
88 fi;
89
90 echo "Removing configure script files...not needed"
91 rm -f config.guess config.sub configure configure.ac mkdirhier
92 rm -f Makefile-bin.in Makefile.in aclocal.m4 install-sh
93 rm -rf autom4te.cache
94
95 echo "rejig bin/"
96 mv bin/i386-unknown-mingw32/* bin/
97 rmdir bin/i386-unknown-mingw32
98 strip bin/ghc.exe
99
100 echo "rejig lib/"
101 mv lib/i386-unknown-mingw32/* .
102 rmdir lib/i386-unknown-mingw32
103 rmdir lib
104 mv ghc-asm.prl ghc-asm
105 mv ghc-split.prl ghc-split
106
107 echo "create gcc-lib/"
108 #
109 # A bunch of stuff gets lumped into gcc-lib:
110 #
111 #  - the gcc-lib/ + gcc-lib/include of the gcc you
112 #    intend to ship (normally located as 
113 #     lib/gcc-lib/mingw/<gcc version>/ in your mingw tree.)
114 #  - the contents of mingw/lib/ 
115 #  - ld.exe, as.exe, dlltool.exe, dllwrap.exe from mingw/bin
116 #    to gcc-lib/
117 #  - ar.exe from mingw/bin to bin/
118 #
119 mkdir gcc-lib
120 mkdir gcc-lib/include
121 cp $gcc_lib/* gcc-lib/
122 cp $gcc_libexec/* gcc-lib/
123 cp $gcc_lib/include/* gcc-lib/include/
124 cp $mingw_lib/* gcc-lib/
125 cp $mingw_bin/as.exe gcc-lib/
126 cp $mingw_bin/ld.exe gcc-lib/
127 cp $mingw_bin/ar.exe bin/
128 # Note: later versions of dlltool.exe depend on a bfd helper DLL.
129 cp $mingw_bin/dllwrap.exe gcc-lib/
130 cp $mingw_bin/dlltool.exe gcc-lib/
131 # Remove worthy, but unused tools
132 rm gcc-lib/f771.exe || echo "good - f771.exe not found"
133 rm gcc-lib/gnat1.exe || echo "good - gnat1.exe not found"
134 rm gcc-lib/jc1.exe || echo "good - jc1.exe not found"
135 rm gcc-lib/libgcj* || echo "good - libgcj libs not found"
136 rm gcc-lib/jvgenmain.exe || echo "good - jvgenmain.exe not found"
137
138 echo "extra header files inside of include/"
139 #
140 # contains mingw/include
141 mkdir include/mingw
142 cp -Rf $mingw_include/* include/mingw
143 #
144 # g++-3/ subdir causes problems with installer tool (+ being a 
145 # troublesome character); leave out for now.
146 #rm -rf include/mingw/g++-3/ || echo "g++-3/ not there"
147 rm -rf include/mingw/c++/ || echo "c++/ not there"
148 rm -rf include/mingw/ddk/ || echo "ddk/ not there"
149 rm -rf include/mingw/gnu/ || echo "gnu/ not there"
150 rm -rf include/mingw/javax/ || echo "javax/ not there"
151 rm -rf include/mingw/java/ || echo "java/ not there"
152 rm -rf include/mingw/gcj/ || echo "gcj/ not there"
153
154 echo "add gcc"
155 cp ${mingw_bin}/gcc.exe .
156 #cp ${mingw_bin}/gcc-2.exe gcc.exe
157
158 echo "copy in perl too"
159 cp ${perl_dir}/perl.exe .
160 cp ${perl_dir}/perl56.dll .
161
162 # For reasons unknown, duplicate copies of misc package files in share/
163 # (leave them be for now.)
164
165 echo "formatting documentation"
166 cp README README.txt
167 mv share doc
168
169 # Leave out pdf users_guide documentation for now; problematic to build with the versions
170 # of 'xsltproc' and 'fop' I've been able to lay my hands on.
171 #cp ../ghc/docs/users_guide/users_guide.pdf doc/ || 
172 #  (make -C ../ghc/docs/users_guide/ pdf ; cp ../ghc/docs/users_guide/users_guide.pdf doc/) || 
173 #  echo "No User Guide PDF doc found"
174 #cp ../hslibs/doc/hslibs.pdf doc/ || 
175 #  (make -C ../hslibs/doc/ pdf ; cp ../hslibs/doc/hslibs.pdf doc/) ||
176 #  echo "No HSLIBS PDF doc found"