### DESTDIR Staged Install for Packaging Source: https://context7.com/autotools-mirror/automake/llms.txt Example of performing a staged installation using `DESTDIR` for creating binary packages. ```sh # DESTDIR staged install for binary packaging ./configure --prefix=/usr make make DESTDIR=$HOME/staging install tar -czf myapp-1.0-x86_64.tar.gz -C $HOME/staging . ``` -------------------------------- ### Cross-Compilation Setup Source: https://context7.com/autotools-mirror/automake/llms.txt Example of configuring a build for a different architecture (ARM) using a specific cross-compiler. ```sh ../configure --host=arm-linux-gnueabihf \ --prefix=/usr \ CC=arm-linux-gnueabihf-gcc make ``` -------------------------------- ### Two-Part Installation Awareness Source: https://context7.com/autotools-mirror/automake/llms.txt Automake separates installation into architecture-dependent (`install-exec`) and independent (`install-data`) targets. Use `DESTDIR` for staged installs. ```makefile ## Makefile.am — two-part install awareness exec_prefix = /usr bindir = $(exec_prefix)/bin # install-exec libdir = $(exec_prefix)/lib # install-exec datadir = $(prefix)/share # install-data docdir = $(datadir)/doc/$(PACKAGE) # install-data bin_PROGRAMS = myapp # → install-exec lib_LIBRARIES = libmyapp.a # → install-exec data_DATA = myapp.conf # → install-data dist_doc_DATA = README COPYING # → install-data ``` -------------------------------- ### Texinfo Documentation Build Commands Source: https://context7.com/autotools-mirror/automake/llms.txt Commands to explicitly build and install different formats of Texinfo documentation. ```sh make dvi # build mypkg.dvi make pdf # build mypkg.pdf make html # build mypkg.html make install-info # install .info pages (already done by 'make install') make install-pdf # explicitly install PDF ``` -------------------------------- ### Standard VPATH Build Process Source: https://context7.com/autotools-mirror/automake/llms.txt Steps for performing a standard build using VPATH, including configuration, compilation, testing, and installation. ```sh tar xf amhello-1.0.tar.gz cd amhello-1.0 mkdir build && cd build ../configure --prefix=/usr/local make make check sudo make install ``` -------------------------------- ### Building Programs with bin_PROGRAMS and _SOURCES Source: https://context7.com/autotools-mirror/automake/llms.txt Declare installable programs using the bin_PROGRAMS primary. Source files for each program 'prog' are listed in 'prog_SOURCES'. Non-alphanumeric characters in program names are converted to underscores for the _SOURCES variable. ```makefile ## src/Makefile.am — building a program bin_PROGRAMS = hello sniff-glue hello_SOURCES = main.c util.c util.h # Canonicalized: hyphens become underscores sniff_glue_SOURCES = sniff-glue.c sniff-glue.h # Extra link libraries and flags hello_LDADD = ../lib/libgreeting.a hello_LDFLAGS = -Wl,--as-needed ``` -------------------------------- ### Texinfo Documentation Configuration Source: https://context7.com/autotools-mirror/automake/llms.txt Automake configuration for building and installing Texinfo documentation, including custom flags and dependencies. ```makefile ## doc/Makefile.am — Texinfo documentation info_TEXINFOS = mypkg.texi # Include files (not standalone, but listed as dependencies) mypkg_TEXINFOS = fdl.texi version.texi # Single-file HTML output (no split) AM_MAKEINFOHTMLFLAGS = --no-headers --no-split # Custom texi2dvi location TEXI2DVI = texi2dvi ``` -------------------------------- ### Minimal configure.ac Setup with AM_INIT_AUTOMAKE Source: https://context7.com/autotools-mirror/automake/llms.txt This is the essential call required in every configure.ac file that uses Automake. It initializes the Automake subsystem and accepts options. Ensure AC_CONFIG_FILES lists all Makefiles to be generated and AC_OUTPUT finalizes their creation. ```autoconf # configure.ac — minimal working example AC_INIT([mypkg], [1.0], [bugs@example.com]) AM_INIT_AUTOMAKE([-Wall -Werror foreign]) AC_PROG_CC AC_CONFIG_HEADERS([config.h]) AC_CONFIG_FILES([ Makefile src/Makefile tests/Makefile ]) AC_OUTPUT ``` -------------------------------- ### Test Suite Configuration Source: https://context7.com/autotools-mirror/automake/llms.txt Configure test scripts and programs in `tests/Makefile.am`. Use `AM_TESTS_ENVIRONMENT` for developer setup and `TESTS_ENVIRONMENT` for user overrides. ```makefile ## tests/Makefile.am — test suite TESTS = foo.sh bar.sh # C program tests check_PROGRAMS = test_parser test_encoder TESTS += test_parser test_encoder test_parser_SOURCES = test_parser.c test_parser_LDADD = ../src/libmyapp.a test_encoder_SOURCES = test_encoder.c test_encoder_LDADD = ../src/libmyapp.a # Developer test environment setup (must end with semicolon) AM_TESTS_ENVIRONMENT = \ export srcdir='$(srcdir)'; \ export PATH='$(abs_top_builddir)/src:$$PATH'; # Custom runner for all .py test files TEST_EXTENSIONS = .sh .py PY_LOG_COMPILER = $(PYTHON) AM_PY_LOG_FLAGS = -B ``` -------------------------------- ### Makefile.am for Installing Custom Macros Source: https://context7.com/autotools-mirror/automake/llms.txt Specify custom .m4 macros to be installed by other packages using Makefile.am. ```makefile ## Makefile.am — install custom m4 macros for other packages aclocaldir = $(datadir)/aclocal aclocal_DATA = m4/ax_my_feature.m4 ``` -------------------------------- ### TAP Test Protocol Integration Source: https://context7.com/autotools-mirror/automake/llms.txt Example of a TAP-speaking test script. Ensure your scripts emit lines like 'ok 1 - description' or 'not ok 2 - description'. ```sh #!/bin/sh # tests/basic.test — a TAP-speaking test script echo '1..3' echo 'ok 1 - program exits zero' ./myapp && echo 'ok 2 - output matches' || echo 'not ok 2 - output mismatch' echo 'ok 3 - no tmp files left # SKIP not yet implemented' ``` -------------------------------- ### Basic aclocal Invocation Source: https://context7.com/autotools-mirror/automake/llms.txt Run aclocal to scan configure.ac and generate aclocal.m4. Use -I to add search directories or --install to copy system macros. ```sh # Basic aclocal run (reads configure.ac, writes aclocal.m4) aclocal ``` ```sh # Add extra search directory aclocal -I /opt/local/share/aclocal ``` ```sh # Copy system macros into local m4/ (recommended for reproducibility) aclocal --install -I m4 ``` ```sh # Set search path via environment (colon-separated) ACLOCAL_PATH=/opt/local/share/aclocal aclocal ``` -------------------------------- ### Automake Uniform Naming Scheme Examples Source: https://context7.com/autotools-mirror/automake/llms.txt Automake uses a '_' naming convention. Standard directory variables can prefix primaries. Custom directories require a corresponding 'dir' variable definition. Prefixes like 'noinst_' and 'check_' are available for build-only or test-suite specific targets. ```makefile ## Makefile.am — uniform naming examples # Standard directories bin_PROGRAMS = myapp lib_LIBRARIES = libutil.a include_HEADERS = myapp.h data_DATA = config.dat man1_MANS = myapp.1 info_TEXINFOS = myapp.texi # Custom directory xmldir = $(datadir)/xml xml_DATA = schema.xsd # Not installed (build-only helpers) noinst_LIBRARIES = libinternal.a # Only built during 'make check' check_PROGRAMS = test_util check_LIBRARIES = libtest_helpers.a ``` -------------------------------- ### Standard Makefile Targets Source: https://context7.com/autotools-mirror/automake/llms.txt Common targets provided by Automake-generated Makefiles for building, installing, cleaning, and distributing software. ```sh make # build everything (alias for 'make all') make all # build programs, libraries, documentation make install # copy files to system directories make uninstall # remove installed files make install-exec # install architecture-dependent files only make install-data # install architecture-independent files only make check # run the test suite make installcheck # run tests on installed files make clean # remove files built by 'make all' make distclean # also remove files created by ./configure make maintainer-clean # remove everything that can be regenerated make dist # create package-version.tar.gz make distcheck # create tarball and validate it exhaustively make dist-xz # create package-version.tar.xz make dist-bzip2 # create package-version.tar.bz2 make dist-zip # create package-version.zip make dvi # build DVI documentation make pdf # build PDF documentation make html # build HTML documentation make ps # build PostScript documentation make TAGS # generate TAGS file for editors make ctags # generate ctags file ``` -------------------------------- ### Custom aclocal Macro Definition Source: https://context7.com/autotools-mirror/automake/llms.txt Define a custom aclocal macro in an .m4 file. Include a '# serial N' line for versioning with --install. ```m4 # m4/ax_check_openssl.m4 # serial 4 AC_DEFUN([AX_CHECK_OPENSSL], [AC_PREREQ([2.69])dnl AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_CHECK_LIB([ssl], [SSL_library_init], [AC_DEFINE([HAVE_OPENSSL], [1], [Define if OpenSSL is available]) OPENSSL_LIBS="-lssl -lcrypto" AC_SUBST([OPENSSL_LIBS])], [AC_MSG_ERROR([OpenSSL not found])]) ]) ``` -------------------------------- ### Conditional Subdirectory Compilation Source: https://context7.com/autotools-mirror/automake/llms.txt Use AM_CONDITIONAL to define boolean flags for conditional compilation in Makefiles. This example controls whether the 'gui' subdirectory is included. ```autoconf # configure.ac AC_ARG_ENABLE([gui], [AS_HELP_STRING([--enable-gui], [build graphical front-end])], [want_gui=$enableval], [want_gui=no]) AM_CONDITIONAL([BUILD_GUI], [test "$want_gui" = yes]) AC_CONFIG_FILES([Makefile src/Makefile gui/Makefile]) ``` -------------------------------- ### Simultaneous Configurations from One Source Tree Source: https://context7.com/autotools-mirror/automake/llms.txt Demonstrates setting up two different build configurations (debug and optimized) from a single source directory using different CFLAGS. ```sh mkdir debug optim cd debug && ../configure CFLAGS='-g -O0' && make && cd .. cd optim && ../configure CFLAGS='-O3 -march=native' && make && cd .. ``` -------------------------------- ### Bootstrap a New Package with autoreconf Source: https://context7.com/autotools-mirror/automake/llms.txt Use autoreconf to initialize the build system for a new package. It calls autoconf, automake, aclocal, and others in the correct order. ```sh # Create the five source files for a minimal package mkdir -p amhello/src cat > amhello/src/main.c << 'EOF' #include #include int main(void) { puts("Hello World!"); puts("This is " PACKAGE_STRING "."); return 0; } EOF cat > amhello/src/Makefile.am << 'EOF' bin_PROGRAMS = hello hello_SOURCES = main.c EOF cat > amhello/Makefile.am << 'EOF' SUBDIRS = src dist_doc_DATA = README EOF cat > amhello/README << 'EOF' This is a demonstration package for GNU Automake. EOF cat > amhello/configure.ac << 'EOF' AC_INIT([amhello], [1.0], [bugs@example.com]) AM_INIT_AUTOMAKE([-Wall -Werror foreign]) AC_PROG_CC AC_CONFIG_HEADERS([config.h]) AC_CONFIG_FILES([Makefile src/Makefile]) AC_OUTPUT EOF # Bootstrap (generates configure, Makefile.in, config.h.in, etc.) cd amhello autoreconf --install # Configure, build, test, and install ./configure --prefix=$HOME/usr make make check make install # installs to ~/usr/bin/hello and ~/usr/share/doc/amhello/README make installcheck # Build a distribution tarball and validate it fully make distcheck # Expected output: # ============================================= # amhello-1.0 archives ready for distribution: # amhello-1.0.tar.gz # ============================================= ``` -------------------------------- ### Basic automake Invocation Source: https://context7.com/autotools-mirror/automake/llms.txt Run automake to generate Makefile.in files from Makefile.am. Use --add-missing to include auxiliary files. ```sh # Generate Makefile.in for all Makefiles listed in configure.ac automake ``` ```sh # Add missing auxiliary files (install-sh, depcomp, etc.) as symlinks automake --add-missing ``` ```sh # Add missing files as copies instead of symlinks automake --add-missing --copy ``` ```sh # Set strictness to 'foreign' (relax GNU-standard file requirements) automake --foreign ``` ```sh # Enable all warnings and treat them as errors automake -Wall -Werror ``` ```sh # Suppress portability warnings automake -Wno-portability ``` ```sh # Enable extra portability warnings (Microsoft lib, etc.) automake -Wextra-portability ``` ```sh # Verbose: print every file read or created automake --verbose ``` ```sh # Use multiple threads to process Makefile.in files concurrently AUTOMAKE_JOBS=4 automake ``` -------------------------------- ### Running Automake Tests Source: https://context7.com/autotools-mirror/automake/llms.txt Commands for running the test suite, including parallel execution, verbose output, colored output, and running individual tests. ```sh # Run tests make check # Run tests in parallel with verbose output make -j4 check VERBOSE=1 # Run tests with coloured output forced make check AM_COLOR_TESTS=always # Run a single test make check TESTS=tests/foo.sh ``` -------------------------------- ### Building Shared Libraries with LTLIBRARIES (Libtool) Source: https://context7.com/autotools-mirror/automake/llms.txt Use the LTLIBRARIES primary with LT_INIT for shared libraries. Libtool library files have the .la suffix. Link-time additions are handled by _LIBADD, and linker flags by _LDFLAGS. ```makefile ## src/Makefile.am — shared/static Libtool library lib_LTLIBRARIES = libfoo.la libfoo_la_SOURCES = foo.c foo.h bar.c libfoo_la_LIBADD = $(LIBM) libfoo_la_LDFLAGS = -version-info 3:1:0 -no-undefined # Consumer program bin_PROGRAMS = myapp myapp_SOURCES = main.c myapp_LDADD = libfoo.la ``` -------------------------------- ### Controlling Build Verbosity Source: https://context7.com/autotools-mirror/automake/llms.txt Demonstrates how to control the verbosity of the build process using the 'V' variable. ```sh make # quiet: shows " CC src/foo.o" make V=1 # verbose: shows full compiler invocation make V=0 # force quiet even when configure default is verbose ``` -------------------------------- ### Building Static Libraries with lib_LIBRARIES and _LIBADD Source: https://context7.com/autotools-mirror/automake/llms.txt Use the LIBRARIES primary for static archives. The archive name is canonicalized for the _SOURCES variable. Add configure-time objects via _LIBADD. Ensure AC_PROG_RANLIB and AM_PROG_AR are called in configure.ac. ```makefile ## lib/Makefile.am — static library noinst_LIBRARIES = libcpio.a libcpio_a_SOURCES = \ copyin.c \ copyout.c \ copypass.c \ util.c # Objects determined at configure time (e.g. replacements for missing fns) libcpio_a_LIBADD = $(LIBOBJS) $(ALLOCA) # Program that links against the library bin_PROGRAMS = cpio cpio_SOURCES = cpio.c cpio_LDADD = libcpio.a ``` -------------------------------- ### Makefile.am for TAP Test Integration Source: https://context7.com/autotools-mirror/automake/llms.txt Configure Makefile.am to use Automake's parallel harness with TAP tests. Set TEST_EXTENSIONS and TEST_LOG_DRIVER. ```makefile ## Makefile.am — enabling TAP TEST_EXTENSIONS = .test TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/tap-driver.sh AM_TEST_LOG_DRIVER_FLAGS = --merge --comments TESTS = basic.test advanced.test ``` -------------------------------- ### Recursive Build Configuration Source: https://context7.com/autotools-mirror/automake/llms.txt Define subdirectories to be built recursively. The order can be customized. ```makefile SUBDIRS = lib src doc tests # Custom build order: build 'lib' and 'src' first, # then the current directory, then 'tests' # SUBDIRS = lib src . tests # When 'opt/' is conditionally excluded from the build # but must still be distributed: # DIST_SUBDIRS = lib src doc tests opt ``` -------------------------------- ### Adding Shared Libraries Support with LT_INIT Source: https://context7.com/autotools-mirror/automake/llms.txt Include LT_INIT in configure.ac for portable shared libraries using Libtool. Libtool library files use the .la suffix. Link-time additions are specified in _LIBADD, and linker flags in _LDFLAGS. ```autoconf # configure.ac additions for shared libraries LT_INIT ``` -------------------------------- ### Enabling Silent Rules in Automake Source: https://context7.com/autotools-mirror/automake/llms.txt Configuration to reduce build verbosity by showing only status tags instead of full command lines. Verbosity can be restored with 'make V=1'. ```autoconf # configure.ac AM_SILENT_RULES([yes]) # silent by default; 'make V=1' restores verbosity ``` -------------------------------- ### Obsolete Automake Substitutions and Variables Source: https://github.com/autotools-mirror/automake/blob/master/PLANS/obsolete-removed/am-prog-mkdir-p.txt The '@mkdir_p@' substitution and '$(mkdir_p)' make variable are still supported as aliases for '$(MKDIR_P)'. ```make @mkdir_p@ ``` ```make $(mkdir_p) ``` -------------------------------- ### Declare Local Macro Directory with aclocal Source: https://context7.com/autotools-mirror/automake/llms.txt Use AC_CONFIG_MACRO_DIRS in configure.ac to declare directories where aclocal should look for local macros. ```autoconf # configure.ac — declare local macro directory AC_CONFIG_MACRO_DIRS([m4]) ``` -------------------------------- ### Automake AM_PROG_MKDIR_P Macro Usage Source: https://github.com/autotools-mirror/automake/blob/master/PLANS/obsolete-removed/am-prog-mkdir-p.txt This macro is used in configure.ac to ensure the mkdir -p command is available. It is now an alias for AC_PROG_MKDIR_P and issues a non-fatal runtime warning. ```autoconf AM_PROG_MKDIR_P ``` -------------------------------- ### Conditional Makefile.am Structure Source: https://context7.com/autotools-mirror/automake/llms.txt Conditionally include subdirectories and define sources based on build flags like BUILD_GUI. ```makefile ## Makefile.am — conditional subdirectory if BUILD_GUI MAYBE_GUI = gui endif SUBDIRS = src $(MAYBE_GUI) DIST_SUBDIRS = src gui # always distribute gui/ ``` ```makefile ## src/Makefile.am — conditional sources bin_PROGRAMS = myapp if BUILD_GUI myapp_SOURCES = main.c gui_backend.c else myapp_SOURCES = main.c tui_backend.c endif ``` -------------------------------- ### Gettext Version Specification in configure.ac Source: https://github.com/autotools-mirror/automake/blob/master/PLANS/obsolete-removed/am-prog-mkdir-p.txt Specifying the Gettext version in configure.ac can influence which data files are brought into the package's tree by autopoint. Older versions of these data files may still contain the deprecated AM_PROG_MKDIR_P macro. ```autoconf AM_GNU_GETTEXT_VERSION([0.18]) ``` ```autoconf AM_GNU_GETTEXT_VERSION([0.18.2]) ``` -------------------------------- ### Distribution Control in Makefile.am Source: https://context7.com/autotools-mirror/automake/llms.txt Manage files included in the distribution tarball using `dist_`, `nodist_`, `EXTRA_DIST`, and `DISTCLEANFILES`. ```makefile ## Makefile.am — distribution control # Install README in docdir AND include it in the tarball dist_doc_DATA = README AUTHORS # Generated headers: built but NOT distributed nodist_include_HEADERS = config.h stamp-h1 # Extra files to include in 'make dist' EXTRA_DIST = autogen.sh m4/ax_check_openssl.m4 contrib/ # Files to remove on 'make distclean' DISTCLEANFILES = config.h stamp-h1 # Files to remove on 'make maintainer-clean' MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure # Conditionally-built sources (Automake must know about all of them) bin_PROGRAMS = hello hello_SOURCES = hello-common.c EXTRA_hello_SOURCES = hello-linux.c hello-generic.c hello_LDADD = $(HELLO_SYSTEM) hello_DEPENDENCIES = $(HELLO_SYSTEM) ``` -------------------------------- ### Recursive Subdirectories with SUBDIRS and DIST_SUBDIRS Source: https://context7.com/autotools-mirror/automake/llms.txt SUBDIRS specifies directories for recursive 'make' processing. DIST_SUBDIRS is crucial for distribution and cleaning rules, ensuring all configured directories, including conditional ones, are included. ```makefile ``` -------------------------------- ### Makefile Hook for Custom Target Source: https://context7.com/autotools-mirror/automake/llms.txt Implement custom logic for a recursive target like 'coverage-local' in Makefile.am. ```makefile ## Makefile.am — hook for custom recursive target coverage-local: $(LCOV) --capture --directory . --output-file coverage.info ``` -------------------------------- ### Custom Recursive Target Source: https://context7.com/autotools-mirror/automake/llms.txt Define custom recursive targets for Automake builds, such as 'coverage'. ```autoconf # configure.ac — custom recursive target AM_EXTRA_RECURSIVE_TARGETS([coverage]) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.