From e86f9181adc947c235d270d2d3fcc3265c1f29cc Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 9 Mar 2005 16:03:05 +0000 Subject: [PATCH] * acinclude.m4 (GNUPG_CHECK_VA_COPY): Assume no when cross-compiling. * Makefile.am (EXTRA_DIST): Include autogen.sh * autogen.sh: Added the usual code to build for W32 (--build-w32). * configure.ac: Fixed the mingw32 host string, removed OS/2 stuff. (HAVE_DRIVE_LETTERS): Removed. (HAVE_W32_SYSTEM): Added. (AC_GNU_SOURCE): New to replace the identical AH_VERBATIM. (AH_BOTTOM): Added. * w32-util.c (_gpgme_get_gpg_path, _gpgme_get_gpgsm_path): Do not cast away type checks. * io.h [W32]: Do not include stdio.h. If it is needed do it at the right place. * data.h [W32]: Removed kludge for EOPNOTSUP. * data.c, data-compat.c [W32]: Explicitly test for it here. --- ChangeLog | 16 ++++++++++++- Makefile.am | 2 +- acinclude.m4 | 16 +++++++++---- autogen.sh | 56 ++++++++++++++++++++++++++++++++++++++++++++ complus/gpgcom.c | 2 +- configure.ac | 50 +++++++++++++++++++++++++-------------- gpgme/ChangeLog | 14 +++++++++++ gpgme/ath-compat.c | 7 +++--- gpgme/ath.h | 14 +++++++---- gpgme/data-compat.c | 5 ++++ gpgme/data.c | 5 ++++ gpgme/engine-gpgsm.c | 6 +++-- gpgme/gpgme.c | 5 ++-- gpgme/gpgme.h | 3 ++- gpgme/io.h | 3 --- gpgme/w32-util.c | 8 +++++-- 16 files changed, 170 insertions(+), 42 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2b6a949..6e85315 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2005-03-09 Werner Koch + + * acinclude.m4 (GNUPG_CHECK_VA_COPY): Assume no when cross-compiling. + + * Makefile.am (EXTRA_DIST): Include autogen.sh + + * autogen.sh: Added the usual code to build for W32 (--build-w32). + + * configure.ac: Fixed the mingw32 host string, removed OS/2 stuff. + (HAVE_DRIVE_LETTERS): Removed. + (HAVE_W32_SYSTEM): Added. + (AC_GNU_SOURCE): New to replace the identical AH_VERBATIM. + (AH_BOTTOM): Added. + 2004-12-28 Werner Koch Released 1.0.2. @@ -564,7 +578,7 @@ * autogen.sh: Added option --build-w32. - Copyright 2001, 2002, 2003, 2004 g10 Code GmbH + Copyright 2001, 2002, 2003, 2004, 2005 g10 Code GmbH This file is free software; as a special exception the author gives unlimited permission to copy and/or distribute it, with or without diff --git a/Makefile.am b/Makefile.am index 2a5ed5e..905c3ce 100644 --- a/Makefile.am +++ b/Makefile.am @@ -23,7 +23,7 @@ ACLOCAL_AMFLAGS = -I m4 AUTOMAKE_OPTIONS = dist-bzip2 -EXTRA_DIST = gpgme.spec.in +EXTRA_DIST = gpgme.spec.in autogen.sh if BUILD_ASSUAN assuan = assuan diff --git a/acinclude.m4 b/acinclude.m4 index c62e596..9676656 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -50,8 +50,11 @@ dnl Actual test code taken from glib-1.1. AC_DEFUN([GNUPG_CHECK_VA_COPY], [ AC_MSG_CHECKING(whether va_lists must be copied by value) AC_CACHE_VAL(gnupg_cv_must_copy_va_byval,[ - gnupg_cv_must_copy_va_byval=no - AC_TRY_RUN([ + if test "$cross_compiling" = yes; then + gnupg_cv_must_copy_va_byval=no + else + gnupg_cv_must_copy_va_byval=no + AC_TRY_RUN([ #include void f (int i, ...) { @@ -69,10 +72,15 @@ AC_DEFUN([GNUPG_CHECK_VA_COPY], f (0, 42); return 0; } - ],gnupg_cv_must_copy_va_byval=yes) + ],gnupg_cv_must_copy_va_byval=yes) + fi ]) if test "$gnupg_cv_must_copy_va_byval" = yes; then AC_DEFINE(MUST_COPY_VA_BYVAL,1,[used to implement the va_copy macro]) fi - AC_MSG_RESULT($gnupg_cv_must_copy_va_byval) + if test "$cross_compiling" = yes; then + AC_MSG_RESULT(assuming $gnupg_cv_must_copy_va_byval) + else + AC_MSG_RESULT($gnupg_cv_must_copy_va_byval) + fi ]) diff --git a/autogen.sh b/autogen.sh index 3e4c96c..1d69d84 100755 --- a/autogen.sh +++ b/autogen.sh @@ -29,6 +29,62 @@ check_version () { } +DIE=no + +# Used to cross-compile for Windows. +if test "$1" = "--build-w32"; then + tmp=`dirname $0` + tsdir=`cd "$tmp"; pwd` + shift + if [ ! -f $tsdir/config.guess ]; then + echo "$tsdir/config.guess not found" >&2 + exit 1 + fi + build=`$tsdir/config.guess` + + [ -z "$w32root" ] && w32root="$HOME/w32root" + echo "Using $w32root as standard install directory" >&2 + + # See whether we have the Debian cross compiler package or the + # old mingw32/cpd system + if i586-mingw32msvc-gcc --version >/dev/null 2>&1 ; then + host=i586-mingw32msvc + crossbindir=/usr/$host/bin + else + host=i386--mingw32 + if ! mingw32 --version >/dev/null; then + echo "We need at least version 0.3 of MingW32/CPD" >&2 + exit 1 + fi + crossbindir=`mingw32 --install-dir`/bin + # Old autoconf version required us to setup the environment + # with the proper tool names. + CC=`mingw32 --get-path gcc` + CPP=`mingw32 --get-path cpp` + AR=`mingw32 --get-path ar` + RANLIB=`mingw32 --get-path ranlib` + export CC CPP AR RANLIB + fi + + if [ -f "$tsdir/config.log" ]; then + if ! head $tsdir/config.log | grep "$host" >/dev/null; then + echo "Pease run a 'make distclean' first" >&2 + exit 1 + fi + fi + + ./configure --enable-maintainer-mode --prefix=${w32root} \ + --host=i586-mingw32msvc --build=${build} \ + --with-gpg-error-prefix=${w32root} \ + --disable-shared --with-gpgsm=c:/gnupg/gpgsm.exe + + exit $? +fi + + + + + # Grep the required versions from configure.ac autoconf_vers=`sed -n '/^AC_PREREQ(/ { s/^.*(\(.*\))/\1/p diff --git a/complus/gpgcom.c b/complus/gpgcom.c index 7c967be..6670369 100644 --- a/complus/gpgcom.c +++ b/complus/gpgcom.c @@ -123,7 +123,7 @@ main (int argc, char **argv ) opt.homedir = getenv("GNUPGHOME"); if( !opt.homedir || !*opt.homedir ) { - #ifdef HAVE_DRIVE_LETTERS + #ifdef HAVE_DOSISH_SYSTEM opt.homedir = "c:/gnupg"; #else opt.homedir = "~/.gnupg"; diff --git a/configure.ac b/configure.ac index 80c2cfa..b62e357 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ # configure.ac for GPGME # Copyright (C) 2000 Werner Koch (dd9jn) -# Copyright (C) 2001, 2002, 2003, 2004 g10 Code GmbH +# Copyright (C) 2001, 2002, 2003, 2004, 2005 g10 Code GmbH # # This file is part of GPGME. # @@ -43,8 +43,7 @@ GPGME_CONFIG_API_VERSION=1 NEED_GPG_VERSION=1.2.2 NEED_GPGSM_VERSION=1.9.6 ############################################## -AC_PREREQ(2.52) -AC_REVISION($Revision$) + PACKAGE=$PACKAGE_NAME VERSION=$PACKAGE_VERSION @@ -57,11 +56,8 @@ AM_INIT_AUTOMAKE($PACKAGE, $VERSION) AM_MAINTAINER_MODE AC_CANONICAL_HOST -AH_VERBATIM([_GNU_SOURCE], -[/* Enable GNU extensions on systems that have them. */ -#ifndef _GNU_SOURCE -# define _GNU_SOURCE -#endif]) +# Enable GNU extensions on systems that have them. +AC_GNU_SOURCE AH_VERBATIM([_REENTRANT], [/* To allow the use of GPGME in multithreaded programs we have to use @@ -72,6 +68,16 @@ AH_VERBATIM([_REENTRANT], # define _REENTRANT 1 #endif]) +AH_BOTTOM([ +/* Some environments miss the definition for EOPNOTSUPP. We provide + the error code here and test where neded whether it should be + defined. Can't do the test here due to the order of includes. */ +#ifdef HAVE_W32_SYSTEM +#define VALUE_FOR_EOPNOTSUPP 95 +#endif /*!HAVE_W32_SYSTEM*/ + +]) + AC_PROG_CC @@ -109,17 +115,13 @@ AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes") GPG_DEFAULT=no GPGSM_DEFAULT=no component_system=None +have_dosish_system=no +have_w32_system=no case "${host}" in - *-*-mingw32* | i?86-emx-os2 | i?86-*-os2*emx | i?86-*-msdosdjgpp* ) + *-mingw32*) # special stuff for Windoze NT - # OS/2 with the EMX environment - # DOS with the DJGPP environment - AC_DEFINE(HAVE_DRIVE_LETTERS, , - [Defined if we run on some of the PCDOS like systems (DOS, - Windoze, OS/2) with special properties like no file modes.]) - AC_DEFINE(HAVE_DOSISH_SYSTEM, , - [Defined if the filesystem uses driver letters.]) have_dosish_system=yes + have_w32_system=yes GPG_DEFAULT='c:\\gnupg\\gpg.exe' # XXX Assuan is not supported in this configuration. #GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe' @@ -141,7 +143,21 @@ case "${host}" in # GPGSM_DEFAULT='/usr/bin/gpgsm' ;; esac -AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = "yes") + +if test "$have_dosish_system" = yes; then + AC_DEFINE(HAVE_DOSISH_SYSTEM,1, + [Defined if we run on some of the PCDOS like systems + (DOS, Windoze. OS/2) with special properties like + no file modes]) +fi +AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = yes) + +if test "$have_w32_system" = yes; then + AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system]) +fi +AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes) + + AM_CONDITIONAL(HAVE_PTH, test "$have_pth" = "yes") AM_CONDITIONAL(HAVE_PTHREAD, test "$have_pthread" = "yes") diff --git a/gpgme/ChangeLog b/gpgme/ChangeLog index dc398fe..8ba7807 100644 --- a/gpgme/ChangeLog +++ b/gpgme/ChangeLog @@ -1,3 +1,17 @@ +2005-03-09 Werner Koch + + * w32-util.c (_gpgme_get_gpg_path, _gpgme_get_gpgsm_path): Do not + cast away type checks. + + * io.h [W32]: Do not include stdio.h. If it is needed do it at + the right place. + + * data.h [W32]: Removed kludge for EOPNOTSUP. + * data.c, data-compat.c [W32]: Explicitly test for it here. + + Replaced use of _WIN32 by HAVE_W32_SYSTEM except for public header + files. + 2005-03-07 Timo Schulz * gpgme.h: [_WIN32] Removed ssize_t typedef. diff --git a/gpgme/ath-compat.c b/gpgme/ath-compat.c index 110bd51..3ac7a26 100644 --- a/gpgme/ath-compat.c +++ b/gpgme/ath-compat.c @@ -22,17 +22,18 @@ #include #endif -#include #include +#include #ifdef HAVE_SYS_SELECT_H # include #else # include #endif #include -#ifndef _WIN32 +#ifndef HAVE_W32_SYSTEM #include -#endif +#endif /*!HAVE_W32_SYSTEM*/ + #include "ath.h" diff --git a/gpgme/ath.h b/gpgme/ath.h index ef74126..8a323eb 100644 --- a/gpgme/ath.h +++ b/gpgme/ath.h @@ -21,12 +21,15 @@ #ifndef ATH_H #define ATH_H -#ifdef _WIN32 -struct msghdr { int dummy; }; -typedef int socklen_t; +#ifdef HAVE_W32_SYSTEM + /* fixme: Check how we did it in libgcrypt. */ + struct msghdr { int dummy; }; + typedef int socklen_t; # include # include -#else + +#else /*!HAVE_W32_SYSTEM*/ + # ifdef HAVE_SYS_SELECT_H # include # else @@ -34,7 +37,8 @@ typedef int socklen_t; # endif # include # include -#endif + +#endif /*!HAVE_W32_SYSTEM*/ diff --git a/gpgme/data-compat.c b/gpgme/data-compat.c index 6b6663b..b55fd61 100644 --- a/gpgme/data-compat.c +++ b/gpgme/data-compat.c @@ -30,6 +30,11 @@ #include "data.h" #include "util.h" +#if defined(HAVE_W32_SYSTEM) && !defined(EOPNOTSUPP) +#define EOPNOTSUPP VALUE_FOR_EOPNOTSUPP +#endif + + /* Create a new data buffer filled with LENGTH bytes starting from OFFSET within the file FNAME or stream STREAM (exactly one must be diff --git a/gpgme/data.c b/gpgme/data.c index 3ba644f..d4bac06 100644 --- a/gpgme/data.c +++ b/gpgme/data.c @@ -33,6 +33,11 @@ #include "ops.h" #include "io.h" +#if defined(HAVE_W32_SYSTEM) && !defined(EOPNOTSUPP) +#define EOPNOTSUPP VALUE_FOR_EOPNOTSUPP +#endif + + gpgme_error_t _gpgme_data_new (gpgme_data_t *r_dh, struct _gpgme_data_cbs *cbs) diff --git a/gpgme/engine-gpgsm.c b/gpgme/engine-gpgsm.c index 71b01c9..c35087b 100644 --- a/gpgme/engine-gpgsm.c +++ b/gpgme/engine-gpgsm.c @@ -19,11 +19,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef _WIN32 #if HAVE_CONFIG_H #include #endif +#ifndef HAVE_W32_SYSTEM + #include #include #include @@ -1597,4 +1598,5 @@ struct engine_ops _gpgme_engine_ops_gpgsm = gpgsm_io_event, gpgsm_cancel }; -#endif + +#endif /*!HAVE_W32_SYSTEM*/ diff --git a/gpgme/gpgme.c b/gpgme/gpgme.c index f95ae3f..9e5171c 100644 --- a/gpgme/gpgme.c +++ b/gpgme/gpgme.c @@ -344,7 +344,7 @@ gpgme_get_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs) gpgme_error_t gpgme_set_locale (gpgme_ctx_t ctx, int category, const char *value) { -#ifndef _WIN32 +#ifndef HAVE_W32_SYSTEM int failed = 0; char *new_lc_ctype; char *new_lc_messages; @@ -398,7 +398,8 @@ gpgme_set_locale (gpgme_ctx_t ctx, int category, const char *value) SET_ONE_LOCALE (messages, MESSAGES); if (!ctx) UNLOCK (def_lc_lock); -#endif + +#endif /*!HAVE_W32_SYSTEM*/ return 0; } diff --git a/gpgme/gpgme.h b/gpgme/gpgme.h index 2e22113..3db2d97 100644 --- a/gpgme/gpgme.h +++ b/gpgme/gpgme.h @@ -72,7 +72,8 @@ extern "C" { AM_PATH_GPGME macro) check that this header matches the installed library. Warning: Do not edit the next line. configure will do that for you! */ -#define GPGME_VERSION "1.0.1" +#define GPGME_VERSION "1.1.0-cvs" + /* Some opaque data types used by GPGME. */ diff --git a/gpgme/io.h b/gpgme/io.h index 58de071..4770701 100644 --- a/gpgme/io.h +++ b/gpgme/io.h @@ -22,9 +22,6 @@ #ifndef IO_H #define IO_H -#ifdef _WIN32 -#include -#endif /* A single file descriptor passed to spawn. For child fds, dup_to specifies the fd it should become in the child. */ diff --git a/gpgme/w32-util.c b/gpgme/w32-util.c index 5254fcc..e4fac8e 100644 --- a/gpgme/w32-util.c +++ b/gpgme/w32-util.c @@ -51,6 +51,10 @@ read_w32_registry_string (const char *root, const char *dir, const char *name) DWORD n1, nbytes; char *result = NULL; +#ifdef HAVE_W32_SYSTEM +#warning Check that this code matches the one used by gnupg +#endif + if (!root) root_key = HKEY_CURRENT_USER; else if (!strcmp (root, "HKEY_CLASSES_ROOT")) @@ -120,7 +124,7 @@ _gpgme_get_gpg_path (void) LOCK (get_path_lock); if (!gpg_program) - gpg_program = (char*)find_program_in_registry ("gpgProgram"); + gpg_program = find_program_in_registry ("gpgProgram"); #ifdef GPG_PATH if (!gpg_program) gpg_program = GPG_PATH; @@ -136,7 +140,7 @@ _gpgme_get_gpgsm_path (void) LOCK (get_path_lock); if (!gpgsm_program) - gpgsm_program = (char*)find_program_in_registry ("gpgsmProgram"); + gpgsm_program = find_program_in_registry ("gpgsmProgram"); #ifdef GPGSM_PATH if (!gpgsm_program) gpgsm_program = GPGSM_PATH; -- 2.26.2