Skip to content

Commit

Permalink
update configure compatibility with system zlib, (#156)
Browse files Browse the repository at this point in the history
and minizip.
restore support for building with configure
outside the srcdir.
  • Loading branch information
tsteven4 committed Apr 27, 2018
1 parent 8c3354d commit 8bf7ad2
Show file tree
Hide file tree
Showing 16 changed files with 169 additions and 46 deletions.
2 changes: 1 addition & 1 deletion GPSBabel.pro
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ HEADERS = \
src/core/xmlstreamwriter.h \
src/core/logging.h

SUBDIRS += jeeps
INCLUDEPATH += zlib

macx|linux {
DEFINES += HAVE_NANOSLEEP HAVE_LIBUSB HAVE_GLOB
Expand Down
14 changes: 11 additions & 3 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@

srcdir = @srcdir@
VPATH = @srcdir@
builddir = @builddir@

# when srcdir and builddir are different we need to get config.h from builddir.
ifeq ($(srcdir), $(builddir))
BUILD_CPP = -I$(srcdir)
else
BUILD_CPP = -I$(builddir) -I$(srcdir)
endif

# version and release are defined in the head of configure.ac
# don't forget 'autoconf' if you change them
Expand Down Expand Up @@ -49,7 +57,7 @@ LRELEASE=@LRELEASE@
#OPTIMIZATION=-O $(EXTRA_OPTIMIZATION)
#DEBUGGING=-g $(EXTRA_DEBUGGING)
# add -DDEBUG_MEM to turn on memory allocation logging
GBCFLAGS=$(EXTRA_CFLAGS) $(DEBUGGING) -I$(srcdir) @QT_INC_OPT@$(QT_INC) \
GBCFLAGS=$(EXTRA_CFLAGS) $(DEBUGGING) $(BUILD_CPP) @ZLIB_CPP@ @QT_INC_OPT@$(QT_INC) \
$(OPTIMIZATION) -DHAVE_CONFIG_H -DNEW_STRINGS
LDFLAGS=$(EXTRA_LDFLAGS) @LDFLAGS@
PREFIX=@prefix@
Expand Down Expand Up @@ -106,7 +114,7 @@ MINIZIP=zlib/contrib/minizip/zip.o \
ZLIB=zlib/adler32.o zlib/compress.o zlib/crc32.o zlib/deflate.o zlib/inffast.o \
zlib/inflate.o zlib/infback.o zlib/inftrees.o zlib/trees.o \
zlib/uncompr.o zlib/gzlib.o zlib/gzclose.o zlib/gzread.o \
zlib/gzwrite.o zlib/zutil.o $(MINIZIP)
zlib/gzwrite.o zlib/zutil.o


LIBOBJS = queue.o route.o waypt.o filter_vecs.o util.o vecs.o mkshort.o \
Expand All @@ -117,7 +125,7 @@ LIBOBJS = queue.o route.o waypt.o filter_vecs.o util.o vecs.o mkshort.o \
src/core/xmlstreamwriter.o \
src/core/usasciicodec.o\
src/core/ziparchive.o \
$(GARMIN) $(JEEPS) $(SHAPE) @ZLIB@ $(FMTS) $(FILTERS)
$(GARMIN) $(JEEPS) $(SHAPE) @ZLIB@ @MINIZIP@ $(FMTS) $(FILTERS)
OBJS = main.o globals.o $(LIBOBJS) @FILEINFO@

DEPFILES = $(OBJS:.o=.d)
Expand Down
6 changes: 6 additions & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
/* Define to 1 if you have the `m' library (-lm). */
#undef HAVE_LIBM

/* Define to 1 if you have the `minizip' library (-lminizip). */
#undef HAVE_LIBMINIZIP

/* Defined if you have libusb */
#undef HAVE_LIBUSB

Expand Down Expand Up @@ -72,6 +75,9 @@
/* 1 to enable as many formats as possible */
#undef MAXIMAL_ENABLED

/* 1 to inhibit our use of libminizip. */
#undef MINIZIP_INHIBITED

/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT

Expand Down
120 changes: 109 additions & 11 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,6 @@ QT_INC
DOCDIR
INSTALL_DEBUG
GPSBABEL_DEBUG
ZLIB
GBSER
OSJEEPS
USB_CFLAGS
Expand All @@ -642,6 +641,9 @@ ac_ct_QMAKE
QMAKE
RC
FILEINFO
MINIZIP
ZLIB
ZLIB_CPP
FMTS
EGREP
GREP
Expand Down Expand Up @@ -698,6 +700,7 @@ infodir
docdir
oldincludedir
includedir
runstatedir
localstatedir
sharedstatedir
sysconfdir
Expand Down Expand Up @@ -725,6 +728,7 @@ enable_csv
enable_most
enable_filters
with_zlib
with_libminizip
with_doc
'
ac_precious_vars='build_alias
Expand Down Expand Up @@ -777,6 +781,7 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
Expand Down Expand Up @@ -1029,6 +1034,15 @@ do
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;

-runstatedir | --runstatedir | --runstatedi | --runstated \
| --runstate | --runstat | --runsta | --runst | --runs \
| --run | --ru | --r)
ac_prev=runstatedir ;;
-runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
| --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
| --run=* | --ru=* | --r=*)
runstatedir=$ac_optarg ;;

