]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - Makefile.real
build: Rename all_objs -> dep_objs.
[paraslash.git] / Makefile.real
index c8d30aae7f6d2171e8c45bc037da88512562f92b..92a5724b3cc6543553dcaf8dbdf6385e4169e41e 100644 (file)
@@ -10,17 +10,17 @@ endif
 .SHELLFLAGS := -ec
 
 LOGLEVELS := LL_DEBUG,LL_INFO,LL_NOTICE,LL_WARNING,LL_ERROR,LL_CRIT,LL_EMERG
+SEVERITIES := \"debug\",\"info\",\"notice\",\"warning\",\"error\",\"crit\",\"emerg\"
 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")
 uname_rs := $(shell uname -rs)
 cc_version := $(shell $(CC) --version | head -n 1)
 GIT_VERSION := $(shell ./GIT-VERSION-GEN git-version.h)
-COPYRIGHT_YEAR := 2018
+COPYRIGHT_YEAR := 2024
 
 ifeq ("$(origin O)", "command line")
        build_dir := $(O)
@@ -34,15 +34,263 @@ m4depdir := $(build_dir)/m4deps
 lls_suite_dir := $(build_dir)/lls
 lls_m4_dir := m4/lls
 test_dir := t
-yy_src_dir = yy
-yy_build_dir = $(build_dir)/yy
+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 \
+                       crypt_common base64 ipc dccp_send fd user_list \
+                       chunk_queue afs aft mood mp score attribute blob \
+                       playlist sched acl send_common udp_send color fec \
+                       wma_afh wma_common sideband version lsu \
+               )
+               ifeq ($(CRYPTOLIB),openssl)
+                       server_objs += openssl.o
+               else
+                       server_objs += gcrypt.o
+               endif
+               ifeq ($(NEED_OGG_OBJECTS),yes)
+                       server_objs += ogg_afh_common.o
+               endif
+               ifeq ($(NEED_VORBIS_OBJECTS),yes)
+                       server_objs += ogg_afh.o
+               endif
+               ifeq ($(NEED_SPEEX_OBJECTS),yes)
+                       server_objs += spx_afh.o spx_common.o
+               endif
+               ifeq ($(NEED_OPUS_OBJECTS),yes)
+                       server_objs += opus_afh.o opus_common.o
+               endif
+               ifeq ($(NEED_FLAC_OBJECTS),yes)
+                       server_objs += flac_afh.o
+               endif
+               ifeq ($(HAVE_FAAD),yes)
+                       server_objs += aac_afh.o mp4.o
+               endif
+               upgrade_db_objs := $(addsuffix .o, crypt_common exec fd string \
+                       upgrade_db version base64)
+       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) \
+       )
+       ifeq ($(HAVE_READLINE),yes)
+               client_objs += interactive.o
+       endif
+       audiod_objs := $(addsuffix .o, \
+               audiod signal string daemon stat net crypt_common base64 sideband \
+               time grab_client filter_common wav_filter compress_filter amp_filter \
+               http_recv dccp_recv recv_common fd sched write_common file_write \
+               audiod_command fecdec_filter client_common udp_recv color fec \
+               prebuffer_filter version bitstream imdct wma_common wmadec_filter \
+               buffer_tree sync_filter lsu $(CRYPTOLIB) \
+       )
+       audiod_audio_formats := "wma"
+       ifeq ($(NEED_VORBIS_OBJECTS),yes)
+               audiod_objs += oggdec_filter.o
+               audiod_audio_formats += ,"ogg"
+       endif
+       ifeq ($(NEED_SPEEX_OBJECTS),yes)
+               audiod_objs += spxdec_filter.o spx_common.o
+               audiod_audio_formats += ,"spx"
+       endif
+       ifeq ($(NEED_OPUS_OBJECTS),yes)
+               audiod_objs += opusdec_filter.o opus_common.o
+               audiod_audio_formats += ,"opus"
+       endif
+       ifeq ($(NEED_FLAC_OBJECTS),yes)
+               audiod_objs += flacdec_filter.o
+               audiod_audio_formats += ,"flac"
+       endif
+       ifeq ($(HAVE_FAAD),yes)
+               audiod_objs += aacdec_filter.o
+               audiod_audio_formats += ,"aac"
+       endif
+       ifeq ($(HAVE_MAD),yes)
+               audiod_objs += mp3dec_filter.o
+               audiod_audio_formats += ,"mp3"
+       endif
+       ifeq ($(HAVE_OSS),yes)
+               audiod_objs += oss_write.o
+       endif
+       ifeq ($(HAVE_ALSA),yes)
+               audiod_objs += alsa_write.o
+       endif
+       ifeq ($(NEED_AO_OBJECTS),yes)
+               audiod_objs += ao_write.o
+       endif
+       ifeq ($(HAVE_SAMPLERATE),yes)
+               audiod_objs += resample_filter.o check_wav.o
+       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
+       endif
+       ifeq ($(HAVE_ALSA),yes)
+               mixer_objs += alsa_mix.o
+       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
+filter_objs := $(addsuffix .o, \
+       filter_common wav_filter compress_filter filter string stdin stdout \
+       sched fd amp_filter fecdec_filter fec lsu version prebuffer_filter \
+       time bitstream imdct wma_common wmadec_filter buffer_tree net \
+       sync_filter \
+)
+ifeq ($(NEED_VORBIS_OBJECTS),yes)
+       filter_objs += oggdec_filter.o
+endif
+ifeq ($(NEED_SPEEX_OBJECTS),yes)
+       filter_objs += spxdec_filter.o spx_common.o
+endif
+ifeq ($(NEED_OPUS_OBJECTS),yes)
+       filter_objs += opusdec_filter.o opus_common.o
+endif
+ifeq ($(NEED_FLAC_OBJECTS),yes)
+       filter_objs += flacdec_filter.o
+endif
+ifeq ($(HAVE_FAAD),yes)
+       filter_objs += aacdec_filter.o
+endif
+ifeq ($(HAVE_MAD),yes)
+       filter_objs += mp3dec_filter.o
+endif
+ifeq ($(HAVE_SAMPLERATE),yes)
+       filter_objs += resample_filter.o check_wav.o
+endif
+
+recv_objs := $(addsuffix .o, \
+       http_recv recv_common recv time string net dccp_recv fd sched stdout \
+       udp_recv buffer_tree afh_recv afh_common wma_afh wma_common mp3_afh \
+       version \
+)
+ifeq ($(NEED_OGG_OBJECTS),yes)
+       recv_objs += ogg_afh_common.o
+endif
+ifeq ($(NEED_VORBIS_OBJECTS),yes)
+       recv_objs += ogg_afh.o
+endif
+ifeq ($(NEED_SPEEX_OBJECTS),yes)
+       recv_objs += spx_afh.o spx_common.o
+endif
+ifeq ($(NEED_OPUS_OBJECTS),yes)
+       recv_objs += opus_afh.o opus_common.o
+endif
+ifeq ($(NEED_FLAC_OBJECTS),yes)
+       recv_objs += flac_afh.o
+endif
+ifeq ($(HAVE_FAAD),yes)
+       recv_objs += aac_afh.o mp4.o
+endif
+
+audio_format_handlers := mp3 wma
+afh_objs := $(addsuffix .o, afh string fd mp3_afh afh_common time wma_afh \
+       wma_common version)
+ifeq ($(NEED_OGG_OBJECTS),yes)
+       afh_objs += ogg_afh_common.o
+endif
+ifeq ($(NEED_VORBIS_OBJECTS),yes)
+       afh_objs += ogg_afh.o
+       audio_format_handlers += ogg
+endif
+ifeq ($(NEED_SPEEX_OBJECTS),yes)
+       afh_objs += spx_common.o
+       audio_format_handlers += spx
+endif
+ifeq ($(NEED_OPUS_OBJECTS),yes)
+       afh_objs += opus_afh.o opus_common.o
+       audio_format_handlers += opus
+endif
+ifeq ($(NEED_FLAC_OBJECTS),yes)
+       afh_objs += flac_afh.o
+       audio_format_handlers += flac
+endif
+ifeq ($(HAVE_FAAD),yes)
+       afh_objs += aac_afh.o mp4.o
+       audio_format_handlers += aac
+endif
+
+play_objs := $(addsuffix .o, \
+       play fd sched buffer_tree time string net afh_recv afh_common \
+       wma_afh wma_common mp3_afh recv_common udp_recv http_recv dccp_recv \
+       filter_common fec bitstream imdct wav_filter compress_filter \
+       amp_filter prebuffer_filter fecdec_filter wmadec_filter write_common \
+       file_write version sync_filter lsu \
+)
+ifeq ($(NEED_OGG_OBJECTS),yes)
+       play_objs += ogg_afh_common.o
+endif
+ifeq ($(NEED_VORBIS_OBJECTS),yes)
+       play_objs += oggdec_filter.o ogg_afh.o
+endif
+ifeq ($(NEED_SPEEX_OBJECTS),yes)
+       play_objs += spxdec_filter.o spx_afh.o spx_common.o
+endif
+ifeq ($(NEED_OPUS_OBJECTS),yes)
+       play_objs += opusdec_filter.o opus_afh.o opus_common.o
+endif
+ifeq ($(NEED_FLAC_OBJECTS),yes)
+       play_objs += flacdec_filter.o flac_afh.o
+endif
+ifeq ($(HAVE_FAAD),yes)
+       play_objs += aac_afh.o aacdec_filter.o mp4.o
+endif
+ifeq ($(HAVE_MAD),yes)
+       play_objs += mp3dec_filter.o
+endif
+ifeq ($(HAVE_OSS),yes)
+       play_objs += oss_write.o
+endif
+ifeq ($(HAVE_ALSA),yes)
+       play_objs += alsa_write.o
+endif
+ifeq ($(NEED_AO_OBJECTS),yes)
+       play_objs += ao_write.o
+endif
+ifeq ($(HAVE_READLINE),yes)
+       play_objs += interactive.o
+endif
+ifeq ($(HAVE_SAMPLERATE),yes)
+       play_objs += resample_filter.o check_wav.o
+endif
+
+write_objs := $(addsuffix .o, write write_common file_write time fd \
+       string sched stdin buffer_tree check_wav version)
+ifeq ($(NEED_AO_OBJECTS),yes)
+       write_objs += ao_write.o
+endif
+ifeq ($(HAVE_OSS),yes)
+       write_objs += oss_write.o
+endif
+ifeq ($(HAVE_ALSA),yes)
+       write_objs += alsa_write.o
+endif
+
+audioc_objs := $(addsuffix .o, audioc string lsu net fd time version)
+ifeq ($(HAVE_READLINE),yes)
+       audioc_objs += buffer_tree.o interactive.o sched.o
+endif
 
 # sort removes duplicate words, which is all we need here
