Example of Makefile that invokes rpcgen
GNU Build System has two goals:
- "To simplify the development of portable programs. "
- "To simplify the building of programs that are distributed as source code."
Links:
Examples of my files for project (modified to hide project details):
configure.in:
AC_INIT(acinclude.m4) dnl a source file from your sub dir
AC_CANONICAL_SYSTEM
dnl Automake doc recommends to do this only here. (Janos)
AM_INIT_AUTOMAKE(SoftwareName,Version)
AC_PREFIX_DEFAULT(/usr/local)
if test "x$prefix" = "xNONE"; then
prefix=$ac_default_prefix
ac_configure_args="$ac_configure_args --prefix $prefix"
fi
dnl generate the config header
AM_CONFIG_HEADER(config.h) dnl at the distribution this done
dnl Checks for programs.
AC_CHECK_COMPILERS
dnl allows building code in sub-directories into temporary libraries.
AC_PROG_RANLIB
dnl converted AC_OUTPUT to this method for newer versions (2.59) of autoconf
AC_CONFIG_FILES([ Makefile ])
AC_CONFIG_FILES([ src/Makefile ])
AC_CONFIG_FILES([ src/toolkit/Makefile ])
.
.
.
AC_OUTPUT
if test "$all_tests" = "bad"; then
if test ! "$cache_file" = "/dev/null"; then
echo ""
echo "Please remove the file $cache_file after changing your setup"
echo "so that configure will find the changes next time."
echo ""
fi
else
echo ""
echo "Good - your configure finished. Start make now"
echo ""
fi
Makefile.am examples:
Top level Makefile.am mostly used to point to the subdirectories that have makefile.ams unless there is also code that needs to be built in your base directory.
SUBDIRS = src
EXTRA_DIST = admin AUTHORS COPYING ChangeLog INSTALL README TODO data scripts nets temp
I'm not sure what EXTRA_DIST is for but I think it is files that don't pertain to the make
For a directory where we build an executable: Makefile.am:
bin_PROGRAMS = myexec
myexec_SOURCES = students.cxx read.cxx something.cxx main.cxx ensemble.cxx cc.cxx ada.cxx timer.cxx distributed.cpp
SUBDIRS = @myexec_subdirs@
#we also need to adjust the required libraries based on configure options
#example of var set in the admin/ for configured libaries and directly including the libppclient.a lib
myexec_LDADD = @myexec_libraries@ pp_client/libppclient.a
# set the include path for X, qt and KDE
INCLUDES= $(all_includes)
# the library search path.
myexec_LDFLAGS = $(all_libraries)
# them while "make clean", use CLEANFILES
DISTCLEANFILES = $(myexec_METASOURCES)
#Example where I needed to build an executable and a library: Makefile.am:
bin_PROGRAMS = pp_client
noinst_LIBRARIES = libppclient.a
# set the include path for X, qt and KDE
INCLUDES = $(all_includes)
pp_client_METASOURCES = AUTO
libppclient_a_METASOURCES = AUTO
pp_client_SOURCES = pp_clnt.cxx pp_xdr.cxx pptrain.cxx pp_client.cxx
libppclient_a_SOURCES = pp_clnt.cxx pp_xdr.cxx pptrain.cxx pp_client.cxx
#we also need to adjust the required libraries based on configure options
#pp_client_LDADD = @nnes_libraries@
#but I didn't, I directly set the LDADDs. Probably should have modified the acinclude.m4.in in admin/
pp_client_LDADD = ../cascade/libcascade.a ../cascade/parse/libparse.a ../cascade/toolkit/libtoolkit.a
# the library search path.
#added my own libaries here also.. -lnsl got threads working on solaris
pp_client_LDFLAGS = $(all_libraries) -lpthread -lnsl
# them while "make clean", use CLEANFILES
DISTCLEANFILES = $(myexec_METASOURCES)
Now need to rebuild Makefiles and configure script. This will need to be done each time a Makefile.am or configure.in are changed. Its easiest to make a script to do this. As stated in one of the links above create a script called rconf.
rconf:
#!/bin/sh
rm -f config.cache
rm -f acconfig.h
aclocal -I m4
autoconf
autoheader
automake -a
There are no comments on this page. [Add comment]