From 59e52d87145f090bdf6d069bfc81c0db9d682039 Mon Sep 17 00:00:00 2001 From: David Hampton Date: Sat, 18 May 2002 20:32:22 +0000 Subject: [PATCH] Mac OS X support, round 2. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6878 57a11ea4-9604-0410-9ed3-97b8803252fd --- ChangeLog | 19 +++++++++++++++++++ configure.in | 34 ++++++++++++++++++++++++++++++++++ lib/libc/Makefile.am | 2 +- lib/libc/localtime_r.c | 1 + ltmain.sh | 11 +++++++++++ src/backend/file/Makefile.am | 1 + src/backend/file/sixtp-utils.c | 31 ++++++++++++++++++++++++++----- src/engine/Makefile.am | 5 ++++- src/engine/date.c | 7 +++++++ src/gnome/druid-hierarchy.c | 9 +++++++++ src/scm/main.scm | 5 ++++- 11 files changed, 117 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 56ca6c4b2e..00523602e5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2002-05-18 David Hampton + + * configure.in: Work around incompatibilities between autoconf + 2.52 and 2.53 wrt creating the LIBLTOBJS variable. + + * ltmain.sh: Mac OS X tweaks. + + * libc/Makefile.am: Use LIBLTOBJS instead of LIBOBJS. + + * src/backend/file/sixtp-utils.c (string_to_gint64): + (string_to_gint32): (string_to_timespec_nsecs): Work around bugs + in Mac OS X version of sscanf. + + * src/gnome/druid-hierarchy.c (gnc_get_ea_locale_dir): Work around + lack of LC_MESSAGES on Mac OS X. + + * src/scm/main.scm (local-prefixes): Work around + lack of LC_MESSAGES on Mac OS X. + 2002-05-14 David Hampton * configure.in (AC_CANONICAL_HOST): Remove redundant command. diff --git a/configure.in b/configure.in index 0ab85515a7..3e39028fda 100644 --- a/configure.in +++ b/configure.in @@ -805,6 +805,40 @@ chmod u+x src/bin/overrides/gnucash-make-guids ### -------------------------------------------------------------------------- ### Makefile creation +# +# God, this is ugly.... +# +# The libtool 2.52 and 2.53 info pages specify two different +# *incompatible* ways to create the LTLIBOBJS variable. 2.53 makes it +# an error to directly access the LIBOBJS variable, but then provides +# a hack to get past this test by introducing the four character +# sequence '@&t@' that expands to the empty string. This expansion +# occurs *after* the LIBOBJS usage test has taken place. +# Unfortunately, the '@&t@' sequence doesn't exist in 2.52, so we're +# stuck with this big ugly version check. Sigh! At some point in the +# future, Autoconf 2.53 can be made a required version and this code +# can be cleaned up. +# +# This is necessary so that .o files in LIBOBJS are also built via +# the ANSI2KNR-filtering rules. + +AUTOCONF_VERSION=`autoconf --version` +autoconf_major_version=`echo ${AUTOCONF_VERSION} | \ + sed 's/^.*GNU Autoconf.* \([[0-9]]*\)\.\([[0-9]]*\).*$/\1/'` +autoconf_minor_version=`echo ${AUTOCONF_VERSION} | \ + sed 's/^.*GNU Autoconf.* \([[0-9]]*\)\.\([[0-9]]*\).*$/\2/'` +if test $autoconf_major_version -gt 2 -o \ + \( $autoconf_major_version -eq 2 -a \ + $autoconf_minor_version -gt 52 \) ; then + LIB@&t@OBJS=`echo "$LIB@&t@OBJS" | + sed 's,\.[[^.]]* ,$U&,g;s,\.[[^.]]*$,$U&,'` + LTLIBOBJS=`echo "$LIB@&t@OBJS" | + sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'` +else + LTLIBOBJS=`echo "$LIBOBJS" | sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'` +fi +AC_SUBST(LTLIBOBJS) + AC_OUTPUT( m4/Makefile intl/Makefile dnl # Makefiles Makefile diff --git a/lib/libc/Makefile.am b/lib/libc/Makefile.am index 59e08e66b3..5b82243f54 100644 --- a/lib/libc/Makefile.am +++ b/lib/libc/Makefile.am @@ -9,7 +9,7 @@ libc_missing_la_SOURCES = libc-missing-noop.c # This will automatically be filled in with the necessary object file # names. Configure does this based upon the AC_REPLACE_FUNCS macros. -libc_missing_la_LIBADD = @LIBOBJS@ +libc_missing_la_LIBADD = @LTLIBOBJS@ # Not currently used. If added to AC_REPLACE_FUNCS then this line # should be removed. diff --git a/lib/libc/localtime_r.c b/lib/libc/localtime_r.c index ee6cab3b4d..cce996511b 100644 --- a/lib/libc/localtime_r.c +++ b/lib/libc/localtime_r.c @@ -4,6 +4,7 @@ #if !HAVE_LOCALTIME_R #include #include +#include "localtime_r.h" #if HAVE_PTHREAD_MUTEX_INIT #include diff --git a/ltmain.sh b/ltmain.sh index 50de244984..90c74a31f7 100644 --- a/ltmain.sh +++ b/ltmain.sh @@ -3296,7 +3296,18 @@ EOF if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then eval cmds=\"$archive_expsym_cmds\" else + save_deplibs="$deplibs" + for conv in $convenience; do + tmp_deplibs= + for test_deplib in $deplibs; do + if test "$test_deplib" != "$conv"; then + tmp_deplibs="$tmp_deplibs $test_deplib" + fi + done + deplibs="$tmp_deplibs" + done eval cmds=\"$archive_cmds\" + deplibs="$save_deplibs" fi if len=`expr "X$cmds" : ".*"` && diff --git a/src/backend/file/Makefile.am b/src/backend/file/Makefile.am index 87a3f76e74..a97e7c136d 100644 --- a/src/backend/file/Makefile.am +++ b/src/backend/file/Makefile.am @@ -8,6 +8,7 @@ AM_CFLAGS = \ -I${top_srcdir}/src/engine \ -I${top_srcdir}/src/gnc-module \ -I${top_srcdir}/src/core-utils\ + -I${top_srcdir}/lib/libc\ ${GLIB_CFLAGS} libgncmod_backend_file_la_SOURCES = \ diff --git a/src/backend/file/sixtp-utils.c b/src/backend/file/sixtp-utils.c index 11cf44dde6..99747d2cda 100644 --- a/src/backend/file/sixtp-utils.c +++ b/src/backend/file/sixtp-utils.c @@ -41,6 +41,12 @@ #include "guid.h" #include "gnc-numeric.h" #include "gnc-engine-util.h" +#ifndef HAVE_STRPTIME +#include "strptime.h" +#endif +#ifndef HAVE_LOCALTIME_R +#include "localtime_r.h" +#endif static short module = MOD_IO; @@ -214,10 +220,19 @@ string_to_gint64(const gchar *str, gint64 *v) g_return_val_if_fail(str, FALSE); /* must use "<" here because %n's effects aren't well defined */ - if(sscanf(str, " " GNC_SCANF_LLD " %n", &v_in, &num_read) < 1) { + if(sscanf(str, " " GNC_SCANF_LLD "%n", &v_in, &num_read) < 1) { return(FALSE); } + /* + * Mac OS X version 10.1 and under has a silly bug where scanf + * returns bad values in num_read if there is a space before %n. It + * is fixed in the next release 10.2 afaik + */ + while( (*((gchar*)str + num_read)!='\0') && + isspace(*((char*)str + num_read))) + num_read++; + if (v) *v = v_in; @@ -237,9 +252,12 @@ string_to_gint32(const gchar *str, gint32 *v) int v_in; /* must use "<" here because %n's effects aren't well defined */ - if(sscanf(str, " %d %n", &v_in, &num_read) < 1) { + if(sscanf(str, " %d%n", &v_in, &num_read) < 1) { return(FALSE); } + while( (*((gchar*)str + num_read)!='\0') && + isspace(*((char*)str + num_read))) + num_read++; if (v) *v = v_in; @@ -475,14 +493,17 @@ string_to_timespec_secs(const gchar *str, Timespec *ts) { } gboolean -string_to_timespec_nsecs(const gchar *str, Timespec *ts) { - +string_to_timespec_nsecs(const gchar *str, Timespec *ts) +{ long int nanosecs; int charcount; if (!str || !ts) return FALSE; - sscanf(str, " %ld %n", &nanosecs, &charcount); + sscanf(str, " %ld%n", &nanosecs, &charcount); + while( (*((gchar*)str + charcount)!='\0') && + isspace(*((char*)str + charcount))) + charcount++; if(charcount != strlen(str)) return(FALSE); diff --git a/src/engine/Makefile.am b/src/engine/Makefile.am index 6d920f1fdd..939ba856da 100644 --- a/src/engine/Makefile.am +++ b/src/engine/Makefile.am @@ -2,7 +2,10 @@ SUBDIRS = . test-core test pkglib_LTLIBRARIES = libgw-engine.la libgw-kvp.la libgncmod-engine.la -AM_CFLAGS = -I${top_srcdir}/src/gnc-module ${GNUCASH_ENGINE_CFLAGS} +AM_CFLAGS = \ + -I${top_srcdir}/lib/libc \ + -I${top_srcdir}/src/gnc-module \ + ${GNUCASH_ENGINE_CFLAGS} libgncmod_engine_la_SOURCES = \ Account.c \ diff --git a/src/engine/date.c b/src/engine/date.c index 2a59eec9ee..b15fef38c9 100644 --- a/src/engine/date.c +++ b/src/engine/date.c @@ -46,6 +46,13 @@ #include "date.h" #include "gnc-engine-util.h" +#ifndef HAVE_STRPTIME +#include "strptime.h" +#endif +#ifndef HAVE_LOCALTIME_R +#include "localtime_r.h" +#endif + #define NANOS_PER_SECOND 1000000000 #ifdef HAVE_LANGINFO_D_FMT diff --git a/src/gnome/druid-hierarchy.c b/src/gnome/druid-hierarchy.c index c1b0ff32db..3fd56729b3 100644 --- a/src/gnome/druid-hierarchy.c +++ b/src/gnome/druid-hierarchy.c @@ -312,7 +312,16 @@ gnc_get_ea_locale_dir(const char *top_dir) gchar *locale; struct stat buf; +#ifdef HAVE_LC_MESSAGES locale = g_strdup(setlocale(LC_MESSAGES, NULL)); +#else + /* + * Mac OS X 10.1 and earlier, not only doesn't have LC_MESSAGES + * setlocale can sometimes return NULL instead of "C" + */ + locale = g_strdup(setlocale(LC_ALL, NULL) ? + setlocale(LC_ALL, NULL) : "C"); +#endif ret = g_strdup_printf("%s/%s", top_dir, locale); diff --git a/src/scm/main.scm b/src/scm/main.scm index ef751eb7b3..83acd4a3a8 100644 --- a/src/scm/main.scm +++ b/src/scm/main.scm @@ -314,7 +314,10 @@ string and 'directories' must be a list of strings." ;; thereof. (define (locale-prefixes) - (let* ((locale (setlocale LC_MESSAGES)) + ;; Mac OS X. 10.1 and earlier don't have LC_MESSAGES. Fall back to + ;; LC_ALL for those systems. + (let* ((locale (or (false-if-exception (setlocale LC_MESSAGES)) + (setlocale LC_ALL))) (strings (cond ((not (string? locale)) ()) ((equal? locale "C") ()) ((<= (string-length locale) 4) (list locale))