From 369daede614d7e794e6af57e8543a623cc619e69 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 --- trunk/ChangeLog | 6 ++ trunk/NEWS | 2 + trunk/autogen.sh | 2 +- trunk/configure.ac | 25 +++++- trunk/gpgme/ChangeLog | 11 +++ trunk/gpgme/Makefile.am | 34 +++++++- trunk/gpgme/ath-compat.c | 24 ++++++ trunk/gpgme/data-stream.c | 4 + trunk/gpgme/gpgme.def | 148 ++++++++++++++++++++++++++++++++++ trunk/gpgme/libgpgme.vers | 3 + trunk/gpgme/ttyname_r.c | 4 + trunk/gpgme/versioninfo.rc.in | 52 ++++++++++++ 12 files changed, 311 insertions(+), 4 deletions(-) create mode 100644 trunk/gpgme/gpgme.def create mode 100644 trunk/gpgme/versioninfo.rc.in diff --git a/trunk/ChangeLog b/trunk/ChangeLog index 83209c4..7a9423e 100644 --- a/trunk/ChangeLog +++ b/trunk/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/trunk/NEWS b/trunk/NEWS index 663f0a2..d9a04b4 100644 --- a/trunk/NEWS +++ b/trunk/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/trunk/autogen.sh b/trunk/autogen.sh index 1d69d84..80e1136 100755 --- a/trunk/autogen.sh +++ b/trunk/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/trunk/configure.ac b/trunk/configure.ac index 2271357..801a4c4 100644 --- a/trunk/configure.ac +++ b/trunk/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/trunk/gpgme/ChangeLog b/trunk/gpgme/ChangeLog index caa73ad..0a50a9f 100644 --- a/trunk/gpgme/ChangeLog +++ b/trunk/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/trunk/gpgme/Makefile.am b/trunk/gpgme/Makefile.am index 90751e6..5fd79dd 100644 --- a/trunk/gpgme/Makefile.am +++ b/trunk/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/trunk/gpgme/ath-compat.c b/trunk/gpgme/ath-compat.c index 3ac7a26..7efd586 100644 --- a/trunk/gpgme/ath-compat.c +++ b/trunk/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/trunk/gpgme/data-stream.c b/trunk/gpgme/data-stream.c index 298ffb4..e760168 100644 --- a/trunk/gpgme/data-stream.c +++ b/trunk/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/trunk/gpgme/gpgme.def b/trunk/gpgme/gpgme.def new file mode 100644 index 0000000..f7117e0 --- /dev/null +++ b/trunk/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/trunk/gpgme/libgpgme.vers b/trunk/gpgme/libgpgme.vers index a16d37f..ec7f6b9 100644 --- a/trunk/gpgme/libgpgme.vers +++ b/trunk/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/trunk/gpgme/ttyname_r.c b/trunk/gpgme/ttyname_r.c index fb70ba5..5cd2949 100644 --- a/trunk/gpgme/ttyname_r.c +++ b/trunk/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/trunk/gpgme/versioninfo.rc.in b/trunk/gpgme/versioninfo.rc.in new file mode 100644 index 0000000..30397b9 --- /dev/null +++ b/trunk/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 + -- 2.26.2