I'm new to automake and autoconf, I'm now trying to write my first project using these tools.
My project consists in a library and a sample apache module that depends on this library.
The directory structure I have chosen is the following:


      my_project (contains configure.ac and top Makefile.am)

       -> includes (the includes to be installed to use the library,
       used by sources and random_module)
       -> sources (the sources of the library)
       -> random_module (the sample)

I have tried to set up configure.ac and Makefile.am reading info documentation, actually I'm able to compile the project but I have still some problems.

  1. make install installs the library and the sample module, but does
     not install the headers
  2. the library built in sources and the apache module are compiled
     using libtool, I was able to introduce a dependence between the
     module and the library but libtool statically links in the
     library. I would like the sample module to be linked with the
     shared library, how can I do that?

Here are my configure.ac and makefile.am, every comment will be apreciated, I have a lot to learn about autoconf & automake

configure.ac

AC_PREREQ(2.59)
AC_COPYRIGHT([Copyright 2004,2005 Giovanni Bricconi])
AC_INIT([gbap-pool], [0.3], [EMAIL PROTECTED])
AC_CONFIG_SRCDIR([sources/win_threads.cpp])
AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE

# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LIBTOOL

AC_PATH_PROG([APXS],[apxs],[not-found],[$PATH:/usr/local/apache2/bin:/usr/apache2/bin])
if test $APXS = not-found ; then
  AC_MSG_ERROR("please place apache2/bin in PATH")
fi
AC_SUBST([APXS])
HTTP_HOME=`echo $APXS | sed "s/\/bin\/apxs//g"`
AC_SUBST([HTTP_HOME])
AC_MSG_RESULT([APXS = $APXS])
AC_MSG_RESULT([HTTP_HOME = $HTTP_HOME])

# Checks for libraries.

# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([stdlib.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
AC_C_INLINE
AC_TYPE_SIZE_T
AC_C_VOLATILE
AC_CHECK_TYPES([ptrdiff_t])

#define additional symbols

AC_ARG_ENABLE([gb-dump],
   AC_HELP_STRING([--enable-gb-dump],
       [add more debug messages (default is NO)]),
   [ac_cv_use_gb_dump=yes],
   [ac_cv_use_gb_dump=no])
if test "$ac_cv_use_gb_dump = yes" ; then
  AC_DEFINE([GB_DUMP],[1],[add more debug messages])

AC_ARG_ENABLE([random_module],
    AC_HELP_STRING([--enable-random-module (default is YES)],
       [compile the sample module]),
    [case "${enableval}" in
      yes) random_module=true ;;
      no)  random_module=false ;;
      *) AC_MSG_ERROR(bad value ${enableval} for --enable-random-module) ;;
    esac],[random_module=true])
AM_CONDITIONAL(RANDOM_MODULE, test x$random_module = xtrue)

AC_MSG_RESULT([Apache environment])
APXS_INCLUDEDIR=`$APXS -q INCLUDEDIR`
APXS_LIBEXECDIR=`$APXS -q LIBEXECDIR`
APXS_EXTRA_CFLAGS=`$APXS -q EXTRA_CFLAGS`
AC_MSG_RESULT([APXS_INCLUDEDIR = $APXS_INCLUDEDIR])
AC_MSG_RESULT([APXS_LIBEXECDIR = $APXS_LIBEXECDIR])
AC_MSG_RESULT([APXS_EXTRA_CFLAG = $APXS_EXTRA_CFLAGS])
AC_SUBST([APXS_INCLUDEDIR])
AC_SUBST([APXS_LIBEXECDIR])
AC_SUBST([APXS_EXTRA_CFLAGS])

# Checks for library functions.

AC_CONFIG_FILES([Makefile
        includes/Makefile
                sources/Makefile
        random_module/Makefile])
AC_OUTPUT()


the Makefile.am in includes directory, does not work, if I call make install from includes headers get installed, i I call make install from the top directory headers does not gets installed.


include_HEADERS = gb_allocators.h gb_pthreadstuff.h gb_new.h gb_Pool_Allocator.h


The Makefile.am in random_module directory, compiling it libgbap il statically linked, I would like to link random_module to libgbap shared object.


CXXFLAGS+=-I${top_srcdir}/includes [EMAIL PROTECTED]@ -pthread

noinst_LTLIBRARIES =

if RANDOM_MODULE
noinst_LTLIBRARIES += random_module.la
endif

random_module_la_LDFLAGS = -module -rpath '@APXS_LIBEXECDIR@' 
../sources/libgbap.la

random_module_la_SOURCES = Variabile.cpp Random.cpp mod_random.cpp

#install-exec-local
install-data-local:
@APXS@ -i -n 'random_module' random_module.la



The library's Makefile.am (works)

CXXFLAGS+=-I${top_srcdir}/includes [EMAIL PROTECTED]@ -pthread

lib_LTLIBRARIES = libgbap.la

libgbap_la_SOURCES = gb_pthreadstuff.cpp win_threads.cpp

Top directory makefile.am

SUBDIRS=sources random_module

check_apxs_vars:
       @echo APXS_INCLUDEDIR @APXS_INCLUDEDIR@;\
       echo APXS_LIBEXECDIR @APXS_LIBEXECDIR@;\
       echo APXS_EXTRA_CFLAGS @APXS_EXTRA_CFLAGS@

#deep-clean
code-clean:
   rm -f *.so *.o *~ *.dll *.exp *.lib *.ncb *.obj *.bak *.pdb

# single process
#httpd: install
#        $(HTTPD) -X -d $(HTTPD_HOME)

# debug the module
#gdb: install
#        gdb --cd=$(HTTPD_HOME) --directory=$(SOURCEDIR) $(HTTPD)

# generate documentation
doc: $(LISTA_HEADERS) Doxyfile
       doxygen Doxyfile

#cleanup documentation
doc-clean:
       rm -Rf doc

#create tar file
TAR_FILE=gbap_pool_`date +%Y_%m_%d`.tar

tar: code-clean doc
tar cf $(TAR_FILE) *
bzip2 $(TAR_FILE)



Thanks a lot in advance!

Reply via email to