1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365
|
#!/bin/sh
#
# $Id$
#
# error out on failed commands whose return code wasn't explicitly
# checked
set -e
usage() {
cat << EOF
$0 [options]
Builds a non-cygwin version of pcb and create a standalone
windows installer.
Supported options:
--debug - Omits the compiler flag which prevents
a command window from being opened. This
is useful when trying to use debug printf's
--disable-doc - Pass "--disable-doc" to the configure script.
--enable-maintainer-mode
- Pass "--enable-maintainer-mode" to the
configure script.
--help - Show this message and exit.
--force-autogen - Force running ./autogen.sh. Normally this is
only done if the configure script is not present.
--nsis-only - Only run NSIS to create the installer. This is
shorthand for all of the following --skip-* options.
--skip-build - Skip the "make" step of the process.
--skip-clean - Skip the "make clean" step of the process.
--skip-config - Skip the "./configure" step of the process.
--skip-install - Skip the "make install" step of the process.
--with-tex - Set TEX=tex
--with-etex - set TEX=etex
For the $0 script to work, you must have the gtk_win32 files
as well as gdlib installed on your system in very specific
locations. Edit $0 to change these. While you are at it, feel
free to provide a patch to improve the documentation about
those libraries.
EOF
}
debug=no
do_autogen=no
do_config=yes
do_build=yes
do_clean=yes
do_install=yes
config_args=""
tex_flag="TEX=tex"
while test $# -ne 0 ; do
case $1 in
--debug)
debug=yes
shift
;;
--disable-doc)
config_args="${config_args} --disable-doc"
shift
;;
--enable-maintainer-mode)
config_args="${config_args} --enable-maintainer-mode"
shift
;;
--help)
usage
exit 0
;;
--force-autogen)
do_autogen=yes
shift
;;
--nsis-only)
do_build=no
do_clean=no
do_config=no
do_install=no
shift
;;
--skip-build)
do_build=no
shift
;;
--skip-clean)
do_clean=no
shift
;;
--skip-config)
do_config=no
shift
;;
--skip-install)
do_install=no
shift
;;
--with-etex)
tex_flag="TEX=etex"
shift
;;
--with-tex)
tex_flag="TEX=tex"
shift
;;
-*)
echo "ERROR: Unknown option $1"
usage
exit 1
;;
*)
break
;;
esac
done
if test ! -f win32/build_pcb ; then
echo "$0: ERROR. This script must be run from the top level of the pcb source tree."
exit 1
fi
# Run this under cygwin to build pcb and create a windows installer for
# it. Thanks to Bob Paddock for pointing me to NSIS and answering some
# beginner windows questions.
# where gtk_win32 is installed
gtk_win32=c:\\cygwin\\home\\${USER}\\gtk_win32
# where only the runtime components are installed
gtk_win32_runtime=c:\\\\cygwin\\\\home\\\\${USER}\\\\gtk_win32_runtime
# where the gdwin32.zip archive has been extracted
# gdwin32.zip can be downloaded from http://www.boutell.com/gd/http/gdwin32.zip
# I have used 2.0.33
gd_win32=c:\\cygwin\\home\\${USER}\\gd_win32
gd_win32_runtime=c:\\\\cygwin\\\\home\\\\${USER}\\\\gd_win32_runtime
# pcb version
pcb_version=`awk '/AC_INIT/ {gsub(/.*,[ \t]*\[/, ""); gsub(/\]\).*/, ""); print}' configure.ac`
echo "pcb_version=${pcb_version}"
# location of the NSIS makensis executible (see http://nsis.sourceforge.net)
makensis="/cygdrive/c/Program Files/NSIS/makensis.exe"
# ########################################################################
#
# The rest should be ok without editing
#
# ########################################################################
if test ! -f configure -o $do_autogen = yes ; then
echo "Bootstrapping autotools"
ACLOCAL_FLAGS="-I ${gtk_win32}\\share\\aclocal" ./autogen.sh
fi
# source directory
srcdir=`pwd.exe`/win32
top_srcdir=${srcdir}/..
src_dir=c:\\\\cygwin`echo ${srcdir} | sed 's;/;\\\\\\\\;g'`
top_src_dir=c:\\\\cygwin`echo ${top_srcdir} | sed 's;/;\\\\\\\\;g'`
# where to install pcb
pcb_inst=`pwd`/pcb_inst
# DOS version
pcb_inst_dir=c:\\\\cygwin`echo ${pcb_inst} | sed 's;/;\\\\\\\\;g'`
PKG_CONFIG_PATH=${gtk_win32}\\lib\\pkgconfig
export PKG_CONFIG_PATH
PATH=${HOME}/gd_win32_runtime/bin:${HOME}/gtk_win32_runtime/bin:${PATH}
export PATH
echo "Set PATH=${PATH}"
echo "Showing packages known to pkg-config:"
pkg-config --list-all
# do not try to use libpng-config, it seems broken on win32
LIBPNG_CONFIG=/usr/bin/true
export LIBPNG_CONFIG
LIBPNG_CFLAGS="-I${HOME}/gtk_win32/include"
LIBPNG_LDFLAGS="-L${HOME}/gtk_win32/lib"
LIBPNG_LIBS="-lpng"
# do not try and build the tk based QFP footprint
# builder
WISH=/usr/bin/true
export WISH
# do not try and use the gdlib-config script to
# configure gdlib
GDLIB_CONFIG=/usr/bin/true
export GDLIB_CONFIG
GDLIB_CFLAGS="-I${HOME}/gd_win32/include"
GDLIB_LDFLAGS="-L${HOME}/gd_win32/lib -lbgd"
# add the gcc options to produce a native windows binary that
# does not need cygwin to run
if test "x${debug}" = "xno" ; then
EXTRA_FLAGS="-mwindows"
fi
CYGWIN_CFLAGS="-mms-bitfields -mno-cygwin ${EXTRA_FLAGS}"
export CYGWIN_CFLAGS
CYGWIN_CPPFLAGS="-mms-bitfields -mno-cygwin ${EXTRA_FLAGS}"
export CYGWIN_CPPFLAGS
# setting WIN32=yes will make sure that the desktop icon
# gets compiled in
if test "$do_config" = "yes" ; then
rm -fr src/.deps
echo "Configuring for cygwin"
( ( ( env WIN32=yes \
./configure \
--prefix=${pcb_inst} \
--pdfdir=${pcb_inst}/doc/pdf \
--htmldir=${pcb_inst}/doc/html \
--datadir=${pcb_inst}/share \
ac_cv_func_gdImageGif="yes" \
ac_cv_func_gdImageJpeg="yes" \
ac_cv_func_gdImagePng="yes" \
--disable-dependency-tracking \
--disable-nls \
--disable-update-desktop-database \
--disable-update-mime-database \
${config_args} \
CFLAGS="${GDLIB_CFLAGS}" \
LDFLAGS="${GDLIB_LDFLAGS}" \
WIN32=yes \
2>&1 ; echo $? >&4 ) | tee c.log 1>&3) 4>&1 | (read a ; exit $a)) 3>&1
if test $? -ne 0 ; then
echo "**** ERROR **** Configure failed. See log in c.log"
exit 1
fi
# If the win32 pkg-config is used, then you end up with spurious CR's
# in the generated Makefile's and we need to get rid of them.
for f in `find . -name Makefile -print`; do
mv $f $f.bak
cat $f.bak | tr '\r' ' ' > $f
rm $f.bak
done
fi
if test "$do_clean" = "yes" ; then
echo "Cleaning"
( ( ( make clean 2>&1 ; echo $? >&4) | tee clean.log 1>&3) 4>&1 | (read a ; exit $a) ) 3>&1
if test $? -ne 0 ; then
echo "**** ERROR **** Clean failed. See log in clean.log"
exit 1
fi
fi
if test "$do_build" = "yes" ; then
echo "Building for cygwin"
( ( ( make $tex_flag 2>&1 ; echo $? >&4) | tee m.log 1>&3) 4>&1 | (read a ; exit $a) ) 3>&1
if test $? -ne 0 ; then
echo "**** ERROR **** Build failed. See log in m.log"
exit 1
fi
fi
if test "$do_install" = "yes" ; then
echo "Installing for cygwin"
# first clean out the installation directory to make sure
# we don't have old junk lying around.
if test -d ${pcb_inst} ; then
rm -fr ${pcb_inst}
fi
( ( ( make install 2>&1 ; echo $? >&4) | tee -a m.log 1>&3) 4>&1 | (read a ; exit $a) ) 3>&1
if test $? -ne 0 ; then
echo "**** ERROR **** Build failed. See log in m.log"
exit 1
fi
fi
cat << EOF
Creating NSIS script
srcdir = ${srcdir}
src_dir = ${src_dir}
top_srcdir = ${top_srcdir}
top_src_dir = ${top_src_dir}
EOF
sed \
-e "s;@pcb_version@;${pcb_version};g" \
-e "s;@pcb_prefix@;${pcb_inst_dir};g" \
-e "s;@pcb_srcdir@;${top_src_dir};g" \
-e "s;@gtk_win32_runtime@;${gtk_win32_runtime};g" \
-e "s;@gd_win32@;${gd_win32};g" \
-e "s;@gd_win32_runtime@;${gd_win32_runtime};g" \
${srcdir}/pcb.nsi.in > ${srcdir}/pcb.nsi
echo "Creating windows installer"
"${makensis}" ${src_dir}/pcb.nsi
echo "Windows installer left in ${srcdir}:"
ls -l ${srcdir}/*.exe
bat=run_install.bat
cat << EOF
Creating DOS batch file wrapper for the installer.
If you have just built this under cygwin on Vista,
you will need to either run the installer from
the Vista start menu, Windows explorer or directly from
the cygwin shell with
./${bat}
EOF
cat > ${bat} << EOF
.\win32\pcbinst-${pcb_version}.exe
EOF
chmod 755 ${bat}
|