From: dbs Date: Fri, 29 Jan 2010 02:48:00 +0000 (+0000) Subject: Apply patches for enhancing portability, from Dan McMahill X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=f42087159ab322eae4a1c7c09082ce60083c8aeb;p=OpenSRF.git Apply patches for enhancing portability, from Dan McMahill The following is a list of the patches and a brief description of what they are supposed to address. They were needed for building OpenSRF-1.2.0 (the most recent release) on a NetBSD system. patch-aa -- some systems have dlerror() in libc instead of libdl so use AC_SEARCH_LIBS to see if we need an explicit -ldl or not. Fail in the same way as the previous code if we can't find dlerror() anywhere. malloc_stats() is malloc implementation specific so check for it and define HAVE_MALLOC_STATS if we do. patch-ab -- No need to explicitly list -lxml2 -ldl -lmemcache in LDADD. These were automatically filled in via the LIBS variable which is filled in via AC_SEARCH_LIBS and AC_CHECK_LIB. Also this way -ldl only shows up if it is actually needed. patch-ac -- Only conditionally call malloc_stats() if it exists. On systems without malloc_stats(), just print a warning to the effect. patch-ad -- Instead of using -lopensrf for foo_la_LIBADD use @top_builddir@/src/libopensrf/libopensrf.la. This is the way to link to the not-yet-installed libtool library we just built. patch-af -- "sed -i" is a GNU sed extension and not portable to Solaris or the various BSDs. Rework the target a little to be more portable. patch-ag -- Use /bin/sh instead of /bin/bash. And to make sure this will work on non-Linux systems where /bin/sh is *not* bash, make things a little more portable. The biggest is that function foo { code here } is replaced by the more portable foo() {code here} syntax. patch-ah -- Use /bin/sh instead of /bin/bash. And to make sure this will work on non-Linux systems where /bin/sh is *not* bash, make things a little more portable. Of note, "echo -e" is non-portable so instead use as "here document" which is more portable and also I think easier to edit anyway. Also address the function syntax and finally "==" is a bash extension to "test". "=" does the same thing and is portable to other shells. Developer's Certificate of Origin 1.1 By making a contribution to this project, I certify that: (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. Signed-off-by: Dan McMahill git-svn-id: svn://svn.open-ils.org/OpenSRF/branches/rel_1_2@1907 9efc2488-bf62-4759-914b-345cdb29e865 --- diff --git a/bin/osrf_config.in b/bin/osrf_config.in index a61bfe8..5002b04 100644 --- a/bin/osrf_config.in +++ b/bin/osrf_config.in @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # Copyright (C) 2008 Equinox Software, Inc. # Kevin Beswick @@ -20,7 +20,7 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ datarootdir=@datarootdir@ -function showInstalled { +showInstalled() { JAVA=@OSRF_INSTALL_JAVA@ PYTHON=@OSRF_INSTALL_PYTHON@ if test "$JAVA" = "true"; then @@ -31,7 +31,7 @@ function showInstalled { fi } -function showAll { +showAll() { echo @PACKAGE_STRING@ echo PREFIX=@prefix@ echo BINDIR=@bindir@ @@ -48,7 +48,7 @@ function showAll { showInstalled; } -function showHelp { +showHelp() { echo echo "------------------------------------------------------------" echo " osrf_config " @@ -77,53 +77,53 @@ function showHelp { case "$1" in --installed) - showInstalled; + showInstalled ;; --cconfig) cconfig; ;; --libxml) - echo @LIBXML2_HEADERS@; + echo @LIBXML2_HEADERS@ ;; --apr) - echo @APR_HEADERS@; + echo @APR_HEADERS@ ;; --apache) - echo @APACHE2_HEADERS@; + echo @APACHE2_HEADERS@ ;; --prefix) echo @prefix@ ;; --version) - echo @PACKAGE_STRING@; + echo @PACKAGE_STRING@ ;; --bindir) echo @bindir@ ;; --libdir) - echo @libdir@; + echo @libdir@ ;; --sysconfdir) - echo @sysconfdir@; + echo @sysconfdir@ ;; --localstatedir) - echo @localstatedir@; + echo @localstatedir@ ;; --tmpdir) - echo @TMP@; + echo @TMP@ ;; --apxs) - echo @APXS2@; + echo @APXS2@ ;; --includedir) - echo @includedir@; + echo @includedir@ ;; --docdir) - echo @docdir@; + echo @docdir@ ;; --help) - showHelp; + showHelp ;; *) - showAll; + showAll ;; esac diff --git a/bin/osrf_ctl.sh.in b/bin/osrf_ctl.sh.in index 625b7a3..b1a10df 100755 --- a/bin/osrf_ctl.sh.in +++ b/bin/osrf_ctl.sh.in @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -28,40 +28,41 @@ OSRF_HOSTNAME="" [ $(whoami) != 'opensrf' ] && echo 'Must run as user "opensrf"' && exit; -function usage { - echo ""; - echo "usage: $0 [OPTION]... -c -a "; - echo ""; - echo "Mandatory parameters:"; - echo -e " -a\t\taction to perform"; - echo ""; - echo "Optional parameters:"; - echo -e " -c\t\tfull path to C configuration file (opensrf_core.xml)"; - echo -e " -d\t\tstore PID files in this directory"; - echo -e " -l\t\taccept 'localhost' as the fully-qualified domain name"; - echo ""; - echo "Actions include:"; - echo -e "\tstart_router" - echo -e "\tstop_router" - echo -e "\trestart_router" - echo -e "\tstart_perl" - echo -e "\tstop_perl" - echo -e "\trestart_perl" - echo -e "\tstart_c" - echo -e "\tstop_c" - echo -e "\trestart_c" - echo -e "\tstart_osrf" - echo -e "\tstop_osrf" - echo -e "\trestart_osrf" - echo -e "\tstop_all" - echo -e "\tstart_all" - echo -e "\trestart_all" - echo ""; - echo "Examples:"; - echo " $0 -a restart_all"; - echo " $0 -l -c opensrf_core.xml -a restart_all"; - echo ""; - exit; +usage() { + cat << EOF + +usage: $0 [OPTION]... -c -a + +Mandatory parameters: + -a action to perform + +Optional parameters:"; + -c full path to C configuration file (opensrf_core.xml) + -d store PID files in this directory + -l accept 'localhost' as the fully-qualified domain name + +Actions include: + start_router + stop_router + restart_router + start_perl + stop_perl + restart_perl + start_c + stop_c + restart_c + start_osrf + stop_osrf + restart_osrf + stop_all + start_all + restart_all + +Examples: + $0 -a restart_all + $0 -l -c opensrf_core.xml -a restart_all + +EOF } # --------------------------------------------------------------------------- @@ -96,13 +97,13 @@ PID_OSRF_C="$OPT_PID_DIR/osrf_c.pid"; # --------------------------------------------------------------------------- # Utility code for checking the PID files # --------------------------------------------------------------------------- -function do_action { +do_action() { action="$1"; pidfile="$2"; item="$3"; - if [ $action == "start" ]; then + if [ $action = "start" ]; then if [ -e $pidfile ]; then pid=$(cat $pidfile); @@ -112,7 +113,7 @@ function do_action { echo "Starting $item"; fi; - if [ $action == "stop" ]; then + if [ $action = "stop" ]; then if [ ! -e $pidfile ]; then echo "$item not running"; @@ -138,7 +139,7 @@ function do_action { # --------------------------------------------------------------------------- -function start_router { +start_router() { do_action "start" $PID_ROUTER "OpenSRF Router"; opensrf_router $OPT_CONFIG routers sleep 2; # give the router procs time to fork and appear in ps @@ -147,28 +148,28 @@ function start_router { return 0; } -function stop_router { +stop_router() { do_action "stop" $PID_ROUTER "OpenSRF Router"; return 0; } -function start_perl { +start_perl() { echo "Starting OpenSRF Perl"; opensrf-perl.pl --verbose --pid-dir $OPT_PID_DIR \ --config $OPT_CONFIG --action start_all --settings-startup-pause 3 return 0; } -function stop_perl { +stop_perl() { echo "Stopping OpenSRF Perl"; opensrf-perl.pl --verbose --pid-dir $OPT_PID_DIR --config $OPT_CONFIG --action stop_all sleep 1; return 0; } -function start_c { +start_c() { host=$OSRF_HOSTNAME - if [ "_$host" == "_" ]; then + if [ "_$host" = "_" ]; then host=$(perl -MNet::Domain=hostfqdn -e 'print hostfqdn()'); fi; @@ -180,7 +181,7 @@ function start_c { return 0; } -function stop_c { +stop_c() { do_action "stop" $PID_OSRF_C "OpenSRF C"; sleep 1; return 0; diff --git a/configure.ac b/configure.ac index cc9d705..b050a02 100644 --- a/configure.ac +++ b/configure.ac @@ -202,7 +202,7 @@ fi # Checks for libraries. #----------------------------- -AC_CHECK_LIB([dl], [dlerror], [],AC_MSG_ERROR(***OpenSRF requires libdl)) +AC_SEARCH_LIBS([dlerror], [dl], [], AC_MSG_ERROR([***OpenSRF requires a library (typically libdl) that provides dlerror()])) AC_SEARCH_LIBS([mc_req_free], [memcache], [], AC_MSG_ERROR(***OpenSRF requires memcache development headers)) AC_CHECK_LIB([ncurses], [initscr], [], AC_MSG_ERROR(***OpenSRF requires ncurses development headers)) AC_CHECK_LIB([readline], [readline], [], AC_MSG_ERROR(***OpenSRF requires readline development headers)) @@ -240,7 +240,7 @@ AC_TYPE_SIGNAL AC_FUNC_STRFTIME AC_FUNC_STRTOD AC_FUNC_VPRINTF -AC_CHECK_FUNCS([bzero dup2 gethostbyname gethostname gettimeofday memset select socket strcasecmp strchr strdup strerror strncasecmp strndup strrchr strtol]) +AC_CHECK_FUNCS([bzero dup2 gethostbyname gethostname gettimeofday malloc_stats memset select socket strcasecmp strchr strdup strerror strncasecmp strndup strrchr strtol]) #------------------------------------ # Configuration and output diff --git a/src/Makefile.am b/src/Makefile.am index d695ad0..fd4d831 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -48,12 +48,12 @@ install-exec-local: mkdir -p $(jsdir) install-exec-hook: - sed -i 's|LOCALSTATEDIR|$(VAR)|g' '$(DESTDIR)@sysconfdir@/opensrf.xml.example' - sed -i 's|SYSCONFDIR|$(ETCDIR)|g' '$(DESTDIR)@sysconfdir@/opensrf.xml.example' - sed -i 's|LOCALSTATEDIR|$(VAR)|g' '$(DESTDIR)@sysconfdir@/opensrf_core.xml.example' - sed -i 's|SYSCONFDIR|$(ETCDIR)|g' '$(DESTDIR)@sysconfdir@/opensrf_core.xml.example' - sed -i 's|LOCALSTATEDIR|$(VAR)|g' '$(DESTDIR)@sysconfdir@/srfsh.xml.example' - sed -i 's|SYSCONFDIR|$(ETCDIR)|g' '$(DESTDIR)@sysconfdir@/srfsh.xml.example' + for f in opensrf.xml.example opensrf_core.xml.example srfsh.xml.example ; do \ + mv "$(DESTDIR)@sysconfdir@/$${f}" "$(DESTDIR)@sysconfdir@/$${f}.bak" ; \ + sed -e 's|LOCALSTATEDIR|$(VAR)|g' -e 's|SYSCONFDIR|$(ETCDIR)|g' \ + "$(DESTDIR)@sysconfdir@/$${f}.bak" > "$(DESTDIR)@sysconfdir@/$${f}" ; \ + rm "$(DESTDIR)@sysconfdir@/$${f}.bak" ; \ + done cp -r @srcdir@/javascript/* $(jsdir)/ uninstall-hook: diff --git a/src/c-apps/Makefile.am b/src/c-apps/Makefile.am index 80e0e3d..8f3d1e7 100644 --- a/src/c-apps/Makefile.am +++ b/src/c-apps/Makefile.am @@ -19,13 +19,16 @@ noinst_PROGRAMS = timejson lib_LTLIBRARIES = osrf_dbmath.la osrf_math.la osrf_version.la timejson_SOURCES = timejson.c -timejson_LDADD = -lopensrf +timejson_LDADD = @top_builddir@/src/libopensrf/libopensrf.la + osrf_dbmath_la_SOURCES = osrf_dbmath.c osrf_dbmath_la_LDFLAGS = $(AM_LDFLAGS) -module -osrf_dbmath_la_LIBADD = -lopensrf +osrf_dbmath_la_LIBADD = @top_builddir@/src/libopensrf/libopensrf.la + osrf_math_la_SOURCES = osrf_math.c osrf_math_la_LDFLAGS = $(AM_LDFLAGS) -module -osrf_math_la_LIBADD = -lopensrf +osrf_math_la_LIBADD = @top_builddir@/src/libopensrf/libopensrf.la + osrf_version_la_SOURCES = osrf_version.c osrf_version_la_LDFLAGS = $(AM_LDFLAGS) -module -osrf_version_la_LIBADD = -lopensrf +osrf_version_la_LIBADD = @top_builddir@/src/libopensrf/libopensrf.la diff --git a/src/c-apps/timejson.c b/src/c-apps/timejson.c index 0ee1e94..9e4bba3 100644 --- a/src/c-apps/timejson.c +++ b/src/c-apps/timejson.c @@ -57,8 +57,11 @@ int main( void ) { else printf( "Address space: %lu\n", (unsigned long) rlim.rlim_cur ); +#ifdef HAVE_MALLOC_STATS malloc_stats(); - +#else + fprintf(stderr, "malloc_stats() is not available on your system\n"); +#endif return rc; } diff --git a/src/libopensrf/Makefile.am b/src/libopensrf/Makefile.am index 479e3dc..841908f 100644 --- a/src/libopensrf/Makefile.am +++ b/src/libopensrf/Makefile.am @@ -14,7 +14,7 @@ AM_CFLAGS = $(DEF_CFLAGS) -DASSUME_STATELESS -DOSRF_STRICT_PARAMS -rdynamic -fno-strict-aliasing -DOSRF_JSON_ENABLE_XML_UTILS AM_LDFLAGS = $(DEF_LDFLAGS) -R $(libdir) -LDADD = -lxml2 -ldl -lmemcache -lopensrf +LDADD = -lopensrf OSRF_INC = @top_srcdir@/include/opensrf