Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8366685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:58:34+00:00 2026-06-09T12:58:34+00:00

I have an autotools project. I wish to exclude some files from the project,

  • 0

I have an autotools project. I wish to exclude some files from the project, if the user configures so during build. For example, if the build is configured with –no-gui , the files related to GUI are not to be included in the build.

  1. What is the standard macro for such a flag in autoconf? Something that could be configured with like –disable-gui?

  2. How to establish the link between this configure option and automake input files?

I have Calcote’s introductory book Autotools here. If you can give pointers as to the macros involved, I can look it up in the book or the net.

Thank you,

Elan.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T12:58:35+00:00Added an answer on June 9, 2026 at 12:58 pm

    According to the autoconf manual, the correct way to do this is with an --enable-FEATURE argument to configure. That’s done using the macro AC_ARG_ENABLE. The four argument to AC_ARG_ENABLE are, in order, FEATURE, HELP-STRING, ACTION-IF-GIVEN, ACTION-IF-NOT-GIVEN. So in configure.ac:

    AC_ARG_ENABLE([gui],
      [AS_HELP_STRING([--disable-gui], [Enable GUI support @<:@check@:>@])],
      [:],
      [enable_gui=check])
    

    AS_HELP_STRING wraps the help string nicely, and the @<:@ and @:>@ are quadrigraphs which expand to [ and ] in the output of ./configure --help. Even though I’ve specified an empty ACTION-IF-GIVEN, configure will still set enable_gui to yes or no, depending on whether --enable-gui or --disable-gui (which is an alias for --enable-gui=no) was passed.

    So the shell variable $enable_gui will be either yes, no or check. This is for the benefit of the poor packagers who make the distribution packages, as it’s considered poor form to build optional support based only on a check. See the gentoo article on automagic dependencies, but packagers would prefer for the build to fail than silently not include a wanted feature.

    Now, if $enable_gui is yes or check, we want to check for dependencies and fail if we manually enabled the feature. Since I don’t know what library your gui depends on, I’m just going to use pkg-config to check for gtk+-2.0. The four arguments to PKG_CHECK_MODULES (provided by the pkg-config package) are, in order, VARIABLE, MODULES, ACTION-IF-FOUND and ACTION-IF-NOT-FOUND:

    AS_IF([test "$enable_gui" != "no"],
      [PKG_CHECK_MODULES([GTK],
        [gtk+-2.0],
        [enable_gui=yes],
        [AS_IF([test "$enable_gui" = "yes"],
          [AC_MSG_ERROR([gtk+-2.0 required, but not found.])],
          [enable_gui=no])])])
    

    The reason we use AS_IF instead of just writing a normal shell if-expression is so that autoconf expands anything that an enclosed macro might require (here PKG_CHECK_MODULES internally depends on macros like PKG_PROG_PKG_CONFIG). You can test that this does the right thing in all cases by doing something like ./configure --enable-gui PKG_CONFIG=/bin/false.

    Anyway, we’ve now resolved enable_gui=check into either enable_gui=yes or enable_gui=no. Now we have to pass this to automake. The macro to use is AM_CONDITIONAL. Its arguments are, in order, CONDITIONAL (the name used in Makefile.am) and CONDITION (the shell test to set CONDITIONAL):

    AM_CONDITIONAL([ENABLE_GUI], [test "$enable_gui" = "yes"])
    

    Now, we move over to Makefile.am, I’m going to assume a simple program with a couple of optional sources:

    # You probably have something real for these.
    AM_CFLAGS =
    LDADD =
    
    bin_PROGRAMS = elanprog
    elanprog_SOURCES = elanprog.c elanfile.c
    
    if ENABLE_GUI
    AM_CFLAGS += $(GTK_CFLAGS)
    LDADD += $(GTK_LIBS)
    elanprog_SOURCES += elangui.c
    endif
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a project with autotools: automake, autoconf. I want to prohibit make from
Problem: I have a project which I'm porting from Solaris/Lex/Yacc to Linux/Flex/Bison + Autotools.
I have an autotools project. The same tarball on one machine compiles the files
A have a project build with GNU autotools. Now I have a tiny change
I have a C++ project that uses the GNU Autotools for its build scripts
I have a project that uses autotools. A nice feature of autotools is 'out-of-source'
We have an autotools project that has a mixture of unit and integration tests,
Summary : I have a project using GNU Autotools. I have a pot file.
In a project built with GNU Autotools, I have a script that needs to
I'm currently converting a small C project from autotools to CMake . In the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.