5 # error out on failed commands whose return code wasn't explicitly
14 Builds a non-cygwin version of gerbv or pcb and create a standalone
19 --build-only - Only run the 'make' part of the process. This is
20 shorthand for all of the --skip-* options except
23 --debug - Omits the compiler flag which prevents
24 a command window from being opened. This
25 is useful when trying to use debug printf's.
26 If listed twice then --enable-debug is passed
27 down to the configure script which enables
28 a good bit of debug output.
30 -h|--help - Show this message and exit.
32 --force-autogen - Force running ./autogen.sh. Normally this is
33 only done if the configure script is not present.
35 --nsis-only - Only run NSIS to create the installer. This is
36 shorthand for all of the following --skip-* options.
38 --skip-build - Skip the "make" step of the process.
40 --skip-clean - Skip the "make clean" step of the process.
42 --skip-config - Skip the "./configure" step of the process.
44 --skip-install - Skip the "make install" step of the process.
46 --skip-nsis - Skip the NSIS step of the process.
48 For the $0 script to work, you must have the gtk_win32 files
49 as well as gdlib installed on your system in very specific
50 locations. Edit $0 to change these. While you are at it, feel
51 free to provide a patch to improve the documentation about
54 On older installs of cygwin, the available gcc will accept -mno-cygwin
55 to build an executible that does not link to the cygwin dll. On newer
56 gcc's this option has been removed and you must use either a
57 cross compiler that targets mingw or use the native MinGW compiler.
58 If you use the native MinGW compiler approach, then
59 the MinGW compilers to be installed in
60 c:\MinGW and also in your cygwin environment there needs to be
63 /mingw -> /cygdrive/c/MinGW
76 while test $# -ne 0 ; do
87 if test "X${debug}" = "Xyes" ; then
88 config_args
="${config_args} --enable-debug"
138 echo "ERROR: Unknown option $1"
149 do_fake_crossbuild
=no
150 if test -f /mingw
/bin
/mingw32-gcc.exe
; then
151 do_fake_crossbuild
=yes
154 echo "do_fake_crossbuild = ${do_fake_crossbuild}"
158 if test ! -d win32
; then
159 echo "$0: ERROR. This script must be run from the top level of the source tree"
163 if test -f src
/gerbv.c
; then
167 if test -f src
/pcb-menu.res
; then
169 config_args
="${config_args} --disable-dbus --disable-m4lib-png "
170 if test -f .gitignore
-o -f CVS
/Root
; then
171 echo "Building from git or CVS so the documentation"
172 echo "build will be disabled (since we are cross building"
173 config_args
="${config_args} --disable-doc"
178 if test -f libwcalc
/microstrip.c
; then
180 config_args
="${config_args} --disable-htdocs --disable-cgi --disable-stdio"
183 if test ${prog_name} = unknown
; then
185 $0: ERROR. Unable to figure out what you are building.
186 This may happen if you are trying to execute $0 from a directory
187 other than the top of the source tree.
192 echo "Building program: ${prog_name}"
194 # Run this under cygwin to build gerbv or pcb and create a windows installer for
195 # it. Thanks to Bob Paddock for pointing me to NSIS and answering some
196 # beginner windows questions.
198 # where gtk_win32 is installed
199 gtk_win32
=c
:\\cygwin
\\home
\\${USER}\\gtk_win32
200 gd_win32
=c
:\\cygwin
\\home
\\${USER}\\gd_win32
201 gd_win32_f
=c
:/cygwin
/home
/${USER}/gd_win32
203 # where only the runtime components are installed
204 gtk_win32_runtime
=c
:\\\\cygwin
\\\\home
\\\\${USER}\\\\gtk_win32_runtime
205 gd_win32_runtime
=c
:\\\\cygwin
\\\\home
\\\\${USER}\\\\gd_win32_runtime
209 prog_version
=`awk '/AC_INIT/ {gsub(/.*,[ \t]*\[/, ""); gsub(/\]\).*/, ""); print}' configure.ac`
210 echo "prog_version=${prog_version}"
212 # location of the NSIS makensis executible (see http://nsis.sourceforge.net)
213 makensis
="/cygdrive/c/Program Files/NSIS/makensis.exe"
216 # ########################################################################
218 # The rest should be ok without editing
220 # ########################################################################
223 ######################################################################
227 ######################################################################
229 if test ! -f configure
-o $do_autogen = yes ; then
230 echo "Bootstrapping autotools"
231 ACLOCAL_FLAGS
="-I ${gtk_win32}\\share\\aclocal" .
/autogen.sh
235 srcdir
=`pwd.exe`/win32
236 top_srcdir
=${srcdir}/..
238 src_dir
=c
:\\\\cygwin
`echo ${srcdir} | sed 's;/;\\\\\\\\;g'`
239 top_src_dir
=c
:\\\\cygwin
`echo ${top_srcdir} | sed 's;/;\\\\\\\\;g'`
242 # where to install the program
243 prog_inst
=`pwd`/${prog_name}_inst
246 prog_inst_dir
=c
:\\\\cygwin
`echo ${prog_inst} | sed 's;/;\\\\\\\\;g'`
248 PKG_CONFIG_PATH
=${gtk_win32}\\lib
\\pkgconfig
249 export PKG_CONFIG_PATH
251 PATH
=${gtk_win32}\\bin:${gd_win32}:${PATH}
254 echo "Showing packages known to pkg-config:"
255 pkg-config
--list-all
258 # do not try to use libpng-config, it seems broken on win32
259 if test $prog_name = pcb
; then
260 LIBPNG_CFLAGS
="-I${gtk_win32}\\include"
261 LIBPNG_CPPFLAGS
="-I${gtk_win32}\\include"
262 LIBPNG_LDFLAGS
="-L${gtk_win32}\\lib"
263 LIBPNG_LIBS
="-lpng14"
264 LIBGD_CFLAGS
="-I${gd_win32}\\include -I${gd_win32_f}/include"
265 LIBGD_CPPFLAGS
="-I${gd_win32}\\include"
266 LIBGD_LDFLAGS
="-L${gd_win32}\\lib -L${gd_win32_f}/lib"
268 # this ugly hack is here because the AC_CHECK_FUNC autoconf
269 # test doesn't include gd.h. Inside of gd.h, gdImageGif and
270 # friends are declared with
271 # __declspec(dllimport) void _stdcall
272 # which causes a change in how the function is named in the DLL
273 # which in turn causes the autoconf test to fail. ugh! FIXME!
274 export ac_cv_func_gdImageGif
=yes
275 export ac_cv_func_gdImageJpeg
=yes
276 export ac_cv_func_gdImagePng
=yes
282 LIBPNG_CONFIG
=/usr
/bin
/true
285 # add the gcc options to produce a native windows binary that
286 # does not need cygwin to run
287 if test "x${debug}" = "xno" ; then
288 EXTRA_FLAGS
="-mwindows"
291 CYGWIN_CFLAGS
="-mms-bitfields -mno-cygwin ${EXTRA_FLAGS}"
294 CYGWIN_CPPFLAGS
="-mms-bitfields -mno-cygwin ${EXTRA_FLAGS}"
295 export CYGWIN_CPPFLAGS
298 # older releases of cygwin had a gcc that accepted -mno-cygwin.
299 # in more recent releases this flag (which builds and links without
300 # the cygwin dll) has been removed. We either need a normal
301 # cross compiler or we can fake it by using the native mingw
303 # see http://www.gnu.org/software/libtool/manual/html_node/Cygwin-to-MinGW-Cross.html
304 # in particular, the lt_cv_to_tool_file_cmd bit is needed because
305 # libtool will call the mingw ranlib which will not understand
306 # any cygwin absolute paths.
307 if test ${do_fake_crossbuild} = yes ; then
308 config_args
="${config_args} --build=i686-pc-cygwin --host=mingw32"
309 NM
=/cygdrive
/c
/MinGW
/bin
/nm.exe
312 # the ranlib bit here is because putting the mingw tools first
313 # in PATH causes the mingw ranlib to be called. The problem
314 # with that is tht libtool is passing an absolute cygwin
315 # path at install time to ranlib which can't deal. The
316 # func_convert... stuff is supposed to help but it didn't.
317 # The libtool folks have a patch for this so at some point
319 RANLIB
=/usr
/bin
/ranlib
321 PATH
=/cygdrive
/c
/MinGW
/bin
:${PATH}
322 export lt_cv_to_tool_file_cmd
=func_convert_file_cygwin_to_w32
325 ######################################################################
329 ######################################################################
331 # setting WIN32=yes will make sure that the desktop icon
333 if test "$do_config" = "yes" ; then
335 echo "Configuring for cygwin"
336 ( ( ( env WIN32
=yes \
338 --prefix=${prog_inst} \
339 --disable-dependency-tracking \
340 --disable-maintainer-mode \
342 --disable-update-desktop-database \
343 --disable-update-mime-database \
345 CFLAGS
="${LIBPNG_CFLAGS} ${LIBGD_CFLAGS}" \
346 CPPFLAGS
="${LIBPNG_CPPFLAGS} ${LIBGD_CPPFLAGS}" \
347 LDFLAGS
="${LIBPNG_LDFLAGS} ${LIBGD_LDFLAGS}" \
348 LIBS
="${LIBPNG_LIBS} ${LIBGD_LIBS}" \
350 2>&1 ; echo $?
>&4 ) |
tee c.log
1>&3) 4>&1 |
(read a
; exit $a)) 3>&1
352 if test $?
-ne 0 ; then
353 echo "**** ERROR **** Configure failed. See log in c.log"
357 # If the win32 pkg-config is used, then you end up with spurious CR's
358 # in the generated Makefile's and we need to get rid of them.
363 cat $f.bak |
tr '\r' ' ' > $f
366 echo "Removing spurious carriage returns in the Makefiles..."
367 for f
in `find . -name Makefile -print` ; do
371 if test -f libtool
; then
372 echo "Removing spurious carriage returns in libtool..."
378 ######################################################################
382 ######################################################################
384 if test "$do_clean" = "yes" ; then
386 ( ( ( make clean
2>&1 ; echo $?
>&4) |
tee clean.log
1>&3) 4>&1 |
(read a
; exit $a) ) 3>&1
387 if test $?
-ne 0 ; then
388 echo "**** ERROR **** Clean failed. See log in clean.log"
393 ######################################################################
397 ######################################################################
399 if test "$do_build" = "yes" ; then
400 echo "Building for cygwin"
401 ( ( ( make 2>&1 ; echo $?
>&4) |
tee m.log
1>&3) 4>&1 |
(read a
; exit $a) ) 3>&1
402 if test $?
-ne 0 ; then
403 echo "**** ERROR **** Build failed. See log in m.log"
408 ######################################################################
412 ######################################################################
414 if test "$do_install" = "yes" ; then
415 echo "Installing for cygwin"
416 # first clean out the installation directory to make sure
417 # we don't have old junk lying around.
418 if test -d ${prog_inst} ; then
421 ( ( ( make install 2>&1 ; echo $?
>&4) |
tee -a m.log
1>&3) 4>&1 |
(read a
; exit $a) ) 3>&1
422 if test $?
-ne 0 ; then
423 echo "**** ERROR **** Build failed. See log in m.log"
428 ######################################################################
430 # NSIS INSTALLER CREATION
432 ######################################################################
434 if test "$do_nsis" = "yes" ; then
435 echo "Creating NSIS script"
436 echo "srcdir = ${srcdir}"
437 echo "src_dir = ${src_dir}"
438 echo "top_srcdir = ${top_srcdir}"
439 echo "top_src_dir = ${top_src_dir}"
442 -e "s|@enable_doc@|${enable_doc}|g" \
443 -e "s;@prog_version@;${prog_version};g" \
444 -e "s;@prog_prefix@;${prog_inst_dir};g" \
445 -e "s;@prog_srcdir@;${top_src_dir};g" \
446 -e "s;@gd_win32_runtime@;${gd_win32_runtime};g" \
447 -e "s;@gtk_win32_runtime@;${gtk_win32_runtime};g" \
448 ${srcdir}/${prog_name}.nsi.in > ${srcdir}/${prog_name}.nsi
450 echo "Creating windows installer"
451 "${makensis}" ${src_dir}/${prog_name}.nsi
454 echo "Windows installer left
in ${srcdir}:"
455 ls -l ${srcdir}/*.exe
462 Creating DOS batch file wrapper for the installer.
463 If you have just built this under cygwin on Vista,
464 you will need to either run the installer from
465 the Vista start menu, Windows explorer or directly from
466 the cygwin shell with
474 .\win32\\${prog_name}inst-${prog_version}.exe
479 echo "Skipping NSIS step per user request
"