[syslog-ng]fyi: building SyslogNG snapshot on OSX 10.3.8

OpenMacNews syslog-ng@lists.balabit.hu
Wed, 23 Feb 2005 11:48:37 -0800


hi all,

i've seen a couple of recent questions onlist re: building on Mac, so i thought 
i'd post my latest notes; the following works great for me.  HTH, but, as 
always, YMMV =)

note:

(a) i'm building from the latest src snapshots
(b) i'm using some updated build tools
(c) i'm linking against an EXTERNAL bind9 build's libs (currently 
bind-9.3.1rc1), rather than Apple's native -lresolv ...

fwiw, my ENV:

	% gcc --version
		gcc (GCC) 3.3 20030304 (Apple Computer, Inc. build 1671)
	% glibtool --version
		ltmain.sh (GNU libtool) 1.5.14 (1.1220.2.195 2005/02/12 12:12:33)
	% automake --version
		automake (GNU automake) 1.9.4
	% autoconf --version
		autoconf (GNU Autoconf) 2.59




setenv LIBOL_LOC "http://www.balabit.com/downloads/syslog-ng/1.6/src-snapshot"
setenv SYSLOGNG_LOC 
"http://www.balabit.com/downloads/syslog-ng/1.6/src-snapshot"
setenv LIBOL_VER "libol-0.3.15+20050216"
setenv SYSLOGNG_VER "syslog-ng-1.6.6+20050216"

cd /usr/ports/
wget $LIBOL_LOC/$LIBOL_VER.tar.gz
wget $SYSLOGNG_LOC/$SYSLOGNG_VER.tar.gz
gnutar zxvf $LIBOL_VER.tar.gz
gnutar zxvf $SYSLOGNG_VER.tar.gz

unsetenv CFLAGS CPPFLAGS CXX CXXFLAGS LDFLAGS LDDLFLAGS LD_PREBIND 
EXTRA_LDFLAGS EXTRA_LIBS LC_ALL LANG LINGUAS

################
## LIBOL
#
cd /usr/ports/$LIBOL_VER

glibtoolize --force --copy
aclocal
autoconf

./configure \
--prefix=/usr/local \
--enable-shared \
--enable-static

make
make install

################
## SYSLOG-NG
#
cd /usr/ports/$SYSLOGNG_VER

unsetenv CFLAGS CPPFLAGS CXX CXXFLAGS LDFLAGS LDDLFLAGS LD_PREBIND 
EXTRA_LDFLAGS EXTRA_LIBS LC_ALL LANG LINGUAS
setenv LDFLAGS "-bind_at_load -L/usr/local/bind9/lib -llwres -lbind9"
setenv CPPFLAGS "-I/usr/local/bind9/include"

# make a couple of changes ...
================================================================
(EDITOR) /usr/ports/$SYSLOGNG_VER/configure.in

@164
---	AC_CHECK_LIB(resolv, res_init)
+++	dnl AC_CHECK_LIB(resolv, res_init)
	   dnl on Linux res_init is a macro
---	AC_CHECK_LIB(resolv, __res_init)
+++	dnl AC_CHECK_LIB(resolv, __res_init)

@336
---    LIBS="$LIBS $LIBOL_LIBS -Wl,-Bstatic $LEXLIB $LIBWRAP_LIBS $LIBNET_LIBS 
-Wl,-Bdynamic"
+++    LIBS="$LIBS $LIBOL_LIBS -Wl,-dynamic $LEXLIB $LIBWRAP_LIBS $LIBNET_LIBS 
-Wl,-dynamic"

================================================================

glibtoolize --force --copy
aclocal
autoconf

./configure \
--prefix=/usr/local \
--enable-debug \
--enable-full-static=no \
--enable-tcp-wrapper

make
make install


################
## StartupItems
#

mkdir -p /Library/StartupItems/SyslogNG
==================================================
(EDITOR) /Library/StartupItems/SyslogNG/SyslogNG
#!/bin/sh

##
# SyslogNG StartupItem
#

. /etc/rc.common

RunService ()
{
	case $1 in
		start  ) StartService   ;;
		stop   ) StopService    ;;
		restart) RestartService ;;
		*      ) echo "$0: unknown argument: $1";;
	esac
}

##
# SyslogNG StartupItem Handlers
##

StartService ()
{
	if [ "${SYSLOGNG:=-NO-}" = "-YES-" ]; then
#		if [ -f "/var/run/syslog" ] ; then
			ConsoleMessage "Stopping SYSLOGD server"
			sleep 2
			killall syslogd
#		fi
		ConsoleMessage "Starting SYSLOG-NG Logging Server"
		/usr/local/sbin/syslog-ng -f /etc/syslog-ng/syslog-ng.conf -p 
/var/run/syslog-ng.pid
	fi
}

StopService ()
{
	if [ -f "/var/run/syslog-ng.pid" ] ; then
		ConsoleMessage "Stopping SYSLOG-NG Logging Server"
		sleep 2
		kill -9 `cat /var/run/syslog-ng.pid`
	fi
}

RestartService ()
{
	StopService
	StartService
}

RunService "$1"
=================================================================

==================================================
(EDITOR) /Library/StartupItems/SyslogNG/StartupParameters.plist
{
  Description     = "SyslogNG";
  Provides        = ("SyslogNG");
  Requires        = ("Resolver","Network Time","Disks");
  Uses            = ("Network");
  OrderPreference = "None";
  Messages =
  {
    start = "Starting SyslogNG";
    stop  = "Stopping SyslogNG";
  };
}
==================================================

==================================================
(EDITOR) /etc/hostconfig
+++	SYSLOGNG=-YES-
==================================================

chown -R root:wheel /Library/StartupItems/SyslogNG
chmod 755 /Library/StartupItems/SyslogNG
chmod 755 /Library/StartupItems/SyslogNG/SyslogNG
chmod 644 /Library/StartupItems/SyslogNG/StartupParameters.plist



# now let's see what we've got ...

% which syslog-ng
	/usr/local/sbin/syslog-ng

% ls -al /usr/local/sbin/syslog-ng
-rwxr-xr-x  1 root wheel 453968 Feb 23 11:17 /usr/local/sbin/syslog-ng

% otool -L /usr/local/sbin/syslog-ng
/usr/local/sbin/syslog-ng:
        /usr/local/bind9/lib/liblwres.1.dylib (compatibility version 4.0.0, 
current version 4.2.0)
        /usr/local/bind9/lib/libbind9.0.dylib (compatibility version 1.0.0, 
current version 1.5.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current 
version 71.1.1)

# start it up !!!

% /Library/StartupItems/SyslogNG/SyslogNG start

% ps -ax | grep syslog-ng
 9649  ??  Ss     0:00.02 /usr/local/sbin/syslog-ng -f 
/etc/syslog-ng/syslog-ng.conf -p /var/run/syslog-ng.pid


smooth sailing from here ... happy trails!

richard