Compiling dansguardian 2.10.1.1 on Mac OS X Snow Leopard

I’m trying the DansGuardian content filtering proxy at home. But it wouldn’t compile on my modern Snow Leopard machine.

Salient errors:

String.cpp: In member function ‘off_t String::toOffset()’:
String.cpp:167: warning: format ‘%d’ expects type ‘int*’, but argument 3 has type ‘off_t*’
In file included from HTTPHeader.hpp:38,
                 from DownloadManager.hpp:30,
                 from OptionContainer.hpp:27,
                 from ConnectionHandler.hpp:27,
                 from ConnectionHandler.cpp:25:
RegExp.hpp:31:23: error: pcreposix.h: No such file or directory
In file included from HTTPHeader.hpp:38,
                 from DownloadManager.hpp:30,
                 from OptionContainer.hpp:27,
                 from ConnectionHandler.hpp:27,
                 from ConnectionHandler.cpp:25:
RegExp.hpp:82: error: ‘regex_t’ does not name a type
make[2]: *** [dansguardian-ConnectionHandler.o] Error 1
make[2]: *** Waiting for unfinished jobs....
mv -f .deps/dansguardian-String.Tpo .deps/dansguardian-String.Po
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

And a wild goose chase: don’t alter your PCRE_LIBS environment variable or you’ll have trouble like this:

ld: in /Developer/SDKs/MacOSX10.5.sdk/usr/include/php/ext/pcre/pcrelib, can't map file, errno=22

What worked:

 
# this is the main thing-- help it find pcreposix.h !
export CPPFLAGS=-I/Developer/SDKs/MacOSX10.5.sdk/usr/include/php/ext/pcre/pcrelib
 
# only the last two are my preferences, 
# the others are from the INSTALL doc
 
./configure --localstatedir=/var  \
         --mandir=/usr/share/man/  \
         --bindir=/usr/local/sbin/ \
         --with-logdir=/usr/local/dansguardian/logs/ \
         --enable-email=yes
 
make -j 2
sudo make install

starting at boot with daemonic

I got squid using Fink, which uses daemonic for startup/init scripts. So hopefully I can use it to start dansguardian at boot too.

I copied the squid XML file and made this one at /sw/etc/daemons/dansguardian.xml:

<service>
<description>Dan's Guardian</description>
<message>Dan's Guardian content filter</message>
 
<daemon name="dansguardian">
<executable checkexit="true">/usr/local/sbin/dansguardian</executable>
<configfile>/usr/local/etc/dansguardian/dansguardian.conf</configfile>
<pidfile>/var/run/dansguardian.pid</pidfile>
</daemon>
 
</service>

Now all I have to do is:

$ sudo daemonic enable dansguardian

Looks like it built some nice OS-X-y startup scripts for me in /Library/StartupItems/daemonic-dansguardian. Here goes rebooting…