-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
Expand Down Expand Up @@ -1166,7 +1180,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
libdir localedir mandir
libdir localedir mandir runstatedir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
Expand Down Expand Up @@ -1319,6 +1333,7 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
Expand Down Expand Up @@ -1363,6 +1378,8 @@ Optional Packages:
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-zlib=(included)|system|no
--with-libminizip=(included)|system|no
--with-doc=DIR Path where the documentation will be stored.
Some influential environment variables:
Expand Down Expand Up @@ -5354,12 +5371,89 @@ $as_echo "no" >&6; }
;; #(
*) :
ZLIB_CPP="-I\$(srcdir)/zlib"
ZLIB="\$(ZLIB)"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: using included version" >&5
$as_echo "using included version" >&6; }
;;
esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to support zlib's minizip" >&5
$as_echo_n "checking whether to support zlib's minizip... " >&6; }
# Check whether --with-libminizip was given.
if test "${with_libminizip+set}" = set; then :
withval=$with_libminizip;
fi
case $with_libminizip in #(
"system") :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for zipOpen64 in -lminizip" >&5
$as_echo_n "checking for zipOpen64 in -lminizip... " >&6; }
if ${ac_cv_lib_minizip_zipOpen64+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lminizip $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char zipOpen64 ();
int
main ()
{
return zipOpen64 ();
;
return 0;
}
_ACEOF
if ac_fn_cxx_try_link "$LINENO"; then :
ac_cv_lib_minizip_zipOpen64=yes
else
ac_cv_lib_minizip_zipOpen64=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_minizip_zipOpen64" >&5
$as_echo "$ac_cv_lib_minizip_zipOpen64" >&6; }
if test "x$ac_cv_lib_minizip_zipOpen64" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBMINIZIP 1
_ACEOF
LIBS="-lminizip $LIBS"
fi
;; #(
"no") :
$as_echo "#define MINIZIP_INHIBITED 1" >>confdefs.h
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
;; #(
*) :
MINIZIP="\$(MINIZIP)"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: using included version" >&5
$as_echo "using included version" >&6; }
;;
esac
case "$target" in #(
*-*-mingw32*) :
Expand Down Expand Up @@ -5982,7 +6076,6 @@ esac
case "$target" in #(
*-linux-*) :
Expand Down Expand Up @@ -6097,12 +6190,13 @@ $as_echo "$DOCDIR" >&6; }
# AC_CHECK_HEADERS([fcntl.h inttypes.h libintl.h limits.h malloc.h stddef.h stdint.h stdlib.h string.h strings.h sys/ioctl.h sys/time.h termios.h unistd.h])
# set up HAVE_STDARG_H for zlib.
for ac_header in stdarg.h
for ac_header in unistd.h stdarg.h
do :
ac_fn_cxx_check_header_mongrel "$LINENO" "stdarg.h" "ac_cv_header_stdarg_h" "$ac_includes_default"
if test "x$ac_cv_header_stdarg_h" = xyes; then :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_cxx_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_STDARG_H 1
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
Expand Down Expand Up @@ -6150,7 +6244,14 @@ done
ac_config_files="$ac_config_files Makefile gbversion.h gui/setup.iss xmldoc/makedoc tools/mkcapabilities win32/gpsbabel.rc jeeps/Makefile shapelib/Makefile zlib/empty"
# make sure subdirectoires exist to receive object files.
# they may not exist if we are compiling outside the src tree.
as_dir=jeeps; as_fn_mkdir_p
as_dir=shapelib; as_fn_mkdir_p
as_dir=src/core; as_fn_mkdir_p
as_dir=zlib/contrib/minizip; as_fn_mkdir_p
ac_config_files="$ac_config_files Makefile gbversion.h gui/setup.iss xmldoc/makedoc tools/mkcapabilities win32/gpsbabel.rc"
ac_config_files="$ac_config_files gui/makelinuxdist.sh"
Expand Down Expand Up @@ -6852,9 +6953,6 @@ do
"xmldoc/makedoc") CONFIG_FILES="$CONFIG_FILES xmldoc/makedoc" ;;
"tools/mkcapabilities") CONFIG_FILES="$CONFIG_FILES tools/mkcapabilities" ;;
"win32/gpsbabel.rc") CONFIG_FILES="$CONFIG_FILES win32/gpsbabel.rc" ;;
"jeeps/Makefile") CONFIG_FILES="$CONFIG_FILES jeeps/Makefile" ;;
"shapelib/Makefile") CONFIG_FILES="$CONFIG_FILES shapelib/Makefile" ;;
"zlib/empty") CONFIG_FILES="$CONFIG_FILES zlib/empty" ;;
"gui/makelinuxdist.sh") CONFIG_FILES="$CONFIG_FILES gui/makelinuxdist.sh" ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
Expand Down
31 changes: 28 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,28 @@ AS_CASE([$with_zlib], ["system"], [
AC_DEFINE(ZLIB_INHIBITED, 1, [1 to inhibit our use of zlib.])
AC_MSG_RESULT([no])
], [
ZLIB_CPP="-I\$(srcdir)/zlib"
ZLIB="\$(ZLIB)"
AC_MSG_RESULT([using included version])
])
AC_SUBST(ZLIB_CPP)
AC_SUBST(ZLIB)

