SDL_net: autotools: added --disable-examples configuration option

From f1ba99d9f123dd1e77d00abf85356d319a4f0360 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Tue, 21 Jun 2022 15:55:50 +0300
Subject: [PATCH] autotools: added --disable-examples configuration option

---
 Makefile.am  |  2 ++
 Makefile.in  |  7 ++++---
 configure    | 53 ++++++++++++++++++++++++++++++++++++++--------------
 configure.ac |  5 +++++
 4 files changed, 50 insertions(+), 17 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 04e20b4..bdf7df3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -42,8 +42,10 @@ endif
 .rc.o:
 	$(RC) $< $@
 
+if ENABLE_EXAMPLES
 EXAMPLES = showinterfaces chat chatd
 noinst_PROGRAMS = $(EXAMPLES)
+endif
 
 showinterfaces_SOURCES = showinterfaces.c
 showinterfaces_LDADD = libSDL2_net.la
diff --git a/Makefile.in b/Makefile.in
index a094d42..ee1b885 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -92,7 +92,7 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 @USE_VERSION_RC_FALSE@libSDL2_net_la_DEPENDENCIES =
-noinst_PROGRAMS = $(am__EXEEXT_1)
+@ENABLE_EXAMPLES_TRUE@noinst_PROGRAMS = $(am__EXEEXT_1)
 subdir = .
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/acinclude/libtool.m4 \
@@ -113,7 +113,8 @@ mkinstalldirs = $(install_sh) -d
 CONFIG_CLEAN_FILES = sdl2_net-config.cmake \
 	sdl2_net-config-version.cmake SDL2_net.spec SDL2_net.pc
 CONFIG_CLEAN_VPATH_FILES =
-am__EXEEXT_1 = showinterfaces$(EXEEXT) chat$(EXEEXT) chatd$(EXEEXT)
+@ENABLE_EXAMPLES_TRUE@am__EXEEXT_1 = showinterfaces$(EXEEXT) \
+@ENABLE_EXAMPLES_TRUE@	chat$(EXEEXT) chatd$(EXEEXT)
 PROGRAMS = $(noinst_PROGRAMS)
 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
 am__vpath_adj = case $$p in \
@@ -435,7 +436,7 @@ libSDL2_net_la_LDFLAGS = \
 
 libSDL2_net_la_LIBADD = @INETLIB@
 @USE_VERSION_RC_TRUE@libSDL2_net_la_DEPENDENCIES = version.o
-EXAMPLES = showinterfaces chat chatd
+@ENABLE_EXAMPLES_TRUE@EXAMPLES = showinterfaces chat chatd
 showinterfaces_SOURCES = showinterfaces.c
 showinterfaces_LDADD = libSDL2_net.la
 chat_SOURCES = chat.c chat.h
diff --git a/configure b/configure
index 9e86f75..b594754 100755
--- a/configure
+++ b/configure
@@ -814,6 +814,8 @@ PKG_CONFIG_LIBDIR
 PKG_CONFIG_PATH
 PKG_CONFIG
 SDL_VERSION
+ENABLE_EXAMPLES_FALSE
+ENABLE_EXAMPLES_TRUE
 INETLIB
 USE_VERSION_RC_FALSE
 USE_VERSION_RC_TRUE
@@ -954,6 +956,7 @@ with_gnu_ld
 enable_libtool_lock
 enable_dependency_tracking
 enable_silent_rules
+enable_examples
 with_sdl_prefix
 with_sdl_exec_prefix
 enable_sdltest
@@ -1609,6 +1612,7 @@ Optional Features:
                           speeds up one-time build
   --enable-silent-rules   less verbose build output (undo: "make V=1")
   --disable-silent-rules  verbose build output (undo: "make V=0")
+  --disable-examples      Do not build example programs
   --disable-sdltest       Do not try to compile and run a test SDL program
 
 Optional Packages:
@@ -4531,13 +4535,13 @@ then :
 else $as_nop
   lt_cv_nm_interface="BSD nm"
   echo "int some_variable = 0;" > conftest.$ac_ext
-  (eval echo "\"\$as_me:4534: $ac_compile\"" >&5)
+  (eval echo "\"\$as_me:4538: $ac_compile\"" >&5)
   (eval "$ac_compile" 2>conftest.err)
   cat conftest.err >&5
-  (eval echo "\"\$as_me:4537: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
+  (eval echo "\"\$as_me:4541: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
   (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
   cat conftest.err >&5
-  (eval echo "\"\$as_me:4540: output\"" >&5)
+  (eval echo "\"\$as_me:4544: output\"" >&5)
   cat conftest.out >&5
   if $GREP 'External.*some_variable' conftest.out > /dev/null; then
     lt_cv_nm_interface="MS dumpbin"
@@ -5796,7 +5800,7 @@ ia64-*-hpux*)
   ;;
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 5799 "configure"' > conftest.$ac_ext
+  echo '#line 5803 "configure"' > conftest.$ac_ext
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -7469,11 +7473,11 @@ else $as_nop
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:7472: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:7476: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:7476: \$? = $ac_status" >&5
+   echo "$as_me:7480: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -7819,11 +7823,11 @@ else $as_nop
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:7822: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:7826: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:7826: \$? = $ac_status" >&5
+   echo "$as_me:7830: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -7926,11 +7930,11 @@ else $as_nop
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:7929: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:7933: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:7933: \$? = $ac_status" >&5
+   echo "$as_me:7937: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -7982,11 +7986,11 @@ else $as_nop
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:7985: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:7989: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:7989: \$? = $ac_status" >&5
+   echo "$as_me:7993: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -10425,7 +10429,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10428 "configure"
+#line 10432 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -10522,7 +10526,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10525 "configure"
+#line 10529 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12784,6 +12788,23 @@ printf "%s\n" "$have_gcc_fvisibility" >&6; }
     fi
 }
 
+# Check whether --enable-examples was given.
+if test ${enable_examples+y}
+then :
+  enableval=$enable_examples;
+else $as_nop
+  enable_examples=yes
+fi
+
+ if test x$enable_examples = xyes; then
+  ENABLE_EXAMPLES_TRUE=
+  ENABLE_EXAMPLES_FALSE='#'
+else
+  ENABLE_EXAMPLES_TRUE='#'
+  ENABLE_EXAMPLES_FALSE=
+fi
+
+
 SDL_VERSION=2.0.0
 
 
@@ -13453,6 +13474,10 @@ if test -z "${USE_VERSION_RC_TRUE}" && test -z "${USE_VERSION_RC_FALSE}"; then
   as_fn_error $? "conditional \"USE_VERSION_RC\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${ENABLE_EXAMPLES_TRUE}" && test -z "${ENABLE_EXAMPLES_FALSE}"; then
+  as_fn_error $? "conditional \"ENABLE_EXAMPLES\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 
 : "${CONFIG_STATUS=./config.status}"
 ac_write_fail=0
diff --git a/configure.ac b/configure.ac
index eb6e732..62ff48d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -184,6 +184,11 @@ CheckVisibilityHidden()
     fi
 }
 
+AC_ARG_ENABLE([examples],
+  AS_HELP_STRING([--disable-examples], [Do not build example programs]),,
+    enable_examples=yes)
+AM_CONDITIONAL(ENABLE_EXAMPLES, [test x$enable_examples = xyes])
+
 dnl Check for SDL
 SDL_VERSION=2.0.0
 AC_SUBST(SDL_VERSION)