-all_objs := $(sort $(recv_objs) $(filter_objs) $(client_objs) $(gui_objs) \
+dep_objs := $(sort $(recv_objs) $(filter_objs) $(client_objs) $(gui_objs) \
        $(audiod_objs) $(audioc_objs) $(mixer_objs) $(server_objs) \
-       $(write_objs) $(afh_objs) $(play_objs))
-deps := $(addprefix $(dep_dir)/, $(all_objs:.o=.d))
-deps += $(addprefix $(dep_dir)/, mp.bison.d mp.flex.d)
+       $(write_objs) $(afh_objs) $(play_objs) mp.bison mp.flex)
+deps := $(addprefix $(dep_dir)/, $(dep_objs:.o=.d))
 
 afh_objs += afh.lsg.o
 audioc_objs += audioc.lsg.o
@@ -55,6 +303,7 @@ gui_objs += gui.lsg.o
 play_objs += $(addsuffix _cmd.lsg.o, recv filter play write) play.lsg.o
 recv_objs += recv_cmd.lsg.o recv.lsg.o
 server_objs += server_cmd.lsg.o server.lsg.o
+upgrade_db_objs += upgrade_db.lsg.o
 write_objs += write_cmd.lsg.o write.lsg.o
 
 cmd_suites := $(addsuffix _cmd, audiod server play recv filter write)
