Mailinglist Archive: opensuse (2700 mails)

< Previous Next >
Re: [SLE] Automake ...
  • From: John D Lamb <J.D.Lamb@xxxxxxxxxxxxxx>
  • Date: Wed, 27 Jul 2005 21:37:12 +0100
  • Message-id: <42E7F078.9060906@xxxxxxxxxxxxxx>
Steven Pasternak wrote:
> Carlos E. R. wrote:
>
>
> The Saturday 2005-07-23 at 17:21 -0400, Steven Pasternak wrote:
>
>
>
>>>> Hi All. I have been using linux for about 2 1/2 years now, and wanted
>>>> to start
>>>> C programming. I made the .c and .h files, and I want to know how to
>>>> make a
>>>> configure and Makefile.in. I know that kdevelop does this, but I just
>>>> want to
>>>> know how the old-fashoned way. Thanks!
>>>>
>
> For simple programs I don't think you need that... :-?
>
> -- Cheers,
> Carlos Robinson
>>
>>

>>
> I am trying to build a library, and a program that links to it (and I
> just want to know how to work automake & friends :-) ).
> -Steven

This really belongs in suse-programming-e...

There's a nice book called GNU Autoconf, Automake and Libtool that goes
through most of the details.

Typically you need a minimal configure.ac file containing something like:

# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.57)
AC_INIT(cycles, 0.1, J.D.Lamb@xxxxx)
AC_CONFIG_SRCDIR([config.h.in])
AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE


dnl Checks for programs.
AC_PROG_CXX
AC_PROG_CPP
AC_PROG_INSTALL
AC_COMPILE_WARNINGS

dnl Check for libtool
AC_ENABLE_SHARED
AC_PROG_LIBTOOL

dnl Checks for libraries.
AC_CHECK_LIBM

dnl Checks for header files.
AC_HEADER_STDC

AC_CXX_NAMESPACES
AC_CXX_HAVE_NUMERIC_LIMITS

dnl Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
AC_C_INLINE
AC_TYPE_SIZE_T

dnl Checks for library functions.
AC_FUNC_ERROR_AT_LINE
AC_FUNC_MALLOC
AC_CHECK_FUNCS([pow sqrt])


AC_CONFIG_FILES([Makefile
main/Makefile
test/Makefile
])
AC_OUTPUT

echo \
"------------------------------------------------------------------------
Configuration:

Source code location: ${srcdir}
Compiler: ${CXX}
Compiler flags: ${CXXFLAGS}
Host System Type: ${host}
Install path: ${prefix}

See config.h for further configuration information.
------------------------------------------------------------------------
Building:

To compile library: make
To install library: make install
To create test programs: make check (Creates in
cycles/test.)
To clean up: make clean
------------------------------------------------------------------------"

Then in each directory (root, cycles, test), you put a Makefile.am file.
Typically:

## Process this file with automake to produce Makefile.in

SUBDIRS = main test

or:

## Process this file with automake to produce Makefile.in

ldflags = -version-info 1:0:1
sources = Graph.cc Random.cc EdgeRecorder.cc Circuits.cc P_centre.cc
headers = Graph.h Random.h RuntimeException.h EdgeList.h \
IncidentEdgePropertyMap.h EarlyExitException.h EdgeRecorder.h \
Circuits.h P_centre.h Sort.h

lib_LTLIBRARIES = libcycles.la

if WITH_DEBUG
AM_CXXFLAGS = -DDEBUG
endif

libcycles_la_LDFLAGS = $(ldflags)
libcycles_la_SOURCES = $(sources)
pkginclude_HEADERS = $(headers)


clean-local: clean-src
rm -f *~

clean-src:
cd $(srcdir); rm -f *~


Then use
$ aclocal -I m4
$ autoheader
$ libtoolize --force
$ automake --gnu --add-missing
$ autoconf

to create a configure script and everything should work the way you want
it to.


--
JDL

< Previous Next >