[Opensrf-commits] r1909 - in trunk: . bin src src/c-apps src/libopensrf (dbs)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Jan 28 22:16:53 EST 2010


Author: dbs
Date: 2010-01-28 22:16:51 -0500 (Thu, 28 Jan 2010)
New Revision: 1909

Modified:
   trunk/bin/osrf_config.in
   trunk/bin/osrf_ctl.sh.in
   trunk/configure.ac
   trunk/src/Makefile.am
   trunk/src/c-apps/Makefile.am
   trunk/src/c-apps/timejson.c
   trunk/src/libopensrf/Makefile.am
Log:
Forward-port Dan McMahill's portability patches r1907 and r1908

Improve support for building, compiling, and running OpenSRF on non-Linux
distributions such as NetBSD.


Modified: trunk/bin/osrf_config.in
===================================================================
--- trunk/bin/osrf_config.in	2010-01-29 02:51:11 UTC (rev 1908)
+++ trunk/bin/osrf_config.in	2010-01-29 03:16:51 UTC (rev 1909)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 #
 # Copyright (C) 2008 Equinox Software, Inc.
 # Kevin Beswick <kevinbeswick00 at gmail.com>
@@ -20,7 +20,7 @@
 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 @@
 	 fi
 }
 
-function showAll {
+showAll() {
 	 echo @PACKAGE_STRING@	
 	 echo PREFIX=@prefix@
 	 echo BINDIR=@bindir@
@@ -48,7 +48,7 @@
 	 showInstalled;
 }
 
-function showHelp {
+showHelp() {
 	 echo 
 	 echo "------------------------------------------------------------"
 	 echo " osrf_config                                                "
@@ -77,53 +77,53 @@
 
 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

Modified: trunk/bin/osrf_ctl.sh.in
===================================================================
--- trunk/bin/osrf_ctl.sh.in	2010-01-29 02:51:11 UTC (rev 1908)
+++ trunk/bin/osrf_ctl.sh.in	2010-01-29 03:16:51 UTC (rev 1909)
@@ -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 @@
 [ $(whoami) != 'opensrf' ] && echo 'Must run as user "opensrf"' && exit;
 
 
-function usage {
-	echo "";
-	echo "usage: $0 [OPTION]... -c <c_config> -a <action>";
-	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 <c_config> -a <action>
+
+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 @@
 # ---------------------------------------------------------------------------
 # 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 @@
 		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 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 @@
 	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 @@
 	return 0;
 }
 
-function stop_c {
+stop_c() {
 	do_action "stop" $PID_OSRF_C "OpenSRF C";
 	sleep 1;
 	return 0;

Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac	2010-01-29 02:51:11 UTC (rev 1908)
+++ trunk/configure.ac	2010-01-29 03:16:51 UTC (rev 1909)
@@ -254,10 +254,10 @@
 	# Checks for libraries.
 	#-----------------------------
 
-	AC_CHECK_LIB([dl], [dlerror], [],AC_MSG_ERROR(***OpenSRF requires libdl))
-	AC_CHECK_LIB([ncurses], [initscr], [], AC_MSG_ERROR(***OpenSRF requires ncurses headers))
-	AC_CHECK_LIB([readline], [readline], [], AC_MSG_ERROR(***OpenSRF requires readline headers))
-	AC_CHECK_LIB([xml2], [xmlAddID], [], AC_MSG_ERROR(***OpenSRF requires libxml2 headers))
+	AC_SEARCH_LIBS([dlerror], [dl], [],AC_MSG_ERROR([***OpenSRF requires a library (typically libdl) that provides dlerror()]))
+	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))
+	AC_CHECK_LIB([xml2], [xmlAddID], [], AC_MSG_ERROR(***OpenSRF requires xml2 development headers))
 	# Check for libmemcached and set flags accordingly
 	PKG_CHECK_MODULES(memcached, libmemcached >= 0.8.0)
 	AC_SUBST(memcached_CFLAGS)
@@ -293,7 +293,7 @@
 	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

Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am	2010-01-29 02:51:11 UTC (rev 1908)
+++ trunk/src/Makefile.am	2010-01-29 03:16:51 UTC (rev 1909)
@@ -59,12 +59,15 @@
 	mkdir -p $(SOCK)
 
 install-exec-hook:
-	if [ "$(MAYBE_CORE)" ]; then 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'; fi
+	if [ "$(MAYBE_CORE)" ]; then \
+		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; \
+	fi
+	cp -r @srcdir@/javascript/* $(jsdir)/
 
 uninstall-hook:
 	rm -f @includedir@/opensrf/apachetools.h

Modified: trunk/src/c-apps/Makefile.am
===================================================================
--- trunk/src/c-apps/Makefile.am	2010-01-29 02:51:11 UTC (rev 1908)
+++ trunk/src/c-apps/Makefile.am	2010-01-29 03:16:51 UTC (rev 1909)
@@ -21,13 +21,16 @@
 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

Modified: trunk/src/c-apps/timejson.c
===================================================================
--- trunk/src/c-apps/timejson.c	2010-01-29 02:51:11 UTC (rev 1908)
+++ trunk/src/c-apps/timejson.c	2010-01-29 03:16:51 UTC (rev 1909)
@@ -57,8 +57,11 @@
 	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;
 }
 

Modified: trunk/src/libopensrf/Makefile.am
===================================================================
--- trunk/src/libopensrf/Makefile.am	2010-01-29 02:51:11 UTC (rev 1908)
+++ trunk/src/libopensrf/Makefile.am	2010-01-29 03:16:51 UTC (rev 1909)
@@ -1,4 +1,4 @@
-# Copyright (C) 2008 Equinox Software, Inc.
+# Copyright (C) 2008-2010 Equinox Software, Inc., and others
 # Kevin Beswick <kevinbeswick00 at gmail.com>
 #
 # This program is free software; you can redistribute it and/or
@@ -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 -lopensrf
+LDADD = -lopensrf
 
 DISTCLEANFILES = Makefile.in Makefile
 



More information about the opensrf-commits mailing list