@@ -77,10 +326,12 @@ audiod_objs := $(addprefix $(object_dir)/, $(audiod_objs))
 audioc_objs := $(addprefix $(object_dir)/, $(audioc_objs))
 mixer_objs := $(addprefix $(object_dir)/, $(mixer_objs))
 server_objs := $(addprefix $(object_dir)/, $(server_objs))
+upgrade_db_objs := $(addprefix $(object_dir)/, $(upgrade_db_objs))
 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
@@ -110,14 +361,16 @@ CPPFLAGS += -DBINDIR='"$(bindir)"'
 CPPFLAGS += -DCOPYRIGHT_YEAR='"$(COPYRIGHT_YEAR)"'
 CPPFLAGS += -DBUILD_DATE='"$(build_date)"'
 CPPFLAGS += -DLOGLEVELS='$(LOGLEVELS)'
+CPPFLAGS += -DSEVERITIES=$(SEVERITIES)
 CPPFLAGS += -DUNAME_RS='"$(uname_rs)"'
 CPPFLAGS += -DCC_VERSION='"$(cc_version)"'
-CPPFLAGS += -I/usr/local/include
 CPPFLAGS += -I$(lls_suite_dir)
 CPPFLAGS += -I$(yy_build_dir)
 CPPFLAGS += $(lopsub_cppflags)
