0

I'm trying to set an --enable-gui switch for my program but it doesn't seem to work.

In configure.ac I have

AC_INIT([cwallet], [1.1], [[email protected]])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_PROG_CC
AM_PROG_CC_C_O
AC_CONFIG_HEADERS([config.h])
AC_ARG_ENABLE([gui],
 [AS_HELP_STRING([--enable-gui],
 [enable GUI (default is yes)])],
 [enable_gui=$enableval],
 [enable_gui=yes]) 
if test x$enable_gui != xno; then
 PKG_CHECK_MODULES([GTK2],[gtk+-2.0])
fi
< ... some stuff ... >
AC_CONFIG_FILES([
 Makefile
 src/Makefile
])
AC_OUTPUT
AM_CONDITIONAL([ENABLE_GUI],[test x$enable_gui == xyes])

In src/Makefile.am I have

if ENABLE_GUI
bin_PROGRAMS = cwallet cwallet-gui
cwallet_SOURCES = main.c cwallet.c
cwallet_gui_SOURCES = main-gui.c cwallet.c
cwallet_gui_LDADD = $(GTK2_LIBS)
cwallet_gui_CPPFLAGS = $(GTK2_CFLAGS)
else
bin_PROGRAMS = cwallet
cwallet_SOURCES = main.c cwallet.c
endif

But when I do ./autogen.sh && ./configure -with-gui=no && make, it says it can't find gtk.h, so I guess it is using ENABLE_GUI = true for the Makefile, when it shouldn't.

What's the proper way to do this?

asked Jan 1, 2025 at 10:50
1
  • you have to pass --disable-gui (or --enable-gui=no) to configure, rather than -with-gui=no (with and enable settings are orthogonal and use different namespaces) Commented Feb 10, 2025 at 16:33

1 Answer 1

0

OK I think I figured out the problem. The AM_CONDITIONAL statement should be further up in the configure.ac (right after if test x$enable_gui... block)

answered Jan 1, 2025 at 10:56
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.