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