[ghemical-devel] configure script(s) should call PKG_PROG_PKG_CONFIG

Daniel Leidert daniel.leidert.spam at gmx.net
Sun Oct 5 07:56:31 EDT 2008


Am Sonntag, den 05.10.2008, 00:14 +0200 schrieb Daniel Leidert:
> Am Sonntag, den 05.10.2008, 00:07 +0200 schrieb Daniel Leidert:
> 
> [configure files]
> > Attached to this are updated ones for libghemical and ghemical
> > (liboglappth will follow soon).
> 
> Attached too.

Found another small issue in my updated ones (AC_OUTPUT has to be called
at the end and it was missing for liboglappth). I attached all 3 scripts
to this mail and I will send any updates as answer to this mail.

However, I found something else I would change: At the end the build
options are output. However, they do not consider, if the requested
library was even found. A possible solution could be to use something
like this:

if ( $PKG_CONFIG --exists 'libmopac7 >= 1.13' ); then
	MOPAC7_CFLAGS=`$PKG_CONFIG --cflags libmopac7`
	MOPAC7_LIBS=`$PKG_CONFIG --libs libmopac7`

	CPPFLAGS="$CPPFLAGS $MOPAC7_CFLAGS"
	LIBS="$LIBS $MOPAC7_LIBS"

	REQUISITIONS="$REQUISITIONS libmopac7"
	AC_DEFINE([ENABLE_MOPAC7],, [Define if you are building a version that interfaces directly with MOPAC7])
else
# option 1:
# if required package is missing
	AC_MSG_ERROR([The MOPAC library is missing. Please install it first.])
# option 2
# if an optional package is missing
# e.g. for requested builds with this feature
	AC_MSG_WARN([The MOPAC library is missing. Not building with MOPAC.])
	enable_mopac7=no
fi

This will make the scripts a bit larger, but fail or warn in special cases.

Regards, Daniel
-------------- next part --------------
# Configuration for libghemical.
# Copyright (c) 2000- Geoff Hutchison, Michael Banck, Jean Brefort,
# Tommi Hassinen.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.

# Process this file with aclocal/autoconf to produce a configure script.

AC_INIT([libghemical], [2.98])

AC_DEFINE([LIBVERSION], ["2.98"], [This is the version of libghemical to be built--it is set in the configure.ac])
AC_SUBST([LIBVERSION], ["2.98"])

##################################################################
## also see src/Makefile.am when you change the version number!!!
##################################################################

AC_DEFINE([LIBRELEASEDATE], ["2008-07-31"], [This is the releasedate of libghemical--it is set in the configure.ac])
AC_SUBST([LIBRELEASEDATE], ["2008-07-31"])

AC_PREREQ([2.48])
AC_CONFIG_SRCDIR([src/model.cpp])
AM_CONFIG_HEADER([src/libghemicalconfig.h])

##########################################################################################
dnl ... and this one is a small subset, maintained manually, which will be installed.

## this is for automake-1.4:
AM_CONFIG_HEADER([src/libghemical-features.h])

## this is for later versions:
##AC_CONFIG_HEADERS([src/libghemical-features.h])