AC_MSG_CHECKING([whether to support zlib's minizip])
AC_ARG_WITH([libminizip],
[AS_HELP_STRING(
[--with-libminizip=(included)|system|no],
[])])
AS_CASE([$with_libminizip], ["system"], [
AC_CHECK_LIB([minizip], [zipOpen64])
], ["no"], [
AC_DEFINE(MINIZIP_INHIBITED, 1, [1 to inhibit our use of libminizip.])
AC_MSG_RESULT([no])
], [
MINIZIP="\$(MINIZIP)"
AC_MSG_RESULT([using included version])
])
AC_SUBST(MINIZIP)

AS_CASE(["$target"], [*-*-mingw32*], [
FILEINFO=fileinfo.o
Expand Down Expand Up @@ -265,7 +284,6 @@ AC_SUBST(USB_LIBS)
AC_SUBST(USB_CFLAGS)
AC_SUBST(OSJEEPS)
AC_SUBST(GBSER)
AC_SUBST(ZLIB)

dnl Linux HID support
AS_CASE(["$target"], [*-linux-*], [
Expand Down Expand Up @@ -336,7 +354,7 @@ AC_MSG_RESULT([$DOCDIR])

# AC_CHECK_HEADERS([fcntl.h inttypes.h libintl.h limits.h malloc.h stddef.h stdint.h stdlib.h string.h strings.h sys/ioctl.h sys/time.h termios.h unistd.h])
# set up HAVE_STDARG_H for zlib.
AC_CHECK_HEADERS([stdarg.h])
AC_CHECK_HEADERS([unistd.h stdarg.h])

# Checks for typedefs, structures, and compiler characteristics.
# AC_C_CONST
Expand Down Expand Up @@ -367,6 +385,13 @@ AC_SUBST(QT_INC_OPT)
AC_SUBST(QT_SYSINC_OPT)
AC_SUBST(QT_LIBS)

AC_CONFIG_FILES([Makefile gbversion.h gui/setup.iss xmldoc/makedoc tools/mkcapabilities win32/gpsbabel.rc jeeps/Makefile shapelib/Makefile zlib/empty])
# make sure subdirectoires exist to receive object files.
# they may not exist if we are compiling outside the src tree.
AS_MKDIR_P([jeeps])
AS_MKDIR_P([shapelib])
AS_MKDIR_P([src/core])
AS_MKDIR_P([zlib/contrib/minizip])

AC_CONFIG_FILES([Makefile gbversion.h gui/setup.iss xmldoc/makedoc tools/mkcapabilities win32/gpsbabel.rc])
AC_CONFIG_FILES([gui/makelinuxdist.sh], [chmod +x gui/makelinuxdist.sh])
AC_OUTPUT
2 changes: 1 addition & 1 deletion defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#if HAVE_LIBZ
#include <zlib.h>
#elif !ZLIB_INHIBITED
#include "zlib/zlib.h"
#include "zlib.h"
#endif
#include "gbfile.h"
#include "inifile.h"
Expand Down
Empty file removed jeeps/Makefile.in
Empty file.
Empty file removed shapelib/Makefile.in
Empty file.
7 changes: 6 additions & 1 deletion src/core/ziparchive.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@

#include "defs.h"
#include "src/core/logging.h"
#ifdef HAVE_LIBMINIZIP
#include <minizip/zip.h>
#else
#include "zlib/contrib/minizip/zip.h"
#endif

#include <QtCore/QFile>
#include <QtCore/QDebug>
Expand Down Expand Up @@ -89,4 +93,5 @@ bool ZipArchive::Add(QStringList items_to_add) {
return true;
}
return false;
}
}

5 changes: 5 additions & 0 deletions src/core/ziparchive.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@

#include <QtCore/QString>
#include <QtCore/QStringList>
#include "defs.h"
#ifdef HAVE_LIBMINIZIP
#include <minizip/zip.h>
#else
#include "zlib/contrib/minizip/zip.h"
#endif

class ZipArchive
{
Expand Down
Loading

0 comments on commit 8bf7ad2

Please sign in to comment.