From dbe0df44b68ae918e4d713924d974e3bdb93eac3 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 19 Aug 2005 16:11:46 +0000 Subject: [PATCH] Changes to allow building a W32 DLL --- ChangeLog | 6 ++ NEWS | 2 + autogen.sh | 2 +- configure.ac | 25 ++++++- gpgme/ChangeLog | 11 +++ gpgme/Makefile.am | 34 ++++++++- gpgme/ath-compat.c | 24 +++++++ gpgme/data-stream.c | 4 ++ gpgme/gpgme.def | 148 ++++++++++++++++++++++++++++++++++++++++ gpgme/libgpgme.vers | 3 + gpgme/ttyname_r.c | 4 ++ gpgme/versioninfo.rc.in | 52 ++++++++++++++ 12 files changed, 311 insertions(+), 4 deletions(-) create mode 100644 gpgme/gpgme.def create mode 100644 gpgme/versioninfo.rc.in diff --git a/ChangeLog b/ChangeLog index 83209c46..7a9423ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-08-19 Werner Koch + + * configure.ac [W32]: Create values for versioninfo.rc and list + substuture versioninfo.rc. + * configure.ac: Define ENABLE_GPGSM. + 2005-08-08 Werner Koch * configure.ac (stpcpy): Changed from replace to test. diff --git a/NEWS b/NEWS index 663f0a2f..d9a04b47 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,8 @@ Noteworthy changes in version 1.1.0 (unreleased) ------------------------------------------------ + * "./autogen.sh --build-w32" does now build gpgme.dll. + * You can now configure the backend engine file name and home directory to be used, as default and per context. diff --git a/autogen.sh b/autogen.sh index 1d69d84f..80e1136a 100755 --- a/autogen.sh +++ b/autogen.sh @@ -76,7 +76,7 @@ if test "$1" = "--build-w32"; then ./configure --enable-maintainer-mode --prefix=${w32root} \ --host=i586-mingw32msvc --build=${build} \ --with-gpg-error-prefix=${w32root} \ - --disable-shared --with-gpgsm=c:/gnupg/gpgsm.exe + --disable-shared --without-gpgsm exit $? fi diff --git a/configure.ac b/configure.ac index 2271357c..801a4c43 100644 --- a/configure.ac +++ b/configure.ac @@ -69,6 +69,8 @@ AH_VERBATIM([_REENTRANT], #endif]) AC_PROG_CC +AC_CHECK_TOOL(DLLTOOL, dlltool, :) +AC_CHECK_TOOL(WINDRES, windres, :) AC_SUBST(LIBGPGME_LT_CURRENT) @@ -342,9 +344,11 @@ if test "$GPGSM" = no; then fi else AC_DEFINE_UNQUOTED(GPGSM_PATH, "$GPGSM", [Path to the GPGSM binary.]) - AC_SUBST(GPGSM) + AC_DEFINE(ENABLE_GPGSM,1,[Whether GPGSM support is enabled]) fi AM_CONDITIONAL(HAVE_GPGSM, test "$GPGSM" != "no") + + dnl Check for GPGSM version requirement. GPGSM_VERSION=unknown ok=maybe @@ -439,6 +443,22 @@ AM_CONDITIONAL(BUILD_COMPLUS, test "$component_system" = "COM+") # (this is easier than to have a *.in file just for one substitution) GNUPG_FIX_HDR_VERSION(gpgme/gpgme.h, GPGME_VERSION) +# Generate values for the DLL version info +if test "$have_w32_system" = yes; then + BUILD_TIMESTAMP=`date --iso-8601=minutes` + changequote(,)dnl + BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'` + changequote([,])dnl + case "$VERSION" in + *-cvs) BUILD_FILEVERSION="${BUILD_FILEVERSION}0" ;; + *-rc*) BUILD_FILEVERSION="${BUILD_FILEVERSION}1" ;; + *) BUILD_FILEVERSION="${BUILD_FILEVERSION}2" ;; + esac +fi +AC_SUBST(BUILD_TIMESTAMP) +AC_SUBST(BUILD_FILEVERSION) + + # Substitution used for gpgme-config GPGME_CONFIG_LIBS="-lgpgme" GPGME_CONFIG_CFLAGS="" @@ -456,7 +476,8 @@ AC_SUBST(LTLIBOBJS) AC_CONFIG_FILES(Makefile assuan/Makefile gpgme/Makefile tests/Makefile tests/gpg/Makefile tests/gpgsm/Makefile - doc/Makefile complus/Makefile) + doc/Makefile complus/Makefile + gpgme/versioninfo.rc) AC_CONFIG_FILES(gpgme/gpgme-config, chmod +x gpgme/gpgme-config) AC_OUTPUT diff --git a/gpgme/ChangeLog b/gpgme/ChangeLog index caa73ad4..0a50a9fd 100644 --- a/gpgme/ChangeLog +++ b/gpgme/ChangeLog @@ -1,3 +1,14 @@ +2005-08-19 Werner Koch + + * gpgme.def: New. + * versioninfo.rc.in: New. + * Makefile.am: Addes support for building a W32 DLL. + + * ttyname_r.c (ttyname_r) [W32]: Return error. + * ath-compat.c [W32]: select and co are not yet supported; return + error. + * data-stream.c (stream_seek): Use ftell if ftello is not available. + 2005-08-08 Werner Koch * util.h (stpcpy): Renamed to .. diff --git a/gpgme/Makefile.am b/gpgme/Makefile.am index 90751e6e..5fd79ddd 100644 --- a/gpgme/Makefile.am +++ b/gpgme/Makefile.am @@ -19,7 +19,8 @@ ## Process this file with automake to produce Makefile.in -EXTRA_DIST = gpgme-config.in gpgme.m4 mkstatus libgpgme.vers +EXTRA_DIST = gpgme-config.in gpgme.m4 mkstatus libgpgme.vers \ + versioninfo.rc.in gpgme.de BUILT_SOURCES = status-table.h MOSTLYCLEANFILES = status-table.h bin_SCRIPTS = gpgme-config @@ -124,3 +125,34 @@ libgpgme_pth_la_LIBADD = libgpgme-real.la $(assuan_libobjs) @LTLIBOBJS@ \ status-table.h : gpgme.h $(srcdir)/mkstatus < $(srcdir)/gpgme.h > status-table.h + +# Special code to build a DLL. The current libtool (1.5.6) is not +# able to do this properly; we better use gcc's built in magic. +if HAVE_W32_SYSTEM + +w32_o_files = ath-compat.o conversion.o data-compat.o data-fd.o \ + data-mem.o data-stream.o data-user.o data.o debug.o \ + decrypt-verify.o decrypt.o delete.o edit.o encrypt-sign.o \ + encrypt.o engine-gpgsm.o engine.o error.o export.o genkey.o \ + get-env.o gpgme.o import.o key.o keylist.o memrchr.o \ + op-support.o passphrase.o progress.o putc_unlocked.o \ + rungpg.o sign.o signers.o trust-item.o trustlist.o \ + ttyname_r.o vasprintf.o verify.o version.o \ + w32-io.o w32-sema.o w32-util.o \ + wait-global.o wait-private.o wait-user.o wait.o + +all-local: gpgme.dll gpgme.dll.a + +install-exec-hook: + cp gpgme.dll gpgme.dll.a $(DESTDIR)$(libdir)/ + $(STRIP) $(DESTDIR)$(libdir)/gpgme.dll + +gpgme.dll gpgme.dll.a: gpgme.def $(w32_o_files) versioninfo.o + $(CC) -shared -o gpgme.dll gpgme.def $(w32_o_files) \ + versioninfo.o @GPG_ERROR_LIBS@ -Wl,--out-implib,gpgme.dll.a + + +.rc.o: + $(WINDRES) `test -f '$<' || echo '$(srcdir)/'`$< $@ + +endif diff --git a/gpgme/ath-compat.c b/gpgme/ath-compat.c index 3ac7a263..7efd586a 100644 --- a/gpgme/ath-compat.c +++ b/gpgme/ath-compat.c @@ -133,7 +133,11 @@ ath_select (int nfd, fd_set *rset, fd_set *wset, fd_set *eset, if (ath_ops && ath_ops->select) return ath_ops->select (nfd, rset, wset, eset, timeout); else +#ifdef HAVE_W32_SYSTEM + return -1; /* We don't support this yet. */ +#else return select (nfd, rset, wset, eset, timeout); +#endif } @@ -143,7 +147,11 @@ ath_waitpid (pid_t pid, int *status, int options) if (ath_ops && ath_ops->waitpid) return ath_ops->waitpid (pid, status, options); else +#ifdef HAVE_W32_SYSTEM + return -1; /* We don't support this yet. */ +#else return waitpid (pid, status, options); +#endif } @@ -153,7 +161,11 @@ ath_accept (int s, struct sockaddr *addr, socklen_t *length_ptr) if (ath_ops && ath_ops->accept) return ath_ops->accept (s, addr, length_ptr); else +#ifdef HAVE_W32_SYSTEM + return -1; /* We don't support this yet. */ +#else return accept (s, addr, length_ptr); +#endif } @@ -163,7 +175,11 @@ ath_connect (int s, const struct sockaddr *addr, socklen_t length) if (ath_ops && ath_ops->connect) return ath_ops->connect (s, addr, length); else +#ifdef HAVE_W32_SYSTEM + return -1; /* We don't support this yet. */ +#else return connect (s, addr, length); +#endif } @@ -173,7 +189,11 @@ ath_sendmsg (int s, const struct msghdr *msg, int flags) if (ath_ops && ath_ops->sendmsg) return ath_ops->sendmsg (s, msg, flags); else +#ifdef HAVE_W32_SYSTEM + return -1; /* We don't support this yet. */ +#else return sendmsg (s, msg, flags); +#endif } @@ -183,5 +203,9 @@ ath_recvmsg (int s, struct msghdr *msg, int flags) if (ath_ops && ath_ops->recvmsg) return ath_ops->recvmsg (s, msg, flags); else +#ifdef HAVE_W32_SYSTEM + return -1; /* We don't support this yet. */ +#else return recvmsg (s, msg, flags); +#endif } diff --git a/gpgme/data-stream.c b/gpgme/data-stream.c index 298ffb43..e7601685 100644 --- a/gpgme/data-stream.c +++ b/gpgme/data-stream.c @@ -63,7 +63,11 @@ stream_seek (gpgme_data_t dh, off_t offset, int whence) if (err) return -1; +#ifdef HAVE_FSEEKO return ftello (dh->data.stream); +#else + return ftell (dh->data.stream); +#endif } diff --git a/gpgme/gpgme.def b/gpgme/gpgme.def new file mode 100644 index 00000000..f7117e06 --- /dev/null +++ b/gpgme/gpgme.def @@ -0,0 +1,148 @@ +; gpgme.def - List of symbols to export. +; Copyright (C) 2005 g10 Code GmbH +; +; This file is part of GPGME. +; +; GPGME is free software; you can redistribute it and/or modify +; it under the terms of the GNU Lesser general Public License as +; published by the Free Software Foundation; either version 2.1 of +; the License, or (at your option) any later version. +; +; GPGME is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU Lesser General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public +; License along with this program; if not, write to the Free Software +; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + + +EXPORTS + gpgme_check_version @1 + gpgme_get_engine_info @2 + gpgme_engine_check_version @3 + + gpgme_err_code_from_errno @4 + gpgme_err_code_to_errno @5 + gpgme_err_make_from_errno @6 + gpgme_error_from_errno @7 + gpgme_strerror @8 + gpgme_strerror_r @9 + gpgme_strsource @10 + + gpgme_data_get_encoding @11 + gpgme_data_new @12 + gpgme_data_new_from_cbs @13 + gpgme_data_new_from_fd @14 + gpgme_data_new_from_file @15 + gpgme_data_new_from_filepart @16 + gpgme_data_new_from_mem @17 + gpgme_data_new_from_stream @18 + gpgme_data_read @19 + gpgme_data_release @20 + gpgme_data_release_and_get_mem @21 + gpgme_data_seek @22 + gpgme_data_set_encoding @23 + gpgme_data_write @24 + + gpgme_get_protocol_name @25 + gpgme_hash_algo_name @26 + gpgme_pubkey_algo_name @27 + + gpgme_new @28 + gpgme_get_armor @29 + gpgme_get_include_certs @30 + gpgme_get_io_cbs @31 + gpgme_get_keylist_mode @32 + gpgme_get_passphrase_cb @33 + gpgme_get_progress_cb @34 + gpgme_get_protocol @35 + gpgme_get_textmode @36 + gpgme_release @37 + gpgme_set_armor @38 + gpgme_set_include_certs @39 + gpgme_set_io_cbs @40 + gpgme_set_keylist_mode @41 + gpgme_set_locale @42 + gpgme_set_passphrase_cb @43 + gpgme_set_progress_cb @44 + gpgme_set_protocol @45 + gpgme_set_textmode @46 + gpgme_signers_add @47 + gpgme_signers_clear @48 + gpgme_signers_enum @49 + + gpgme_key_ref @50 + gpgme_key_unref @51 + gpgme_key_release @52 + + gpgme_trust_item_ref @53 + gpgme_trust_item_unref @54 + + gpgme_cancel @55 + gpgme_op_card_edit @56 + gpgme_op_card_edit_start @57 + gpgme_op_decrypt @58 + gpgme_op_decrypt_result @59 + gpgme_op_decrypt_start @60 + gpgme_op_decrypt_verify @61 + gpgme_op_decrypt_verify_start @62 + gpgme_op_delete @63 + gpgme_op_delete_start @64 + gpgme_op_edit @65 + gpgme_op_edit_start @66 + gpgme_op_encrypt @67 + gpgme_op_encrypt_result @68 + gpgme_op_encrypt_sign @69 + gpgme_op_encrypt_sign_start @70 + gpgme_op_encrypt_start @71 + gpgme_op_export @72 + gpgme_op_export_ext @73 + gpgme_op_export_ext_start @74 + gpgme_op_export_start @75 + gpgme_op_genkey @76 + gpgme_op_genkey_result @77 + gpgme_op_genkey_start @78 + gpgme_get_key @79 + gpgme_op_import @80 + gpgme_op_import_result @81 + gpgme_op_import_start @82 + gpgme_op_keylist_end @83 + gpgme_op_keylist_ext_start @84 + gpgme_op_keylist_next @85 + gpgme_op_keylist_result @86 + gpgme_op_keylist_start @87 + gpgme_op_sign @88 + gpgme_op_sign_result @89 + gpgme_op_sign_start @90 + gpgme_op_trustlist_end @91 + gpgme_op_trustlist_next @92 + gpgme_op_trustlist_start @93 + gpgme_op_verify @94 + gpgme_op_verify_result @95 + gpgme_op_verify_start @96 + gpgme_wait @97 + + gpgme_data_new_with_read_cb @98 + gpgme_data_rewind @99 + gpgme_get_sig_status @100 + gpgme_get_sig_string_attr @101 + gpgme_get_sig_ulong_attr @102 + gpgme_get_sig_key @103 + gpgme_key_get_string_attr @104 + gpgme_key_get_ulong_attr @105 + gpgme_key_sig_get_string_attr @106 + gpgme_key_sig_get_ulong_attr @107 + gpgme_op_import_ext @108 + gpgme_trust_item_get_int_attr @109 + gpgme_trust_item_get_string_attr @110 + gpgme_trust_item_release @111 + + gpgme_set_engine_info @112 + + gpgme_ctx_get_engine_info @113 + gpgme_ctx_set_engine_info @114 + +; END + diff --git a/gpgme/libgpgme.vers b/gpgme/libgpgme.vers index a16d37fa..ec7f6b98 100644 --- a/gpgme/libgpgme.vers +++ b/gpgme/libgpgme.vers @@ -17,6 +17,9 @@ # License along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA +#------------------------------------------------------- +# Please remember to add new functions also to gpgme.def +#------------------------------------------------------- GPGME_1.1 { global: diff --git a/gpgme/ttyname_r.c b/gpgme/ttyname_r.c index fb70ba5a..5cd29495 100644 --- a/gpgme/ttyname_r.c +++ b/gpgme/ttyname_r.c @@ -32,6 +32,9 @@ int ttyname_r (int fd, char *buf, size_t buflen) { +#if HAVE_W32_SYSTEM + errno = ENOTTY; /* The best error code I have under mingw. */ +#else char *tty; tty = ttyname (fd); @@ -41,4 +44,5 @@ ttyname_r (int fd, char *buf, size_t buflen) strncpy (buf, tty, buflen); buf[buflen - 1] = '\0'; return (strlen (tty) >= buflen) ? ERANGE : 0; +#endif } diff --git a/gpgme/versioninfo.rc.in b/gpgme/versioninfo.rc.in new file mode 100644 index 00000000..30397b96 --- /dev/null +++ b/gpgme/versioninfo.rc.in @@ -0,0 +1,52 @@ +/* versioninfo.rc.in - for gpgme + * Copyright (C) 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 + * modifications, as long as this notice is preserved. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY, to the extent permitted by law; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* This file is processed by configure to create versioninfo.rc */ + +#line __LINE__ "versioninfo.rc.in" + +#include + + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @BUILD_FILEVERSION@ + PRODUCTVERSION @BUILD_FILEVERSION@ + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x21L +#else + FILEFLAGS 0x20L +#endif + FILEOS 0x40004L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "Provided under the terms of the GNU Lesser General Public License.\0" + VALUE "CompanyName", "g10 Code GmbH\0" + VALUE "FileDescription", "GPGME - GnuPG Made Easy\0" + VALUE "FileVersion", "@VERSION@\0" + VALUE "InternalName", "gpgme\0" + VALUE "LegalCopyright", "Copyright © 2005 g10 Code GmbH\0" + VALUE "LegalTrademarks", "\0" + VALUE "OriginalFilename", "gpgme.dll\0" + VALUE "PrivateBuild", "\0" + VALUE "ProductName", "GPGME\0" + VALUE "ProductVersion", "@VERSION@\0" + VALUE "SpecialBuild", "@BUILD_TIMESTAMP@\0" + END + END +END +