Creating your own personal configure script

Author

Cecilie Hansen

If you are building any of our programs on a Mac machine you are going to have to create a personal configure script. These cannot be generated by us as it depends on the location of items on your machine.

All program will have a configure_mac script that you should use as a starting point. You should not edit these, rather you should copy them and create your own script configure_N where N is your name.

The following instructions start off general and then there is a section for each program that specifies exactly what files you need to provide the path too.

General Information

If you type ./configure –help you will see info like the following:

Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L if you have libraries in a
nonstandard directory
LIBS libraries to pass to the linker, e.g. -l
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if
you have headers in a nonstandard directory
CPP C preprocessor

More Information:

CC
The ‘CC’ bit is the compiler you want to use. We currently recommend using gcc-4.6. If you only have a single version of gcc installed then you can probably change this too just ‘gcc’. 

 
CXXFLAGS, CPPFLAGS and CFLAGS
CXXFLAGS, CPPFLAGS and CFLAGS tell the compiler to add the listed directories to any pre-existing list of include directories. Where these include files are depends on how you have set up your machine. See below for more information about what header files are required by each program.

 
LDFLAGS
LDFLAGS are around additional libraries. See below for more information about what library files are required by each program.

Atlantis2

CXXFLAGS, CPPFLAGS and CFLAGS

Atlantis requires the following headers:

NetCDF headers:

netcdf.h

libxml headers:

libxml/xpathInternals.h
libxml/xmlmemory.h
libxml/parser.h
libxml/xpath.h

Proj4 headers:

proj_api.h

You need to work out the locations of each of these groups of header files. You should generally only need to search for one of the header files. You can search for the files using the following command:

find /usr -name netcdf.h

It is a good assumption that the files will be somewhere in the /usr folder. For more information about the find command you can of course use the ‘man find’ command.

This should return a result similar to the following:

find /usr -name netcdf.h
 
/usr/local/include/netcdf.h

This tells you that the netcdf.h file is located in the ‘/usr/local/include’ folder. You need to add this folder to the values in your configure_N script for the CXXFLAGS, CPPFLAGS and CFLAGS variables.

./configure \
CC='gcc-mp-4.6' \
CFLAGS='-I/usr/local/include ' \
CXXFLAGS='-I/usr/local/include  ' \
CPPFLAGS='-I/usr/local/include  ' \
LDFLAGS=' -lcurl'

Next work out where your libxml include files are:

find /usr -name xpathInternals.h
 
/usr/include/libxml2/libxml/xpathInternals.h

If you have a look at the include statements that i listed above:

libxml/xpathInternals.h
libxml/xmlmemory.h
libxml/parser.h
libxml/xpath.h

you can see that we specify the libxml folder in the source code. So we only need to provide the path ‘/usr/include/libxml2’. Our configure script is now:

./configure \
CC='gcc-mp-4.6' \
CFLAGS='-I/usr/local/include -I/usr/local/include/libxml2' \
CXXFLAGS='-I/usr/local/include -I/usr/local/include/libxml2' \
CPPFLAGS='-I/usr/local/include -I/usr/local/include/libxml2' \
LDFLAGS=' -lcurl'

Check that all of the folders that contain the required headers are included. There will probably be some duplication (eg both the netcdf and proj_api.h headers are in the usr/local/include folder on my machine. You only need to include the folder once.

LDFLAGS

Next we need to find the location to the libraries. Atlantis2 requires the following libraries:

NetCDF

libnetcdf.a

LibXML2

libxml2.a

Proj4:

libproj.a

So again we use the find command to work out where they are located:

find /usr -name libproj.a
/usr/local/lib/libproj.a
 
find /usr -name libnetcdf.a
/usr/local/lib/libnetcdf.a
 
find /usr -name libxml2.a
/usr/local/lib/libxml2.a

As you can see all of the libraries we are looking for are located in the /usr/local/lib folder on my machine. So we can simply add this to the LDDFLAGS variable to give us our final confugure_n script:

./configure \
CC='gcc-mp-4.6' \
CFLAGS='-I/usr/local/include -I/usr/local/include/libxml2' \
CXXFLAGS='-I/usr/local/include -I/usr/local/include/libxml2' \
CPPFLAGS='-I/usr/local/include -I/usr/local/include/libxml2' \
LDFLAGS=' -L/usr/local/lib -lcurl'

NOTE: 64 bit vs 32 bit.

If for some reason you have multiple version of a library install on your machine and one version is in an i386 folder and the other is in an x64 folder then it means you have a 32 bit and a 64 bit version installed. This is fine and won’t cause any issues provided you consistently use the same version when building Atlantis. I would recommend using the 64 bit versions (x64).

AtlantisNCGen

CXXFLAGS, CPPFLAGS and CFLAGS

Atlantis requires the following headers:

NetCDF headers:

netcdf.h

Atlantis2 headers:

sjwlib.h
atlantisboxmodel.h

****LDFLAGS****

****NetCDF library:****

libnetcdf.a

****Atlantis2 library:****

libsjwlib.a

Example find results:

find /usr -name sjwlib.h
/usr/local/include/Atlantis-2.0/Atlantis/sjwlib.h
 
find /usr -name atlantisboxmodel.h
/usr/local/include/Atlantis-2.0/Atlantis/atlantisboxmodel.h


find /usr -name netcdf.h
/usr/local/include/netcdf.h
 
find /usr -name libsjwlib.a
/usr/local/lib/libsjwlib.a


find /usr -name libnetcdf.a
/usr/lib/libnetcdf.a

The resulting configure_N script would then be:

./configure \
CC='gcc-mp-4.6' \
CFLAGS='-I/usr/local/include/Atlantis-2.0/Atlantis -I/usr/local/include' \
CXXFLAGS='-I/usr/local/include/Atlantis-2.0/Atlantis -I/usr/local/include' \
CPPFLAGS='-I/usr/local/include/Atlantis-2.0/Atlantis -I/usr/local/include' \
LDFLAGS='-L/usr/local/lib  -L/usr/local/lib -lcurl'