rejig library include/ files
[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/include/* include/ 
102 rmdir lib/i386-unknown-mingw32/include
103 mv lib/i386-unknown-mingw32/* .
104 rmdir lib/i386-unknown-mingw32
105 rmdir lib
106 mv ghc-asm.prl ghc-asm
107 mv ghc-split.prl ghc-split
108
109 echo "create gcc-lib/"
110 #
111 # A bunch of stuff gets lumped into gcc-lib:
112 #
113 #  - the gcc-lib/ + gcc-lib/include of the gcc you
114 #    intend to ship (normally located as 
115 #     lib/gcc-lib/mingw/<gcc version>/ in your mingw tree.)
116 #  - the contents of mingw/lib/ 
117 #  - ld.exe, as.exe, dlltool.exe, dllwrap.exe from mingw/bin
118 #    to gcc-lib/
119 #  - ar.exe from mingw/bin to bin/
120 #
121 mkdir gcc-lib
122 mkdir gcc-lib/include
123 cp $gcc_lib/* gcc-lib/
124 cp $gcc_libexec/* gcc-lib/
125 cp $gcc_lib/include/* gcc-lib/include/
126 cp $mingw_lib/* gcc-lib/
127 cp $mingw_bin/as.exe gcc-lib/
128 cp $mingw_bin/ld.exe gcc-lib/
129 cp $mingw_bin/ar.exe bin/
130 # Note: later versions of dlltool.exe depend on a bfd helper DLL.
131 cp $mingw_bin/dllwrap.exe gcc-lib/
132 cp $mingw_bin/dlltool.exe gcc-lib/
133 # Remove worthy, but unused tools
134 rm gcc-lib/f771.exe || echo "good - f771.exe not found"
135 rm gcc-lib/gnat1.exe || echo "good - gnat1.exe not found"
136 rm gcc-lib/jc1.exe || echo "good - jc1.exe not found"
137 rm gcc-lib/libgcj* || echo "good - libgcj libs not found"
138 rm gcc-lib/jvgenmain.exe || echo "good - jvgenmain.exe not found"
139
140 echo "extra header files inside of include/"
141 #
142 # contains mingw/include
143 mkdir include/mingw
144 cp -Rf $mingw_include/* include/mingw
145 #
146 # g++-3/ subdir causes problems with installer tool (+ being a 
147 # troublesome character); leave out for now.
148 #rm -rf include/mingw/g++-3/ || echo "g++-3/ not there"
149 rm -rf include/mingw/c++/ || echo "c++/ not there"
150 rm -rf include/mingw/ddk/ || echo "ddk/ not there"
151 rm -rf include/mingw/gnu/ || echo "gnu/ not there"
152 rm -rf include/mingw/javax/ || echo "javax/ not there"
153 rm -rf include/mingw/java/ || echo "java/ not there"
154 rm -rf include/mingw/gcj/ || echo "gcj/ not there"
155
156 echo "add gcc"
157 cp ${mingw_bin}/gcc.exe .
158 #cp ${mingw_bin}/gcc-2.exe gcc.exe
159
160 echo "copy in perl too"
161 cp ${perl_dir}/perl.exe .
162 cp ${perl_dir}/perl56.dll .
163
164 # For reasons unknown, duplicate copies of misc package files in share/
165 # (leave them be for now.)
166
167 echo "formatting documentation"
168 cp README README.txt
169 mv share doc
170
171 # Leave out pdf users_guide documentation for now; problematic to build with the versions
172 # of 'xsltproc' and 'fop' I've been able to lay my hands on.
173 #cp ../ghc/docs/users_guide/users_guide.pdf doc/ || 
174 #  (make -C ../ghc/docs/users_guide/ pdf ; cp ../ghc/docs/users_guide/users_guide.pdf doc/) || 
175 #  echo "No User Guide PDF doc found"
176 #cp ../hslibs/doc/hslibs.pdf doc/ || 
177 #  (make -C ../hslibs/doc/ pdf ; cp ../hslibs/doc/hslibs.pdf doc/) ||
178 #  echo "No HSLIBS PDF doc found"