Programming Wiki: GNUAutotools

Programming Wiki : GNUAutotools

WikiHomePage :: Categories :: PageIndex :: RecentChanges :: RecentlyCommented :: Login/Register
Example of Makefile that invokes rpcgen

GNU Build System has two goals:
  1. "To simplify the development of portable programs. "
  2. "To simplify the building of programs that are distributed as source code."


Examples of my files for project (modified to hide project details):
AC_INIT(acinclude.m4) dnl a source file from your sub dir


dnl Automake doc recommends to do this only here. (Janos)

if test "x$prefix" = "xNONE"; then
  ac_configure_args="$ac_configure_args --prefix $prefix"

dnl generate the config header
AM_CONFIG_HEADER(config.h) dnl at the distribution this done

dnl Checks for programs.

dnl allows building code in sub-directories into temporary libraries.

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 ])

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 ""
  echo ""
  echo "Good - your configure finished. Start make now"
  echo ""
fi examples:
Top level 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.
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:
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

#Example where I needed to build an executable and a library:
bin_PROGRAMS = pp_client
noinst_LIBRARIES = libppclient.a

# set the include path for X, qt and KDE
INCLUDES = $(all_includes)

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 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

Now need to rebuild Makefiles and configure script. This will need to be done each time a or are changed. Its easiest to make a script to do this. As stated in one of the links above create a script called rconf.
rm -f config.cache
rm -f acconfig.h
aclocal -I m4
automake -a

There are no comments on this page. [Add comment]

Powered by Wikka Wakka Wiki
Page was generated in 0.0125 seconds