| OLD | NEW |
| 1 #!/bin/sh | 1 #!/bin/bash |
| 2 # | 2 # |
| 3 ############################################################################### | 3 ############################################################################### |
| 4 # | 4 # |
| 5 # Build a binary package on Windows with MinGW and MSYS | 5 # Build a binary package on Windows with MinGW and MSYS |
| 6 # | 6 # |
| 7 # Set the paths where MinGW, Mingw-w32, or MinGW-w64 are installed. If both | 7 # Set the paths where MinGW, Mingw-w32, or MinGW-w64 are installed. If both |
| 8 # MinGW and MinGW-w32 are specified, MinGW will be used. If there is no | 8 # MinGW and MinGW-w32 are specified, MinGW-w32 will be used. If there is no |
| 9 # 32-bit or 64-bit compiler at all, it is simply skipped. | 9 # 32-bit or 64-bit compiler at all, it is simply skipped. |
| 10 # | 10 # |
| 11 # Optionally, 7-Zip is used to create the final .zip and .7z packages. | 11 # Optionally, 7-Zip is used to create the final .zip and .7z packages. |
| 12 # If you have installed it in the default directory, this script should | 12 # If you have installed it in the default directory, this script should |
| 13 # find it automatically. Otherwise adjust the path manually. | 13 # find it automatically. Otherwise adjust the path manually. |
| 14 # | 14 # |
| 15 # If you want to use a cross-compiler e.g. on GNU/Linux, this script won't | 15 # If you want to use a cross-compiler e.g. on GNU/Linux, this script won't |
| 16 # work out of the box. You need to omit "make check" commands and replace | 16 # work out of the box. You need to omit "make check" commands and replace |
| 17 # u2d with some other tool to convert newlines from LF to CR+LF. You will | 17 # u2d with some other tool to convert newlines from LF to CR+LF. You will |
| 18 # also need to pass the --host option to configure. | 18 # also need to pass the --host option to configure. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 41 set -e | 41 set -e |
| 42 | 42 |
| 43 # White spaces in directory names may break things so catch them immediately. | 43 # White spaces in directory names may break things so catch them immediately. |
| 44 case $(pwd) in | 44 case $(pwd) in |
| 45 ' ' | ' ' | ' | 45 ' ' | ' ' | ' |
| 46 ') echo "Error: White space in the directory name" >&2; exit 1 ;; | 46 ') echo "Error: White space in the directory name" >&2; exit 1 ;; |
| 47 esac | 47 esac |
| 48 | 48 |
| 49 # This script can be run either at the top-level directory of the package | 49 # This script can be run either at the top-level directory of the package |
| 50 # or in the same directory containing this script. | 50 # or in the same directory containing this script. |
| 51 if [ ! -f windows/build.sh ]; then | 51 if [ ! -f windows/build.bash ]; then |
| 52 cd .. | 52 cd .. |
| 53 » if [ ! -f windows/build.sh ]; then | 53 » if [ ! -f windows/build.bash ]; then |
| 54 echo "You are in a wrong directory." >&2 | 54 echo "You are in a wrong directory." >&2 |
| 55 exit 1 | 55 exit 1 |
| 56 fi | 56 fi |
| 57 fi | 57 fi |
| 58 | 58 |
| 59 # Run configure and copy the binaries to the given directory. | 59 # Run configure and copy the binaries to the given directory. |
| 60 # | 60 # |
| 61 # The first argument is the directory where to copy the binaries. | 61 # The first argument is the directory where to copy the binaries. |
| 62 # The rest of the arguments are passed to configure. | 62 # The rest of the arguments are passed to configure. |
| 63 buildit() | 63 buildit() |
| (...skipping 27 matching lines...) Expand all Loading... |
| 91 | 91 |
| 92 # Build the normal speed-optimized binaries. Note that while | 92 # Build the normal speed-optimized binaries. Note that while |
| 93 # --disable-threads has been documented to make some things | 93 # --disable-threads has been documented to make some things |
| 94 # thread-unsafe, it's not actually true with this combination | 94 # thread-unsafe, it's not actually true with this combination |
| 95 # of configure flags in XZ Utils 5.0.x. Things can (and probably | 95 # of configure flags in XZ Utils 5.0.x. Things can (and probably |
| 96 # will) change after 5.0.x, and this script will be updated too. | 96 # will) change after 5.0.x, and this script will be updated too. |
| 97 ./configure \ | 97 ./configure \ |
| 98 --prefix= \ | 98 --prefix= \ |
| 99 --disable-nls \ | 99 --disable-nls \ |
| 100 --disable-threads \ | 100 --disable-threads \ |
| 101 --enable-dynamic=no \ | |
| 102 --build="$BUILD" \ | 101 --build="$BUILD" \ |
| 103 CFLAGS="$CFLAGS -O2" | 102 CFLAGS="$CFLAGS -O2" |
| 104 » make check | 103 » make -C src/liblzma |
| 104 » make -C src/xz LDFLAGS=-static |
| 105 » make -C tests check |
| 105 | 106 |
| 106 cp -v src/xz/xz.exe src/liblzma/.libs/liblzma.a "$DESTDIR" | 107 cp -v src/xz/xz.exe src/liblzma/.libs/liblzma.a "$DESTDIR" |
| 107 cp -v src/liblzma/.libs/liblzma-*.dll "$DESTDIR/liblzma.dll" | 108 cp -v src/liblzma/.libs/liblzma-*.dll "$DESTDIR/liblzma.dll" |
| 108 | 109 |
| 109 » strip -v "$DESTDIR/"* | 110 » strip -v "$DESTDIR/"*.{exe,dll} |
| 111 » strip -vg "$DESTDIR/"*.a |
| 110 } | 112 } |
| 111 | 113 |
| 112 # Copy files and convert newlines from LF to CR+LF. Optinally add a suffix | 114 # Copy files and convert newlines from LF to CR+LF. Optinally add a suffix |
| 113 # to the destination filename. | 115 # to the destination filename. |
| 114 # | 116 # |
| 115 # The first argument is the destination directory. The second argument is | 117 # The first argument is the destination directory. The second argument is |
| 116 # the suffix to append to the filenames; use empty string if no extra suffix | 118 # the suffix to append to the filenames; use empty string if no extra suffix |
| 117 # is wanted. The rest of the arguments are actual the filenames. | 119 # is wanted. The rest of the arguments are actual the filenames. |
| 118 txtcp() | 120 txtcp() |
| 119 { | 121 { |
| 120 DESTDIR=$1 | 122 DESTDIR=$1 |
| 121 SUFFIX=$2 | 123 SUFFIX=$2 |
| 122 shift 2 | 124 shift 2 |
| 123 for SRCFILE; do | 125 for SRCFILE; do |
| 124 DESTFILE="$DESTDIR/${SRCFILE##*/}$SUFFIX" | 126 DESTFILE="$DESTDIR/${SRCFILE##*/}$SUFFIX" |
| 125 echo "Converting \`$SRCFILE' -> \`$DESTFILE'" | 127 echo "Converting \`$SRCFILE' -> \`$DESTFILE'" |
| 126 u2d < "$SRCFILE" > "$DESTFILE" | 128 u2d < "$SRCFILE" > "$DESTFILE" |
| 127 done | 129 done |
| 128 } | 130 } |
| 129 | 131 |
| 130 # FIXME: Make sure that we don't get i686 or i586 code from the runtime. | 132 # FIXME: Make sure that we don't get i686 or i586 code from the runtime. |
| 131 # Actually i586 would be fine, but i686 probably not if the idea is to | 133 # Actually i586 would be fine, but i686 probably not if the idea is to |
| 132 # support even Win95. | 134 # support even Win95. |
| 133 # | 135 # |
| 134 # FIXME: Using i486 in the configure triplet may be wrong. | 136 # FIXME: Using i486 in the configure triplet may be wrong. |
| 135 if [ -d "$MINGW_DIR" ]; then | 137 if [ -d "$MINGW_W32_DIR" ]; then |
| 138 » # 32-bit x86, Win95 or later, using MinGW-w32 |
| 139 » PATH=$MINGW_W32_DIR/bin:$MINGW_W32_DIR/i686-w64-mingw32/bin:$PATH \ |
| 140 » » » buildit \ |
| 141 » » » pkg/bin_i486 \ |
| 142 » » » i486-w64-mingw32 \ |
| 143 » » » '-march=i486 -mtune=generic' |
| 144 elif [ -d "$MINGW_DIR" ]; then |
| 136 # 32-bit x86, Win95 or later, using MinGW | 145 # 32-bit x86, Win95 or later, using MinGW |
| 137 PATH=$MINGW_DIR/bin:$PATH \ | 146 PATH=$MINGW_DIR/bin:$PATH \ |
| 138 buildit \ | 147 buildit \ |
| 139 pkg/bin_i486 \ | 148 pkg/bin_i486 \ |
| 140 i486-pc-mingw32 \ | 149 i486-pc-mingw32 \ |
| 141 '-march=i486 -mtune=generic' | 150 '-march=i486 -mtune=generic' |
| 142 elif [ -d "$MINGW_W32_DIR" ]; then | |
| 143 # 32-bit x86, Win95 or later, using MinGW-w32 | |
| 144 PATH=$MINGW_W32_DIR/bin:$MINGW_W32_DIR/i686-w64-mingw32/bin:$PATH \ | |
| 145 buildit \ | |
| 146 pkg/bin_i486 \ | |
| 147 i486-w64-mingw32 \ | |
| 148 '-march=i486 -mtune=generic' | |
| 149 fi | 151 fi |
| 150 | 152 |
| 151 if [ -d "$MINGW_W64_DIR" ]; then | 153 if [ -d "$MINGW_W64_DIR" ]; then |
| 152 # 64-bit x86, WinXP or later, using MinGW-w64 | 154 # 64-bit x86, WinXP or later, using MinGW-w64 |
| 153 PATH=$MINGW_W64_DIR/bin:$MINGW_W64_DIR/x86_64-w64-mingw32/bin:$PATH \ | 155 PATH=$MINGW_W64_DIR/bin:$MINGW_W64_DIR/x86_64-w64-mingw32/bin:$PATH \ |
| 154 buildit \ | 156 buildit \ |
| 155 pkg/bin_x86-64 \ | 157 pkg/bin_x86-64 \ |
| 156 x86_64-w64-mingw32 \ | 158 x86_64-w64-mingw32 \ |
| 157 '-march=x86-64 -mtune=generic' | 159 '-march=x86-64 -mtune=generic' |
| 158 fi | 160 fi |
| 159 | 161 |
| 160 # Copy the headers, the .def file, and the docs. | 162 # Copy the headers, the .def file, and the docs. |
| 161 # They are the same for all architectures and builds. | 163 # They are the same for all architectures and builds. |
| 162 mkdir -pv pkg/{include/lzma,doc/manuals} | 164 mkdir -pv pkg/{include/lzma,doc/{manuals,examples}} |
| 163 txtcp pkg/include "" src/liblzma/api/lzma.h | 165 txtcp pkg/include "" src/liblzma/api/lzma.h |
| 164 txtcp pkg/include/lzma "" src/liblzma/api/lzma/*.h | 166 txtcp pkg/include/lzma "" src/liblzma/api/lzma/*.h |
| 165 txtcp pkg/doc "" src/liblzma/liblzma.def | 167 txtcp pkg/doc "" src/liblzma/liblzma.def |
| 166 txtcp pkg/doc .txt AUTHORS COPYING NEWS README THANKS TODO | 168 txtcp pkg/doc .txt AUTHORS COPYING NEWS README THANKS TODO |
| 167 txtcp pkg/doc "" doc/*.txt | 169 txtcp pkg/doc "" doc/*.txt windows/README-Windows.txt |
| 168 txtcp pkg/doc/manuals "" doc/man/txt/{xz,xzdec,lzmainfo}.txt | 170 txtcp pkg/doc/manuals "" doc/man/txt/{xz,xzdec,lzmainfo}.txt |
| 169 cp -v doc/man/pdf-*/{xz,xzdec,lzmainfo}-*.pdf pkg/doc/manuals | 171 cp -v doc/man/pdf-*/{xz,xzdec,lzmainfo}-*.pdf pkg/doc/manuals |
| 170 txtcp pkg "" windows/README-Windows.txt | 172 txtcp pkg/doc/examples "" doc/examples/* |
| 173 |
| 174 if [ -f windows/COPYING-Windows.txt ]; then |
| 175 » txtcp pkg/doc "" windows/COPYING-Windows.txt |
| 176 fi |
| 171 | 177 |
| 172 # Create the package. This requires 7z.exe from 7-Zip. If it wasn't found, | 178 # Create the package. This requires 7z.exe from 7-Zip. If it wasn't found, |
| 173 # this step is skipped and you have to zip it yourself. | 179 # this step is skipped and you have to zip it yourself. |
| 174 VER=$(sh version.sh) | 180 VER=$(sh build-aux/version.sh) |
| 175 cd pkg | 181 cd pkg |
| 176 if [ -x "$SEVENZ_EXE" ]; then | 182 if [ -x "$SEVENZ_EXE" ]; then |
| 177 "$SEVENZ_EXE" a -tzip ../xz-$VER-windows.zip * | 183 "$SEVENZ_EXE" a -tzip ../xz-$VER-windows.zip * |
| 178 "$SEVENZ_EXE" a ../xz-$VER-windows.7z * | 184 "$SEVENZ_EXE" a ../xz-$VER-windows.7z * |
| 179 else | 185 else |
| 180 echo | 186 echo |
| 181 echo "NOTE: 7z.exe was not found. xz-$VER-windows.zip" | 187 echo "NOTE: 7z.exe was not found. xz-$VER-windows.zip" |
| 182 echo " and xz-$VER-windows.7z were not created." | 188 echo " and xz-$VER-windows.7z were not created." |
| 183 echo " You can create them yourself from the pkg directory." | 189 echo " You can create them yourself from the pkg directory." |
| 184 fi | 190 fi |
| 185 | 191 |
| 192 if [ ! -f ../windows/COPYING-Windows.txt ]; then |
| 193 echo |
| 194 echo "NOTE: windows/COPYING-Windows.txt doesn't exists." |
| 195 echo " MinGW(-w64) runtime copyright information" |
| 196 echo " is not included in the package." |
| 197 fi |
| 198 |
| 186 echo | 199 echo |
| 187 echo "Build completed successfully." | 200 echo "Build completed successfully." |
| 188 echo | 201 echo |
| OLD | NEW |