Intro
I have been writing my own Makefiles for years. Lately I’ve been experimenting with using automake. I have used automake to compile various things from source for years. It’s a formidable beast but then again so was make and getting vim to work the way _I_ want, but those have proven well worth the effort, we’ll see…
run autoscan
This generates autoscan.log which you probably don’t care about and configure.scan which you will edit and rename to configure.ac
edit configure.scan and rename to configure.ac
add AC_INIT, AC_INIT_AUTOMAKE and AC_OUTPUT
example:
AC_INIT(magtek, 0.1, tallen@integsys.biz)
AM_INIT_AUTOMAKE
AC_OUTPUT(Makefile src/Makefile)
run aclocal
run autoconf
create/edit Makefile.am
AUTOMAKE_OPTIONS = foreign
SUBDIRS = src
foreign means non GNU
SUBDIRS could include things like src, doc, examples, man, scripts
create/edit src/Makefile.am
AM_CXXFLAGS=-g -I/usr/include/libusb-1.0 -lusb-1.0
LDADD = /usr/lib/x86_64-linux-gnu/libusb-1.0.so
AM_ETAGSFLAGS = -R --c++-kinds=+p --fields=+iaS --extra=+q --if0=yes . /usr/include/libusb-1.0/
bin_PROGRAMS = enumerate magtek
enumerate_SOURCES = enumerate.cc
magtek_SOURCES = magtek.cc
AM_CXXFLAGS adds will show up as CXXFLAGS in the generated Makefile
LDADD is library thats not mainstream required for this project
AM_ETAGSFLAGS are the flags for the tags target in the generated Makefile
the rest is for your targets and their dependencies
run autoheader
run automake –add-missing
run autoconf
run ./configure
run make
I used this page and naturally the documentation as a basis for working this out.