tags:

views:

74

answers:

1

Hello!

I have written a small command line tool that includes some GPL code. Everything runs smothly. Using os 10.6.

The external code used has a config.h header file, made by calling autoconf. I'd like to deploy the tool to different OS versions. Thus config.h could look like

// config.h
#if MAC_OS_X_VERSION_MAX_ALLOWED == MAC_OS_X_VERSION_10_4  
// autoconf created config.h content for 10.4 comes here
#elif MAC_OS_X_VERSION_MAX_ALLOWED == MAC_OS_X_VERSION_10_5
// autoconf created config.h content for 10.5 comes here
#elif MAC_OS_X_VERSION_MAX_ALLOWED == MAC_OS_X_VERSION_10_6
// autoconf created config.h content for 10.6 comes here
#else
#error "muahahaha"
#endif

What is the way to tell autoconf to use /Developer/SDKs/MacOSX10.XXXX.sdk/usr/ while generating the config.h?
In order to test it I have run

#!/bin/bash
# for 10.6
export CC="/usr/bin/gcc-4.2"
export CXX="/usr/bin/g++-4.2"
export MACOSX_DEPLOYMENT_TARGET="10.6"
export OSX_SDK="/Developer/SDKs/MacOSX10.6.sdk"
export OSX_CFLAGS="-isysroot $OSX_SDK -arch x86_64 -arch i386"
export OSX_LDFLAGS="-Wl,-syslibroot,$OSX_SDK -arch x86_64 -arch i386"
export CFLAGS=$OSX_CFLAGS
export CXXFLAGS=$OSX_CFLAGS
export LDFLAGS=$OSX_LDFLAGS

before calling ./configure on OS 10.6. I know that the configure script looks for libintl.h, which is not in the "out of box 10.6 / SDK", but is present in the local machine under /usr/local The config.h header file produced with method described above has info that libintl.h is in the system- thus "linking" autoconf only to SDK has failed.

Is it happening because... "we don't have a crystal ball"? :). Or is it incorrect "setup"/flag-export before running autoconf, which I hope is the case? If so, then what would be the correct way to set up envvariables?
Many thanks in advance.


Edit. Looks like

#!/bin/bash
#set to gcc-4.0 for 10.4
export GCC_VERSION="gcc-4.2"
#set to g++-4.0 for 10.4
export GPLUSPLUS_VERSION="g++-4.2"
# MacOSX10.4u. MacOSX10.5, MacOSX10.6
export OSX_SDK="/Developer/SDKs/MacOSX10.6.sdk"
# 10.4, 10.6, 10.6
export MACOSX_DEPLOYMENT_TARGET="10.6"
export CC="$GCC_VERSION -isysroot $OSX_SDK -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET"
export CCX="$GPLUSPLUS_VERSION -isysroot $OSX_SDK -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET"
export CFLAGS="$CFLAGS -isysroot $OSX_SDK -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET"
export CXXFLAGS="$CXXFLAGS -isysroot $OSX_SDK -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET"
export LDFLAGS="$LDFLAGS -isysroot $OSX_SDK -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET"  

did the trick :) Thanks anyway.

+1  A: 

config.h is not created by autoconf. Perhaps that is a typo in your question, or maybe it is a fundamental misunderstanding. config.h is created by the shell script named config.status, which is written by the shell script named configure. The configure script is what is generated by autoconf, and the resulting config.h will be different depending on the machine that configure is run on, the environment in which it is run, and the arguments passed to it.

If you have a lot of settings that need to be passed to configure, it is often convenient to specify the values in a config.site file. You can either put config.site in $prefix/share (eg, /usr/local/share/config.site), or you can specify a path in the environment variable CONFIG_SITE. This is typically preferred to setting things in configure's environment.

William Pursell
Pardon, that was a "typo"- just wanted to explain the situation in short. In this specific case config.h contains only info on if some headers and functions are present in the system, therefore such envvariable export to get the configuration only once from sdks 10.4-10.6 was enough for me. However, thanks for Your time and extended explanation!
kroko