1 / 13

The GNU Autotools

The GNU Autotools. Your very own ./configure. Say Hello to the Autotools. Autoconf , with the power of ./configure! Automake , making makefiles suck less! Libtool , friend to shared and static library alike!. The Autotools are Hard!. No, they’re not! Well, maybe a little…

vin
Download Presentation

The GNU Autotools

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The GNU Autotools Your very own ./configure Michael Imamura / LUG@GT

  2. Say Hello to the Autotools • Autoconf, with the power of ./configure! • Automake, making makefiles suck less! • Libtool, friend to shared and static library alike! Michael Imamura / LUG@GT

  3. The Autotools are Hard! • No, they’re not! • Well, maybe a little… • Okay, here’s why you should learn them anyway. • User configurability • Standards are everybody’s friend! • Portability – your code isn’t as portable as you think! Michael Imamura / LUG@GT

  4. Getting Started • From scratch: A blank Autotools project • http://lugatgt.org/articles/autotools/autoblank.tar.gz • Use an IDE (like Anjuta) • Retrofit an existing project Michael Imamura / LUG@GT

  5. The Initial Process • Create a few initial stub sources (if you don’t already have any) • Create Makefile.am files • http://lugatgt.org/articles/autotools/amwiz/ • Run autoscan and create configure.ac • Autoconf Macro Archivehttp://autoconf-archive.cryp.to/ • Run autoreconf --install • Run ./configure! Michael Imamura / LUG@GT

  6. Automake • Makefile.am  Makefile.in  Makefile • Basically, a Makefile with special variable declarations • Primaries: What is being produced • bin_PROGRAMS, lib_LTLIBRARIES, etc. • Secondaries: How to produce it • _CFLAGS, _SOURCES, _LIBADD, etc. Michael Imamura / LUG@GT

  7. Autoconf • Run “autoscan” to produce configure.scan • Detects source file types • Detects toolchain dependencies • Merge configure.scan into configure.ac • Add AM_INIT_AUTOMAKE to add Automake support • Add AC_PROG_LIBTOOL to add Libtool support Michael Imamura / LUG@GT

  8. Developing, developing, developing… • Whenever configure.ac or Makefile.am changes, re-run autoreconf • autoreconf --make is useful here • Generated Makefile is often smart enough to do it for you • Standard make targets generated by Automake • User: all (default), install, clean • Developer: dist, check, distcheck Michael Imamura / LUG@GT

  9. Debugging • Libtool hides linking issues • Automatically relinks on install • Oops… Libtool gets in the way • Your binary may not be a binary! • Use “libtool gdb” instead of “gdb” Michael Imamura / LUG@GT

  10. Source control: What to check in • General rule: Only check in files that you have created • Only configure.ac and Makefile.am • Set ignores for the generated files • Add to note to HACKING about what versions of Autoconf, Automake, and Libtool you used Michael Imamura / LUG@GT

  11. What about portability? • The other reason to use Autoconf • General strategy: • Study the config.h generated by ./configure • For every #define: • Can we work around the issue? • Is the tested feature an absolute requirement? • Autoconf is not a magic bullet! • It’s up to YOU to decide how to react Michael Imamura / LUG@GT

  12. Beyond ./configure • “make check”: Unit tests with DejaGNU • Custom configure.ac tests • Tests are written in GNU M4 • Use AC_ARG_ENABLE to allow the user to customize your package with --enable-feature • Fine-tuning • Different flavors of “clean” Michael Imamura / LUG@GT

  13. There’s much more to say… • But this presentation is too small to contain it. • http://lugatgt.org/articles/autotools/ • Autoconf Macro Archive:http://autoconf-archive.cryp.to/ • “GNU Autoconf, Automake, and Libtool” by Gary Vaughan, et al.http://sourceware.org/autobook/(free download!) Michael Imamura / LUG@GT

More Related