From b1684c15322f08a51bb81fb1b7268887225751f8 Mon Sep 17 00:00:00 2001
From: Andre Noll <maan@tuebingen.mpg.de>
Date: Sat, 24 Jun 2023 21:36:17 +0200
Subject: [PATCH] build: Construct list of executables in Makefile.

This is actually easier and removes some duplication as we currently
have two copies of the logic which decides whether or not to build
each executable. We lose the summary output at the end of the configure
output, but that was incomplete anyway.
---
 Makefile.in   |  2 --
 Makefile.real |  7 ++++++-
 configure.ac  | 49 -------------------------------------------------
 3 files changed, 6 insertions(+), 52 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index 6e732500..396c8de6 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -33,8 +33,6 @@ HAVE_OSS := @HAVE_OSS@
 HAVE_ALSA := @HAVE_ALSA@
 HAVE_CURSES := @HAVE_CURSES@
 
-executables := @executables@
-
 speex_cppflags := @speex_cppflags@
 opus_cppflags := @opus_cppflags@
 vorbis_cppflags := @vorbis_cppflags@
diff --git a/Makefile.real b/Makefile.real
index 1d671dbe..117d72fa 100644
--- a/Makefile.real
+++ b/Makefile.real
@@ -14,7 +14,6 @@ SEVERITIES := \"debug\",\"info\",\"notice\",\"warning\",\"error\",\"crit\",\"eme
 vardir := /var/paraslash
 mandir := $(datarootdir)/man/man1
 MKDIR_P := mkdir -p
-prefixed_executables := $(addprefix para_, $(executables))
 
 build_date := $(shell date)
 uname_s := $(shell uname -s 2>/dev/null || echo "UNKNOWN_OS")
@@ -38,8 +37,10 @@ test_dir := t
 yy_src_dir := yy
 yy_build_dir := $(build_dir)/yy
 
+executables := recv filter audioc write afh play
 ifneq ($(CRYPTOLIB),)
 	ifeq ($(HAVE_OSL),yes)
+	executables += server upgrade_db
 		server_objs := $(addsuffix .o, \
 			server afh_common mp3_afh vss command net string \
 			signal time daemon http_send close_on_fork \
@@ -76,6 +77,7 @@ ifneq ($(CRYPTOLIB),)
 	endif
 endif
 ifneq ($(CRYPTOLIB),)
+	executables += client audiod
 	client_objs := $(addsuffix .o, \
 		client net string fd lsu sched stdin stdout time sideband client_common \
 		buffer_tree crypt_common base64 version $(CRYPTOLIB) \
@@ -130,6 +132,7 @@ ifneq ($(CRYPTOLIB),)
 	endif
 endif
 ifneq ($(HAVE_OSS)-$(HAVE_ALSA),no-no)
+	executables += mixer
 	mixer_objs := $(addsuffix .o, mixer exec string fd time lsu version)
 	ifeq ($(HAVE_OSS),yes)
 		mixer_objs += oss_mix.o
@@ -139,6 +142,7 @@ ifneq ($(HAVE_OSS)-$(HAVE_ALSA),no-no)
 	endif
 endif
 ifeq ($(HAVE_CURSES),yes)
+	executables += gui
 	gui_objs := $(addsuffix .o, exec signal string stat ringbuffer fd \
 		gui gui_theme lsu time sched version)
 endif
@@ -328,6 +332,7 @@ write_objs := $(addprefix $(object_dir)/, $(write_objs))
 afh_objs := $(addprefix $(object_dir)/, $(afh_objs))
 play_objs := $(addprefix $(object_dir)/, $(play_objs))
 
+prefixed_executables := $(addprefix para_, $(executables))
 man_pages := $(patsubst %, $(man_dir)/%.1, $(prefixed_executables))
 
 autocrap := config.h.in configure
diff --git a/configure.ac b/configure.ac
index 97fcafc6..4f9f4b54 100644
--- a/configure.ac
+++ b/configure.ac
@@ -61,7 +61,6 @@ REQUIRE_EXECUTABLE([bison])
 REQUIRE_EXECUTABLE([flex])
 REQUIRE_EXECUTABLE([m4])
 
-executables="recv filter audioc write afh play"
 ########################################################################### osl
 STASH_FLAGS
 LIB_ARG_WITH([osl], [-losl])
@@ -383,53 +382,5 @@ AC_ARG_ENABLE([ubsan], [AS_HELP_STRING(--enable-ubsan,
 	[Detect and report undefined behaviour.])],
 	[ENABLE_UBSAN=yes], [ENABLE_UBSAN=no])
 AC_SUBST(ENABLE_UBSAN)
-######################################################### server and upgrade_db
-if test -n "$CRYPTOLIB" && test $HAVE_OSL = yes; then
-	build_server="yes"
-	executables="$executables server upgrade_db"
-else
-	build_server="no"
-fi
-############################################################# client
-if test -n "$CRYPTOLIB"; then
-	build_client="yes"
-	executables="$executables client"
-else
-	build_client="no"
-fi
-############################################################# audiod
-if test -n "$CRYPTOLIB"; then
-	build_audiod="yes"
-	executables="$executables audiod"
-else
-	build_audiod="no"
-fi
-########################################################################### mixer
-if test $HAVE_OSS = yes -o $HAVE_ALSA = yes; then
-	build_mixer="yes"
-	executables="$executables mixer"
-fi
-########################################################################### gui
-if test $HAVE_CURSES = yes; then
-	build_gui="yes"
-	executables="$executables gui"
-fi
-######################################################################## audioc
-AC_SUBST(executables)
 
 AC_OUTPUT
-AC_MSG_NOTICE([
-paraslash configuration:
-~~~~~~~~~~~~~~~~~~~~~~~~
-crypto lib: ${CRYPTOLIB:-[none]}
-readline (interactive CLIs): $HAVE_READLINE
-id3 version 2 support: $HAVE_ID3TAG
-faad: $HAVE_FAAD
-
-exe: $executables
-para_server: $build_server
-para_gui: $build_gui
-para_mixer: $build_mixer
-para_client: $build_client
-para_audiod: $build_audiod
-])
-- 
2.39.5