diff options
author | Werner Koch <[email protected]> | 2010-10-28 14:24:52 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2010-10-28 14:24:52 +0000 |
commit | 8c512c3cf0d596eafb708abe3581486894dfe20e (patch) | |
tree | d10f93a9f1e8502301b9d245ba6426ca67de6057 | |
parent | Post release updates (diff) | |
download | libgpg-error-8c512c3cf0d596eafb708abe3581486894dfe20e.tar.gz libgpg-error-8c512c3cf0d596eafb708abe3581486894dfe20e.zip |
Add some code to allow building with MSC.
-rw-r--r-- | ChangeLog | 13 | ||||
-rwxr-xr-x | contrib/conf-w32ce-msc/build.mk | 95 | ||||
-rwxr-xr-x | contrib/conf-w32ce-msc/config.h | 153 | ||||
-rw-r--r-- | src/gpg-error.h.in | 2 | ||||
-rw-r--r-- | src/init.c | 4 | ||||
-rw-r--r-- | src/mkstrtable.awk | 2 | ||||
-rw-r--r-- | src/w32-gettext.c | 14 |
7 files changed, 275 insertions, 8 deletions
@@ -1,3 +1,16 @@ +2010-10-28 Werner Koch <[email protected]> + + * contrib/conf-w32ce-msc/build.mk: New. + * contrib/conf-w32ce-msc/config.h: New. + + * src/mkstrtable.awk: s/inline/GPG_ERR_INLINE/ + * src/w32-gettext.c: Include gpg-error.h and replace all + __inline__ by GPG_ERR_INLINE. + (module_init): Use _GPG_ERR_CONSTRUCTOR. + (_gpg_w32__init_gettext_module): Build also if we don't have + constructors + * src/gpg-error.h.in (GPG_ERR_INLINE) [_MSC_VER]: Define as __inline. + 2010-10-26 Werner Koch <[email protected]> Release 1.10. diff --git a/contrib/conf-w32ce-msc/build.mk b/contrib/conf-w32ce-msc/build.mk new file mode 100755 index 0000000..745a129 --- /dev/null +++ b/contrib/conf-w32ce-msc/build.mk @@ -0,0 +1,95 @@ +# build.mk - Makefile to build libgpg-error using Visual-C +# Copyright 2010 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 file 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 is a helper make script to build libgpg-error for WindowsCE +# using the Microsoft Visual C compiler. + +# The target build directry where we run the Visual C compiler/ +# This needs to be an absolute directory name. +targetdir = /home/smb/xppro-gnu/src/libgpg-error + + +help: + @echo "Run " + @echo " make -f ../contrib/conf-w32ce-msc/build.mk copy-source" + @echo "on the POSIX system and then" + @echo " nmake -f build.mk all" + @echo "on the Windows system" + + +CFLAGS = -DHAVE_CONFIG_H -DDLL_EXPORT -I. +LDFLAGS = + +# Standard source files +sources = \ + init.c init.h \ + strsource.c \ + strerror.c \ + code-to-errno.c \ + code-from-errno.c \ + w32-gettext.c \ + gettext.h \ + err-sources.h \ + err-codes.h + +# Sources files in this directory inclduing this Makefile +conf_sources = \ + build.mk \ + config.h + +# Source files built by running the standard build system. +built_sources = \ + code-from-errno.h \ + code-to-errno.h \ + err-codes-sym.h \ + err-sources-sym.h \ + errnos-sym.h \ + gpg-error.h \ + mkerrcodes.h \ + mkw32errmap.map.c \ + gpg-error.def + +copy-static-source: + @if [ ! -f ./w32-gettext.c ]; then \ + echo "Please cd to the src/ directory first"; \ + exit 1; \ + fi + cp -t $(targetdir) $(sources); + cd ../contrib/conf-w32ce-msc ; cp -t $(targetdir) $(conf_sources) + + +copy-built-source: + @if [ ! -f ./mkw32errmap.map.c ]; then \ + echo "Please build using ./autogen.sh --build-w32ce first"; \ + exit 1; \ + fi + cp -t $(targetdir) $(built_sources) + +copy-source: copy-static-source copy-built-source + + +all: $(sources) $(conf_sources) $(built_sources) + $(CC) $(CFLAGS) -c w32-gettext.c + $(CC) $(CFLAGS) -c init.c + $(CC) $(CFLAGS) -c strsource.c + $(CC) $(CFLAGS) -c strerror.c + $(CC) $(CFLAGS) -c code-to-errno.c + $(CC) $(CFLAGS) -c code-from-errno.c + $(CC) $(LDFLAGS) /LD -Felibgpg-error-0.dll \ + w32-gettext.obj init.obj strsource.obj strerror.obj \ + code-to-errno.obj code-from-errno.obj \ + gpg-error.def + +# Note that install needs to be run on the POSIX platform and the all +# is only to make sure we build everything; it won't compile anything +# because Visual-C is probably not installed on that platform. +install: all + @echo fixme Install the files diff --git a/contrib/conf-w32ce-msc/config.h b/contrib/conf-w32ce-msc/config.h new file mode 100755 index 0000000..bf24d98 --- /dev/null +++ b/contrib/conf-w32ce-msc/config.h @@ -0,0 +1,153 @@ +/* config.h for building with Visual-C for WindowsCE. + * Copyright 2010 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 file 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 was originally created by running + * ./autogen.sh --build-w32ce + * on svn revision 253 (libgpg-error 1.10) and then adjusted to work + * with Visual-C. + */ + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "1.11-msc1" + + +/* Name of package */ +#define PACKAGE "libgpg-error" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "[email protected]" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "libgpg-error" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "libgpg-error " PACKAGE_VERSION + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "libgpg-error" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + + + +/* Define to 1 if translation of program messages to the user's native + language is requested. */ +/* #undef ENABLE_NLS */ + +/* Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the + CoreFoundation framework. */ +/* #undef HAVE_CFLOCALECOPYCURRENT */ + +/* Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in + the CoreFoundation framework. */ +/* #undef HAVE_CFPREFERENCESCOPYAPPVALUE */ + +/* Define if the GNU dcgettext() function is already present or preinstalled. + */ +/* #undef HAVE_DCGETTEXT */ + +/* Define to 1 if you have the declaration of `strerror_r', and to 0 if you + don't. */ +#define HAVE_DECL_STRERROR_R 0 + +/* Define to 1 if you have the <dlfcn.h> header file. */ +/* #undef HAVE_DLFCN_H */ + +/* Define if the GNU gettext() function is already present or preinstalled. */ +/* #undef HAVE_GETTEXT */ + +/* Define if you have the iconv() function and it works. */ +/* #undef HAVE_ICONV */ + +/* Define to 1 if you have the <inttypes.h> header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the <locale.h> header file. */ +/* #undef HAVE_LOCALE_H */ + +/* Define to 1 if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strerror_r' function. */ +/* #undef HAVE_STRERROR_R */ + +/* Define to 1 if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the <sys/types.h> header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* Defined if we run on WindowsCE */ +#define HAVE_W32CE_SYSTEM 1 + +/* Defined if we run on a W32 API based system */ +#define HAVE_W32_SYSTEM 1 + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#define LT_OBJDIR ".libs/" + +/* Define to 1 if your C compiler doesn't accept -c and -o together. */ +/* #undef NO_MINUS_C_MINUS_O */ + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to 1 if strerror_r returns char *. */ +/* #undef STRERROR_R_CHAR_P */ + + +/* Version number of package */ +#define VERSION PACKAGE_VERSION + +/* Define to 1 if on MINIX. */ +/* #undef _MINIX */ + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +/* #undef _POSIX_1_SOURCE */ + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + + +/* Force using of NLS for W32 even if no libintl has been found. This is + okay because we have our own gettext implementation for W32. */ +#if defined(HAVE_W32_SYSTEM) && !defined(ENABLE_NLS) +#define ENABLE_NLS 1 +#endif +/* For building we need to define these macro. */ +#define GPG_ERR_ENABLE_GETTEXT_MACROS 1 +#define GPG_ERR_ENABLE_ERRNO_MACROS 1 + +/* snprintf is not part of oldnames.lib thus we redefine it here. */ +#define snprintf _snprintf + diff --git a/src/gpg-error.h.in b/src/gpg-error.h.in index ae1be21..f89945a 100644 --- a/src/gpg-error.h.in +++ b/src/gpg-error.h.in @@ -25,6 +25,8 @@ #ifdef __GNUC__ #define GPG_ERR_INLINE __inline__ +#elif _MSC_VER >= 1300 +#define GPG_ERR_INLINE __inline #elif __STDC_VERSION__ >= 199901L #define GPG_ERR_INLINE inline #else @@ -380,6 +380,10 @@ DllMain (HINSTANCE hinst, DWORD reason, LPVOID reserved) tls_index = TlsAlloc (); if (tls_index == TLS_OUT_OF_INDEXES) return FALSE; +#ifndef _GPG_ERR_HAVE_CONSTRUCTOR + /* If we have not constructors (e.g. MSC) we call it here. */ + _gpg_w32__init_gettext_module (); +#endif /* falltru. */ case DLL_THREAD_ATTACH: tls = LocalAlloc (LPTR, sizeof *tls); diff --git a/src/mkstrtable.awk b/src/mkstrtable.awk index d97e150..c9de9c1 100644 --- a/src/mkstrtable.awk +++ b/src/mkstrtable.awk @@ -157,7 +157,7 @@ END { print " " pos[coded_msgs]; print " };"; print ""; - print "static inline int"; + print "static GPG_ERR_INLINE int"; print namespace "msgidxof (int code)"; print "{"; print " return (0 ? 0"; diff --git a/src/w32-gettext.c b/src/w32-gettext.c index ca4fbbd..0d0c1eb 100644 --- a/src/w32-gettext.c +++ b/src/w32-gettext.c @@ -50,7 +50,7 @@ #endif /*!jnlib_malloc*/ #include "init.h" - +#include "gpg-error.h" /* localname.c from gettext BEGIN. */ @@ -1026,7 +1026,7 @@ my_nl_locale_name (const char *categoryname) /* Support functions. */ -static __inline__ uint32_t +static GPG_ERR_INLINE uint32_t do_swap_u32 (uint32_t i) { return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24); @@ -1041,8 +1041,8 @@ do_swap_u32 (uint32_t i) /* The so called `hashpjw' function by P.J. Weinberger [see Aho/Sethi/Ullman, COMPILERS: Principles, Techniques and Tools, 1986, 1987 Bell Telephone Laboratories, Inc.] */ -static __inline__ unsigned long -hash_string( const char *str_param ) +static GPG_ERR_INLINE unsigned long +hash_string (const char *str_param) { unsigned long int hval, g; const char *str = str_param; @@ -1147,11 +1147,11 @@ static char *current_domainname; /* Constructor for this module. This can only be used if we are a - DLL. IF used as a static lib we can't control the process set; for + DLL. If used as a static lib we can't control the process set; for example it might be used with a main module which is not build with mingw and thus does not know how to call the constructors. */ #ifdef DLL_EXPORT -static void module_init (void) __attribute__ ((__constructor__)); +static void module_init (void) _GPG_ERR_CONSTRUCTOR; #endif static void module_init (void) @@ -1165,7 +1165,7 @@ module_init (void) } } -#ifndef DLL_EXPORT +#if !defined(DLL_EXPORT) || !defined(_GPG_ERR_HAVE_CONSTRUCTOR) void _gpg_w32__init_gettext_module (void) { |