+CPPFLAGS += -Wunused-macros
 
 STRICT_CFLAGS += -fno-strict-aliasing
+STRICT_CFLAGS += -ftrapv
 STRICT_CFLAGS += -g
 STRICT_CFLAGS += -Os
 STRICT_CFLAGS += -Wundef -W -Wuninitialized
@@ -129,15 +382,20 @@ STRICT_CFLAGS += -Wredundant-decls
 STRICT_CFLAGS += -Wno-sign-compare -Wno-unknown-pragmas
 STRICT_CFLAGS += -Wdeclaration-after-statement
 STRICT_CFLAGS += -Wformat -Wformat-security -Wmissing-format-attribute
+STRICT_CFLAGS += -fdata-sections -ffunction-sections
+STRICT_CFLAGS += -Wstrict-prototypes
+STRICT_CFLAGS += -Wshadow
+
+LDFLAGS += -Wl,--gc-sections
+
+ifeq ($(ENABLE_UBSAN), yes)
+       STRICT_CFLAGS += -fsanitize=undefined
+       LDFLAGS += -lubsan
+endif
 
 ifeq ($(uname_s),Linux)
        # these cause warnings on *BSD
-       CPPFLAGS += -Wunused-macros
-       STRICT_CFLAGS += -fdata-sections -ffunction-sections
-       STRICT_CFLAGS += -Wstrict-prototypes
-       STRICT_CFLAGS += -Wshadow
        STRICT_CFLAGS += -Wunused -Wall