dnl Make sure these two won't clash. Put the following to libghemicalconfig.h:
AH_BOTTOM([/* Don't include libghemical-features.h, it's a subset of libghemicalconfig.h. */
#define LIBGHEMICAL_FEATURES_H])
##########################################################################################

AM_INIT_AUTOMAKE([-Wall])

AC_CANONICAL_HOST

top_builddir_=`pwd`
AC_SUBST(top_builddir_)

AC_DEFINE_DIR([LIBDATA_PATH], [datadir/libghemical], [Where the data files are ; set in the configure.ac])

# create a version of config.h where the PACKAGE definitions are stripped away.
AC_CONFIG_COMMANDS([src/libghemicalconfig2.h],[cat src/libghemicalconfig.h | grep -v PACKAGE > src/libghemicalconfig2.h])

# Get any build/host and enable/disable flags now.
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# if a mingw32 host is specified, then ???
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
##case $host in
##	*-*-mingw32*)
##		CPPFLAGS="-Dmno-cygwin -Dmms_bitfields $CPPFLAGS"
##		LIBS="$LIBS -mwindows"
##		;;
##esac

AC_ARG_ENABLE(
	[mpqc],
	AS_HELP_STRING([--enable-mpqc],
		       [compile with MPQC support @<:@default=no@:>@]
	),
	[enable_mpqc=$enableval],
	[enable_mpqc=no]
)
AC_ARG_ENABLE(
	[mopac7],
	AS_HELP_STRING([--enable-mopac7],
		       [compile with MOPAC7 support @<:@default=no@:>@]
	),
	[enable_mopac7=$enableval],
	[enable_mopac7=no]
)

# Checks for programs.
# ^^^^^^^^^^^^^^^^^^^^

AC_PROG_CC
AC_PROG_CXX
AC_PROG_CPP
AC_PROG_CXXCPP
AC_PROG_INSTALL
AC_PROG_LIBTOOL
AC_PATH_PROG([AR], [ar], [ar])
AC_PATH_PROG([SHELL], [sh], [/bin/sh])
AC_PROG_MAKE_SET
PKG_PROG_PKG_CONFIG

AM_SANITY_CHECK

REQUISITIONS=

# Checks for libraries.
# ^^^^^^^^^^^^^^^^^^^^^

AC_CHECK_LIB([m], [acos],, AC_MSG_ERROR([math library missing]))

if test $enable_mpqc = yes; then
	AC_CHECK_LIB([blas], [main],, AC_MSG_ERROR([Cannot find blas library needed for MPQC support]))
	AC_CHECK_LIB([lapack], [main],, AC_MSG_ERROR([Cannot find lapack library needed for MPQC support]))
	AM_PATH_SC(1.2.5, HAVE_MPQC="yes", HAVE_MPQC="no")
	if test "${HAVE_MPQC}" = "yes"; then
		AC_DEFINE([ENABLE_MPQC],, [Define if you are building a version that interfaces directly with MPQC])
		AC_DEFINE_UNQUOTED([SC_MAJOR_VERSION], [$SC_MAJOR_VERSION], [This is the major version of SC (MPQC's underlying library) found by configure])
		AC_DEFINE_UNQUOTED([SC_MINOR_VERSION], [$SC_MINOR_VERSION], [This is the minor version of SC (MPQC's underlying library) found by configure])
		AC_DEFINE_UNQUOTED([SC_MICRO_VERSION], [$SC_MICRO_VERSION], [This is the micro version of SC (MPQC's underlying library) found by configure])
		CPPFLAGS="$CPPFLAGS $SC_CPPFLAGS"
		LIBS="$LIBS $SC_LIBS"
	else AC_MSG_ERROR([Cannot find proper SC version])
	fi
fi

if test $enable_mopac7 = yes; then
	AC_DEFINE([ENABLE_MOPAC7],, [Define if you are building a version that interfaces directly with MOPAC7])
	
	#PKG_CHECK_MODULES([MOPAC7], [libmopac7 >= 1.13])
	MOPAC7_CFLAGS=`$PKG_CONFIG --cflags libmopac7`
	MOPAC7_LIBS=`$PKG_CONFIG --libs libmopac7`
	
	##AC_SUBST(MOPAC7_CFLAGS)	not necessary???
	##AC_SUBST(MOPAC7_LIBS)		not necessary???
	
	CPPFLAGS="$CPPFLAGS $MOPAC7_CFLAGS"
	LIBS="$LIBS $MOPAC7_LIBS"
	
	REQUISITIONS="$REQUISITIONS libmopac7"
fi

# Checks for header files.
# ^^^^^^^^^^^^^^^^^^^^^^^^

AC_CHECK_HEADERS([GL/gl.h])

# Checks for typedefs, structures, and compiler characteristics.
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

AC_PROG_CC_STDC
AC_C_INLINE
AC_C_CONST

AC_SUBST([CXXFLAGS])
AC_SUBST([LDFLAGS])

AC_SUBST([REQUISITIONS])

# Checks for library functions.
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

AC_HEADER_STDC

AC_CONFIG_FILES([
	libghemical.pc
	Makefile
	bin/Makefile
	bin/amber/Makefile
	bin/builder/Makefile
	bin/param_mm/Makefile
	bin/param_mm/default/Makefile
	bin/param_mm/prmfit/Makefile
	bin/param_mm/tripos52/Makefile
	bin/param_sf/Makefile
	bin/param_sf/default/Makefile
	src/Makefile
])

AC_MSG_NOTICE([

build options:
^^^^^^^^^^^^^^
enable MPQC : $enable_mpqc
enable MOPAC7 : $enable_mopac7
])

AC_CONFIG_COMMANDS([stamp.h], [echo timestamp > stamp.h])

AC_OUTPUT
-------------- next part --------------
# Configuration for liboglappth.
# Copyright (C) 2006- Tommi Hassinen.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1, or (at your option)
# any later version.

# Process this file with aclocal/autoconf to produce a configure script.

AC_INIT([liboglappth], [0.98])

##################################################################
## also see src/Makefile.am when you change the version number!!!
##################################################################

AC_PREREQ([2.48])
AC_CONFIG_SRCDIR([src/base_app.cpp])

AM_INIT_AUTOMAKE([-Wall])

AC_CANONICAL_HOST

top_builddir_=`pwd`
AC_SUBST(top_builddir_)

# Get any build/host and enable/disable flags now.
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# if a mingw32 host is specified, then ???
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
##case $host in
##	*-*-mingw32*)
##		CPPFLAGS="-Dmno-cygwin -Dmms_bitfields $CPPFLAGS"
##		LIBS="$LIBS -mwindows"
##		;;
##esac

# Checks for programs.
# ^^^^^^^^^^^^^^^^^^^^

AC_PROG_CC
AC_PROG_CXX
AC_PROG_CPP
AC_PROG_CXXCPP
AC_PROG_INSTALL
AC_PROG_LIBTOOL
AC_PATH_PROG([AR], [ar], [ar])
AC_PATH_PROG([SHELL], [sh], [/bin/sh])
AC_PROG_MAKE_SET

AM_SANITY_CHECK

# Checks for libraries.
# ^^^^^^^^^^^^^^^^^^^^^

AC_CHECK_LIB([m], [acos],, AC_MSG_ERROR([math library missing]))

LIBS="$LIBS -L/usr/X11R6/lib"

## the GL/GLU library checks won't work at mingw environment...
## ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#AC_CHECK_LIB([GL], [glRenderMode],, AC_MSG_ERROR([GL library missing]))
#AC_CHECK_LIB([GLU], [gluCylinder],, AC_MSG_ERROR([GLU library missing]))

# Checks for header files.
# ^^^^^^^^^^^^^^^^^^^^^^^^

AC_CHECK_HEADERS([GL/gl.h])
AC_CHECK_HEADERS([GL/glu.h])

# Checks for typedefs, structures, and compiler characteristics.
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

AC_PROG_CC_STDC
AC_C_INLINE
AC_C_CONST

AC_SUBST([CXXFLAGS])
AC_SUBST([LDFLAGS])

# Checks for library functions.
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

AC_HEADER_STDC

AC_CONFIG_FILES([
	liboglappth.pc
	Makefile
	src/Makefile
])

AC_MSG_NOTICE([

build options:
^^^^^^^^^^^^^^
])

AC_CONFIG_COMMANDS([stamp.h], [echo timestamp > stamp.h])

AC_OUTPUT
-------------- next part --------------
# Configuration for ghemical.
# Copyright (C) 2000- Geoff Hutchison, Michael Banck, Jean Brefort,
# Tommi Hassinen.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.

# Process this file with aclocal/autoconf to produce a configure script.

AC_INIT([ghemical], [2.98])

AC_DEFINE([APPVERSION], ["2.98"], [This is the version of ghemical to be built--it is set in the configure.ac])
AC_SUBST([APPVERSION], ["2.98"])

AC_DEFINE([APPRELEASEDATE], ["2008-07-31"], [This is the releasedate of ghemical--it is set in the configure.ac])
AC_SUBST([APPRELEASEDATE], ["2008-07-31"])

AC_PREREQ([2.48])
AC_CONFIG_SRCDIR([src/project.cpp])
AM_CONFIG_HEADER([src/ghemicalconfig.h])

# todo : how to prevent from VERSION being written into the config.h file???
# the same will be written into the libghemical config header, causing warnings.

AM_INIT_AUTOMAKE([-Wall])

AC_CANONICAL_HOST

top_builddir_=`pwd`
AC_SUBST(top_builddir_)

AC_DEFINE_DIR([APPDATA_PATH], [datadir/ghemical], [Where the data files are ; set in the configure.ac])

# create a version of config.h where the PACKAGE definitions are stripped away.
AC_CONFIG_COMMANDS([src/ghemicalconfig2.h],[cat src/ghemicalconfig.h | grep -v PACKAGE > src/ghemicalconfig2.h])

# Get any build/host and enable/disable flags now.
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# if a mingw32 host is specified, then ???
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
##case $host in
##	*-*-mingw32*)
##		CPPFLAGS="-Dmno-cygwin -Dmms_bitfields $CPPFLAGS"
##		LIBS="$LIBS -mwindows"
##		;;
##esac

AC_ARG_ENABLE(
	[gtk],
	AS_HELP_STRING([--enable-gtk],
	               [build a GTK2 application @<:@default=yes@:>@]
	),
	[enable_gtk=$enableval],
	[enable_gtk=yes]
)

AM_CONDITIONAL([COND_USE_GTK], [test "x$enable_gtk" = "xyes"])

AC_ARG_ENABLE(
	[threads],
	AS_HELP_STRING([--enable-threads],
		       [build a multithreaded application @<:@default=yes@:>@]
	),
	[enable_threads=$enableval],
	[enable_threads=yes]
)

AC_ARG_ENABLE(
	[openbabel],
	AS_HELP_STRING([--enable-openbabel],
		       [compile with OpenBabel support @<:@default=no@:>@]
	),
	[enable_openbabel=$enableval],
	[enable_openbabel=yes]
)       

# Checks for programs.
# ^^^^^^^^^^^^^^^^^^^^

AC_PROG_CC
AC_PROG_CXX
AC_PROG_CPP
AC_PROG_CXXCPP
AC_PROG_INSTALL
AC_PROG_LIBTOOL
AC_PATH_PROG([AR], [ar], [ar])
AC_PATH_PROG([SHELL], [sh], [/bin/sh])
AC_PROG_MAKE_SET
PKG_PROG_PKG_CONFIG

AM_SANITY_CHECK

# Checks for libraries.
# ^^^^^^^^^^^^^^^^^^^^^

AC_CHECK_LIB([m], [acos],, AC_MSG_ERROR([math library missing]))

LIBS="$LIBS -L/usr/X11R6/lib"

## the GL/GLU library checks won't work at mingw environment...
## ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#AC_CHECK_LIB([GL], [glRenderMode],, AC_MSG_ERROR([GL library missing]))
#AC_CHECK_LIB([GLU], [gluCylinder],, AC_MSG_ERROR([GLU library missing]))

## the X11 check should be skipped at mingw environment...
## ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#AC_CHECK_LIB([X11], [XOpenDisplay],, AC_MSG_ERROR([X11 library missing]))

## are the rest necessary???

#AC_CHECK_LIB([Xmu], [XmuDrawLogo])
#AC_CHECK_LIB([Xext], [XShmAttach])
#AC_CHECK_LIB([Xi], [XOpenDevice])

# gtk+ feature GtkUIManager is needed -> v2.4 or newer is required.
# glib feature GOptionContext is needed -> v2.6 or newer is required.

## the PKG_CHECK_MODULES() function is not working at mingw environment...
## ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

if test $enable_gtk = yes; then
	AC_DEFINE([ENABLE_GTK], [], [Define if you are building a GTK2 application])
	
	if test $enable_threads = yes; then
		AC_DEFINE([ENABLE_THREADS], [], [Define if you are building a multithreaded application])
		
		#PKG_CHECK_MODULES([GTHREAD], [gthread-2.0 >= 2.6.0])
		GTHREAD_CFLAGS=`$PKG_CONFIG --cflags "gthread-2.0 >= 2.6.0"`
		GTHREAD_LIBS=`$PKG_CONFIG --libs gthread-2.0`
		
		CPPFLAGS="$CPPFLAGS $GTHREAD_CFLAGS"
		LIBS="$LIBS $GTHREAD_LIBS"
	fi
	
	#PKG_CHECK_MODULES([GTK], [gtk+-2.0 >= 2.6.0 gtkglext-1.0 >= 1.0.5 libglade-2.0 >= 2.4.0])
	GTK_CFLAGS=`$PKG_CONFIG --cflags "gtk+-2.0 >= 2.6.0 gtkglext-1.0 >= 1.0.5 libglade-2.0 >= 2.4.0"`
	GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0 gtkglext-1.0 libglade-2.0`
	
	CPPFLAGS="$CPPFLAGS $GTK_CFLAGS"
	LIBS="$LIBS $GTK_LIBS"
	
fi

if test $enable_openbabel = yes; then
	AC_DEFINE([ENABLE_OPENBABEL], [], [Define if you are building a version that interfaces directly with OpenBabel])
	
	#PKG_CHECK_MODULES([OPENBABEL], [openbabel-2.0])
	OPENBABEL_CFLAGS=`$PKG_CONFIG --cflags openbabel-2.0`
	OPENBABEL_LIBS=`$PKG_CONFIG --libs openbabel-2.0`
	
	CPPFLAGS="$CPPFLAGS $OPENBABEL_CFLAGS"
	LIBS="$LIBS $OPENBABEL_LIBS"
fi

#PKG_CHECK_MODULES([LIBGHEMICAL], [libghemical >= 2.98 liboglappth >= 0.98])
LIBGHEMICAL_CFLAGS=`$PKG_CONFIG --cflags "libghemical >= 2.98 liboglappth >= 0.98"`
LIBGHEMICAL_LIBS=`$PKG_CONFIG --libs libghemical liboglappth`

CPPFLAGS="$CPPFLAGS $LIBGHEMICAL_CFLAGS"
LIBS="$LIBS $LIBGHEMICAL_LIBS"

# Checks for header files.
# ^^^^^^^^^^^^^^^^^^^^^^^^

AC_CHECK_HEADERS([GL/gl.h])
AC_CHECK_HEADERS([GL/glu.h])

# Checks for typedefs, structures, and compiler characteristics.
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

AC_PROG_CC_STDC
AC_C_INLINE
AC_C_CONST

AC_SUBST([CXXFLAGS])
AC_SUBST([LDFLAGS])

# Checks for library functions.
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

AC_HEADER_STDC

AC_CONFIG_FILES([
	Makefile
	docs/Makefile
	docs/user-docs/Makefile
	docs/user-docs/images/Makefile
	examples/Makefile
	examples/TSS/Makefile
	examples/TSS/carbocation_rearrangement_hydride_shift/Makefile
	examples/TSS/carbocation_rearrangement_methide_shift/Makefile
	examples/TSS/cycloaddition_Diels-Alder/Makefile
	examples/TSS/E2-reaction/Makefile
	examples/TSS/sigmatropic_rearrangement_Cope/Makefile
	examples/TSS/SN2-reaction/Makefile
	examples/TSS/tautomeric_shift_keto_enol/Makefile
	src/Makefile
	src/res_gtk/Makefile
])

AC_MSG_NOTICE([

build options:
^^^^^^^^^^^^^^
enable gtk : $enable_gtk
enable threads : $enable_threads
enable OpenBabel : $enable_openbabel
])

AC_CONFIG_COMMANDS([stamp.h], [echo timestamp > stamp.h])

AC_OUTPUT


More information about the ghemical-devel mailing list