[project @ 2004-11-20 16:02:41 by panne]
[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 export perl_dir=$old_ghc_top
48
49 #
50 # The mingw include, lib, and bin directories; all derived
51 # from ${mingw_top}.
52 #
53 export mingw_include=$mingw_top/include
54 export mingw_lib=$mingw_top/lib
55 export mingw_bin=$mingw_top/bin
56
57 # Check that we're in an OK place before starting to re-org
58 # the directory tree..
59 if ! [ -d bin/i386-unknown-mingw32 ] ; then
60   echo "Doesn't look as if I'm in the toplevel directory of a mingw tree"
61   echo "Usage: cd ghc-<version> ; ../distrib/prep-bin-dist-mingw"
62   exit 1;
63 fi;
64
65 echo "Removing configure script files...not needed"
66 rm -f config.guess config.sub configure configure.ac mkdirhier
67 rm -f Makefile-bin.in Makefile.in aclocal.m4 install-sh
68 rm -rf autom4te.cache
69
70 echo "rejig bin/"
71 mv bin/i386-unknown-mingw32/* bin/
72 rmdir bin/i386-unknown-mingw32
73 strip bin/ghc.exe
74
75 echo "rejig lib/"
76 mv lib/i386-unknown-mingw32/* .
77 rmdir lib/i386-unknown-mingw32
78 rmdir lib
79 mv ghc-asm.prl ghc-asm
80 mv ghc-split.prl ghc-split
81
82 echo "create gcc-lib/"
83 #
84 # A bunch of stuff gets lumped into gcc-lib:
85 #
86 #  - the gcc-lib/ + gcc-lib/include of the gcc you
87 #    intend to ship (normally located as 
88 #     lib/gcc-lib/mingw/<gcc version>/ in your mingw tree.)
89 #  - the contents of mingw/lib/ 
90 #  - ld.exe, as.exe, dlltool.exe, dllwrap.exe from mingw/bin
91 #    to gcc-lib/
92 #  - ar.exe from mingw/bin to bin/
93 #
94 mkdir gcc-lib
95 mkdir gcc-lib/include
96 cp $gcc_lib/* gcc-lib/
97 cp $gcc_lib/include/* gcc-lib/include/
98 cp $mingw_lib/* gcc-lib/
99 cp $mingw_bin/as.exe gcc-lib/
100 cp $mingw_bin/ld.exe gcc-lib/
101 cp $mingw_bin/ar.exe bin/
102 # Note: later versions of dlltool.exe depend on a bfd helper DLL.
103 cp $mingw_bin/dllwrap.exe gcc-lib/
104 cp $mingw_bin/dlltool.exe gcc-lib/
105 rm gcc-lib/f771.exe || echo "good - f771.exe not found"
106
107 echo "extra header files inside of include/"
108 #
109 # contains mingw/include
110 mkdir include/mingw
111 cp -Rf $mingw_include/* include/mingw
112 #
113 # g++-3/ subdir causes problems with installer tool (+ being a 
114 # troublesome character); leave out for now.
115 #rm -rf include/mingw/g++-3/ || echo "g++-3/ not there"
116 rm -rf include/mingw/c++/ || echo "c++/ not there"
117
118 echo "add gcc"
119 cp ${mingw_bin}/gcc.exe .
120 #cp ${mingw_bin}/gcc-2.exe gcc.exe
121
122 echo "copy in perl too"
123 cp ${perl_dir}/perl.exe .
124 cp ${perl_dir}/perl56.dll .
125
126 # For reasons unknown, duplicate copies of misc package files in share/
127 # (leave them be for now.)
128
129 echo "formatting documentation"
130 cp README README.txt
131 mv share doc
132 cp ../ghc/docs/users_guide/users_guide.pdf doc/ || 
133   (make -C ../ghc/docs/users_guide/ pdf ; cp ../ghc/docs/users_guide/users_guide.pdf doc/) || 
134   echo "No User Guide PDF doc found"
135 cp ../hslibs/doc/hslibs.pdf doc/ || 
136   (make -C ../hslibs/doc/ pdf ; cp ../hslibs/doc/hslibs.pdf doc/) ||
137   echo "No HSLIBS PDF doc found"