-       LDFLAGS += -Wl,--gc-sections
 endif
 
 cc-option = $(shell \
@@ -147,6 +405,7 @@ cc-option = $(shell \
 
 STRICT_CFLAGS += $(call cc-option, -Wformat-signedness)
 STRICT_CFLAGS += $(call cc-option, -Wdiscarded-qualifiers)
+STRICT_CFLAGS += $(call cc-option, -Wsuggest-attribute=malloc)
 
 # To put more focus on warnings, be less verbose as default
 # Use 'make V=1' to see the full commands
@@ -186,79 +445,58 @@ $(man_dir)/para_%.1: $(lls_suite_dir)/%.lsg.man \
 
 $(object_dir)/%.o: %.c | $(object_dir)
 
-$(object_dir)/opus%.o: CPPFLAGS += $(opus_cppflags)
-$(object_dir)/gui.o $(object_dir)/gui%.o \
-: CPPFLAGS += $(curses_cppflags)
-$(object_dir)/spx%.o: CPPFLAGS += $(speex_cppflags)
-$(object_dir)/flac%.o: CPPFLAGS += $(flac_cppflags)
-
-$(object_dir)/mp3_afh.o: CPPFLAGS += $(id3tag_cppflags)
-$(object_dir)/crypt.o: CPPFLAGS += $(openssl_cppflags)
-$(object_dir)/gcrypt.o: CPPFLAGS += $(gcrypt_cppflags)
-$(object_dir)/ao_write.o: CPPFLAGS += $(ao_cppflags)
-$(object_dir)/alsa%.o: CPPFLAGS += $(alsa_cppflags)
-
-$(object_dir)/interactive.o \
-: CPPFLAGS += $(readline_cppflags)
-
-$(object_dir)/resample_filter.o \
-: CPPFLAGS += $(samplerate_cppflags)
-
-$(object_dir)/oss_write.o \
-: CPPFLAGS += $(oss_cppflags)
-
-$(object_dir)/ao_write.o \
-: CPPFLAGS += $(ao_cppflags) $(pthread_cppflags)
-
-$(object_dir)/mp3dec_filter.o \
-: CPPFLAGS += $(mad_cppflags)
-
-$(object_dir)/aacdec_filter.o \
-$(object_dir)/aac_afh.o \
-: CPPFLAGS += $(faad_cppflags)
-
-$(object_dir)/ogg_afh.o \
-$(object_dir)/oggdec_filter.o \
-: CPPFLAGS += $(vorbis_cppflags)
-
-$(object_dir)/spx_common.o \
-$(object_dir)/spxdec_filter.o \
-$(object_dir)/spx_afh.o \
-$(object_dir)/oggdec_filter.o \
-$(object_dir)/ogg_afh.o \
-$(object_dir)/ogg_afh_common.o \
-$(object_dir)/opus%.o \
-: CPPFLAGS += $(ogg_cppflags)
-
-$(object_dir)/afs.o \
-$(object_dir)/aft.o \
-$(object_dir)/attribute.o \
-$(object_dir)/blob.o  \
-$(object_dir)/mood.o \
-$(object_dir)/playlist.o \
-$(object_dir)/score.o \
-$(object_dir)/server.o \
-$(object_dir)/vss.o \
-$(object_dir)/command.o \
-$(object_dir)/http_send.o \
-$(object_dir)/dccp_send.o \
-$(object_dir)/udp_send.o \
-$(object_dir)/send_common.o \
-$(object_dir)/mm.o \
-: CPPFLAGS += $(osl_cppflags)
-
-$(object_dir)/compress_filter.o: CFLAGS += -O3
+OD = $(addsuffix .d, $(addprefix $(dep_dir)/, $(1))) \
+       $(addsuffix .o, $(addprefix $(object_dir)/, $(1)))
+
+$(call OD, audiod): \
+       CPPFLAGS += -DAUDIOD_AUDIO_FORMAT_ARRAY='$(audiod_audio_formats)'
+$(call OD, afh command): \
+       CPPFLAGS += -DAUDIO_FORMAT_HANDLERS='"$(audio_format_handlers)"'
+$(call OD, opus%): CPPFLAGS += $(opus_cppflags)
+$(call OD, gui gui%): CPPFLAGS += $(curses_cppflags)
+$(call OD, spx%): CPPFLAGS += $(speex_cppflags)
+$(call OD, flac%): CPPFLAGS += $(flac_cppflags)
+$(call OD, mp3_afh): CPPFLAGS += $(id3tag_cppflags)
+$(call OD, openssl): CPPFLAGS += $(openssl_cppflags)
+$(call OD, gcrypt): CPPFLAGS += $(gcrypt_cppflags)
+$(call OD, ao_write): CPPFLAGS += $(ao_cppflags)
+$(call OD, alsa%): CPPFLAGS += $(alsa_cppflags)
+$(call OD, interactive): CPPFLAGS += $(readline_cppflags)
+$(call OD, resample_filter): CPPFLAGS += $(samplerate_cppflags)
+$(call OD, oss_write): CPPFLAGS += $(oss_cppflags)
+$(call OD, ao_write): CPPFLAGS += $(ao_cppflags) $(pthread_cppflags)
+$(call OD, mp3dec_filter): CPPFLAGS += $(mad_cppflags)
+$(call OD, aacdec_filter aac_afh): CPPFLAGS += $(faad_cppflags)
+$(call OD, ogg_afh oggdec_filter): CPPFLAGS += $(vorbis_cppflags)
+$(call OD, spx_common spxdec_filter spx_afh oggdec_filter ogg_afh \
+       ogg_afh_common opus%): CPPFLAGS += $(ogg_cppflags)
+$(call OD, afs aft attribute blob mood playlist score server vss command \
+       http_send dccp_send udp_send send_common mm.o): \
+       CPPFLAGS += $(osl_cppflags)
+
+$(call OD, compress_filter): CFLAGS += -O3
+$(call OD, openssl): CFLAGS += -Wno-deprecated-declarations
 
 $(object_dir)/%.o: %.c | $(object_dir) $(dep_dir) $(lsg_h) $(yy_h)
+define CC_CMD
        $(call SAY, CC $<)
-       $(CC) -c -o $@ -MMD -MF $(dep_dir)/$(*F).d -MT $@ $(CPPFLAGS) \
-               $(STRICT_CFLAGS) $(CFLAGS) $<
+       $(CC) -c -o $(object_dir)/$(*F).o -MMD -MF \
+               $(dep_dir)/$(*F).d -MT $(object_dir)/$(*F).o \
+               $(CPPFLAGS) $(STRICT_CFLAGS) $(CFLAGS) $<
+endef
+CC_PREREQUISITES := %.c | $(object_dir) $(dep_dir) $(lsg_h) $(yy_h)
+# These two have the same prerequisites and the same recipe. There should be a
+# better way to write this.
+$(object_dir)/%.o: $(CC_PREREQUISITES)
+       $(CC_CMD)
+$(dep_dir)/%.d: $(CC_PREREQUISITES)
+       $(CC_CMD)
 
 para_recv para_afh para_play para_server: LDFLAGS += $(id3tag_ldflags)
 para_write para_play para_audiod \
 : LDFLAGS += $(ao_ldflags) $(pthread_ldflags)
 para_client para_audioc para_play : LDFLAGS += $(readline_ldflags)
-para_server: LDFLAGS += $(osl_ldflags)
+para_server para_upgrade_db: LDFLAGS += $(osl_ldflags)
 para_gui: LDFLAGS += $(curses_ldflags)
 para_server \
 para_client \
@@ -295,6 +533,7 @@ para_gui \
 para_play \
 para_recv \
 para_server \
+para_upgrade_db \
 para_write \
 : LDFLAGS += $(lopsub_ldflags)
 
@@ -330,7 +569,7 @@ distclean: clean
        $(call SAY, DISTCLEAN)
        rm -f Makefile autoscan.log config.status config.log
        rm -f config.h configure config.h.in
-maintainer-clean: distclean
+maintainer-clean: distclean test-clean
        $(call SAY, MAINTAINER-CLEAN)
        rm -f *.tar.bz2 *.tar.xz
        rm -f GPATH GRTAGS GSYMS GTAGS