Subject: configuration problems using 'cpp' on MacOS X
To: None <tech-pkg@netbsd.org>
From: None <jdbaker@mylinuxisp.com>
List: tech-pkg
Date: 02/10/2004 21:43:50
I have encountered a problem configuring "net/tinyfugue" (MU* client) on
MacOS X 10.2.8 using the Dec2002DevTools and Aug2003gcc331update.  It
stems from a curious combination of factors that may affect other
packages.

The build step for net/tinyfugue also runs the package's own configura-
tion script 'work/tf40-s1/unix/tfconfig'.  The output of the script
claims that it could not find the following headers:

     <netinet/in.h>
     <arpa/inet.h>
     <netdb.h>

even though it was, in fact, including them.  I conducted some tests to
see why this was and ultimately a workaround.

It seems Apple tweaked '/usr/include/ppc/param.h', which is ultimately
included by <sys/socket.h> and <netdb.h>.  They added an alternate
definition of the macros "btodb()" and "dbtob()" which take 2 arguments
instead of one.  The two sets of definitions are surrounded by a

   #ifdef __APPLE__
      btodb(x, y)   /* blah */
      dbtob(y, x)   /* blah */
   #else
      btodb(x)   /* blah */
      dbtob(y)   /* blah */
   endif

structure.

The MacOS X Dev Tools 'cpp' does not like this arrangement, complaining
that macro "btodb" takes 2 arguments, but only 1 is given, and likewise
for "dbtob".  Curiously, 'gcc -E' and the rest of the compiler, proper,
does not complain.

When the 'tfconfig' script is executed, it finds CC=gcc and CPP=cpp
already defined in its surrounding environment.  Were these NOT defined,
or were cleared to empty strings, the script would try to detect the
compiler, assuming 'gcc' as the default.  More importantly, it would
first attempt to discern the preprocessor as ${CC} ${CCFLAGS} -E, which
would translated to 'gcc -O2 -I/usr/pkg/include -E', which would
successfully parse its subsequent test code snippets.

The workaround, then is to add "CPP=" or "CPP=''" to the build command
line to set the definition of CPP to the empty string, thereby allowing
the 'tfconfig' script to correctly detect and use "gcc -E" as its
preprocessor.

Having found this, perhaps a similar situation causes problems with
other packages when building on MacOS X?

Perhaps this can be worked into the patches for net/tinyfugue?  I'd
work one up myself, but I am yet a novice in the ways of pkgsrc...

-- 
John D. Baker, KN5UKS                      jdbaker(at)mylinuxisp(dot)com
  http(colon slash slash)mylinuxisp(dot)com(slash tilde)jdbaker(slash)
NetBSD        OpenBSD        Darwin/MacOS X        FreeBSD        BSD/OS
BSD -- The Operating System for the Third Millenium and Beyond!