info-mtools
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Info-mtools] buildMingw.sh improvement


From: Gert Hulselmans
Subject: [Info-mtools] buildMingw.sh improvement
Date: Sat, 12 Jan 2013 22:21:29 +0100

Hi,

When compiling mtools for Windows with mingw, it would be useful to have
the buildMingw.sh script generate all mtools programs that can run under
Windows.

Below is my modified version of the buildMingw.sh script:
  - It strips the generated Windows binary.
  - If upx is installed, it will be compressed with upx too.
  - Makes copies of the mtools binary for each tool and gives them a
*.exe extension
    (I don't know how to make e.g. a softlink or a hard link for
Windows from linux).
  - Make a COPYRIGHT.txt files with Windows line endings.
  - Put all those files in a win32 subdir.


Kind regards,
Gert Hulselmans


$ cat buildMingw.sh
#!/bin/sh

# Build Mingw (Windows) executable
#
# For this you meed the mingw cross-compiler to be installed
#
# You may download the RPMs from http://mirzam.it.vu.nl/mingw/
# All 4 RPM's are needed:
#  mingw-binutils
#  mingw-gcc-core
#  mingw-runtime
#  mingw-w32api

dir=$(dirname "$0")

"${dir}"/configure --srcdir "${dir}"  --host i586-mingw32msvc --disable-floppyd
# If "configure" succeeded, continue:
if [ $? -eq 0 ] ; then
   make

   # If "make" succeeded, continue:
   if [ $? -eq 0 ] ; then
      # Recuce the size of the generated binary.
      strip mtools

      # Compress the mtools binary with UPX (optionally).
      type upx > /dev/null 2>&1
      if [ $? -eq 0 ] ; then
         upx --ultra-brute "${dir}"/mtools
      fi

      # List of all mtool programs that can be used on Windows:
      # MTOOLS='mattrib mcat mcd mclasserase mcopy mdel mdeltree mdir
mdu mformat minfo mlabel mmd mmount mmove mpartition mrd mren mtype
mtoolstest mshortname mshowfat mbadblocks mzip'

      MTOOLS='mattrib mcat mcd mclasserase mcopy mdel mdeltree mdir
mdu mformat minfo mlabel mmd mmove mpartition mrd mren mtype mtools
mtoolstest mshortname mshowfat mbadblocks mzip'

      # Make dir for storing the win32 binaries
      if [ -d "${dir}"/win32 ] ; then
         rm -rf "${dir}"/win32
      fi

      mkdir "${dir}"/win32

      # Copy all mtools programs to the win32 subdir and give them the
proper extension.
      for MTOOL in ${MTOOLS}; do
         cp -v "${dir}"/mtools "${dir}"/win32/${MTOOL}.exe
      done

      # Copy license file (with Windows line endings).
      sed -e 's/$/\r/' "${dir}"/COPYING > "${dir}"/win32/COPYING.txt
   else
      exit 1
   fi
else
   exit 1
fi



reply via email to

[Prev in Thread] Current Thread [Next in Thread]