From 4cfaf1a3cfbcaafbff871a4600c3f064dcf4c623 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Thu, 17 Jul 2025 09:21:15 -0400 Subject: [PATCH] MT#63151 remove duplication of files during make Change-Id: I67f45a52660b089748c4f6f76c564bbc97fa1899 --- daemon/.gitignore | 24 -------------- daemon/Makefile | 1 - lib/.gitignore | 3 ++ lib/common.Makefile | 64 ++++++++++++++++++++++--------------- lib/lib.Makefile | 1 + perf-tester/.gitignore | 14 -------- perf-tester/Makefile | 4 +-- recording-daemon/.gitignore | 20 ------------ recording-daemon/Makefile | 1 - t/.gitignore | 62 ----------------------------------- t/Makefile | 19 +++++------ utils/build_test_wrapper | 7 ++-- 12 files changed, 54 insertions(+), 166 deletions(-) diff --git a/daemon/.gitignore b/daemon/.gitignore index 369301526..d3f3ba3cb 100644 --- a/daemon/.gitignore +++ b/daemon/.gitignore @@ -5,27 +5,3 @@ rtpengine core core.* .ycm_extra_conf.pyc -auxlib.c -loglib.c -rtplib.c -codeclib.c -resample.c -str.c -fix_frame_channel_layout.h -socket.c -streambuf.c -ssllib.c -dtmflib.c -*-test -dtmf_rx_fillin.h -*-test.c -spandsp_logging.h -mvr2s_x64_avx512.S -mvr2s_x64_avx2.S -mix_buffer.c -mix_in_x64_avx2.S -mix_in_x64_avx512bw.S -mix_in_x64_sse2.S -poller.c -bufferpool.c -uring.c diff --git a/daemon/Makefile b/daemon/Makefile index f41c79652..9fd29a24e 100644 --- a/daemon/Makefile +++ b/daemon/Makefile @@ -112,7 +112,6 @@ endif ifneq ($(have_liburing),yes) LIBSRCS+= uring.c endif -OBJS= $(SRCS:.c=.o) $(LIBSRCS:.c=.o) $(LIBASM:.S=.o) MDS= rtpengine.ronn MANS= $(MDS:.ronn=.8) diff --git a/lib/.gitignore b/lib/.gitignore index 5761abcfd..ec3888ff8 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -1 +1,4 @@ *.o +dtmf_rx_fillin.h +fix_frame_channel_layout.h +spandsp_logging.h diff --git a/lib/common.Makefile b/lib/common.Makefile index fa961de4c..5c63b9b3b 100644 --- a/lib/common.Makefile +++ b/lib/common.Makefile @@ -8,36 +8,48 @@ LDLIBS += -latomic all: $(TARGET) $(MANS) -$(TARGET): $(OBJS) Makefile - $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJS) $(LDLIBS) + +OBJS = $(SRCS:.c=.o) + +LIBOBJS = $(LIBSRCS:.c=.o) + +DAEMONOBJS = $(DAEMONSRCS:.c=.o) + +LIBASMOBJS = $(LIBASM:.S=.o) + +ALLOBJS = $(OBJS) $(LIBOBJS) $(LIBASMOBJS) $(DAEMONOBJS) + + +$(OBJS): %.o: %.c + $(CC) -c $(CFLAGS) $< -o $@ + +$(LIBOBJS): %.o: ../lib/%.c + $(CC) -c $(CFLAGS) $< -o $@ + +$(DAEMONOBJS): %.o: ../daemon/%.c + $(CC) -c $(CFLAGS) $< -o $@ + +$(LIBASMOBJS): %.o: ../lib/%.S + $(AS) -c $(ASFLAGS) $< -o $@ + + +$(TARGET): $(ALLOBJS) Makefile + $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(ALLOBJS) $(LDLIBS) + debug: $(MAKE) DBG=yes all -BUILD_TEST_ALTS = fix_frame_channel_layout.h dtmf_rx_fillin.h spandsp_logging.h + +BUILD_TEST_ALTS = ../lib/fix_frame_channel_layout.h ../lib/dtmf_rx_fillin.h ../lib/spandsp_logging.h clean: - rm -f $(OBJS) $(TARGET) $(LIBSRCS) $(LIBASM) $(DAEMONSRCS) $(MANS) $(ADD_CLEAN) core core.* - rm -f $(BUILD_TEST_ALTS) $(BUILD_TEST_ALTS:.h=-test.c) $(BUILD_TEST_ALTS:.h=-test) *.strhash.c $(HASHSRCS) + rm -f $(ALLOBJS) $(TARGET) $(LIBSRCS) $(LIBASM) $(DAEMONSRCS) $(MANS) $(ADD_CLEAN) core core.* + rm -f $(BUILD_TEST_ALTS) $(BUILD_TEST_ALTS:.h=-test) *.strhash.c install: -$(OBJS): Makefile ../include/* ../lib/*.h ../kernel-module/*.h - -$(LIBSRCS): $(patsubst %,../lib/%,$(LIBSRCS)) - ( echo '/******** GENERATED FILE ********/' && \ - echo '#line 1' && \ - cat ../lib/"$@" ) > "$@" - -$(LIBASM): $(patsubst %,../lib/%,$(LIBASM)) - ( echo '/******** GENERATED FILE ********/' && \ - echo '#line 1' && \ - cat ../lib/"$@" ) > "$@" - -$(DAEMONSRCS) $(HASHSRCS): $(patsubst %,../daemon/%,$(DAEMONSRCS)) $(patsubst %,../daemon/%,$(HASHSRCS)) - ( echo '/******** GENERATED FILE ********/' && \ - echo '#line 1' && \ - cat ../daemon/"$@" ) > "$@" +$(ALLOBJS): Makefile ../include/* ../lib/*.h ../kernel-module/*.h %.8: ../docs/%.md cat "$<" | sed '/^# /d; s/^##/#/' | \ @@ -46,19 +58,19 @@ $(DAEMONSRCS) $(HASHSRCS): $(patsubst %,../daemon/%,$(DAEMONSRCS)) $(patsubst %, -M "date:$(BUILD_DATE)" \ -o "$@" -resample.c codeclib.strhash.c mix.c packet.c: fix_frame_channel_layout.h +resample.c ../lib/codeclib.strhash.c mix.c packet.c: ../lib/fix_frame_channel_layout.h ifeq ($(with_transcoding),yes) -codec.c: dtmf_rx_fillin.h -media_player.c codec.c test-resample.c: fix_frame_channel_layout.h +../daemon/codec.c codec.c: ../lib/dtmf_rx_fillin.h +media_player.c ../daemon/media_player.c ../daemon/codec.c codec.c test-resample.c: ../lib/fix_frame_channel_layout.h endif -t38.c: spandsp_logging.h +t38.c ../daemon/t38.c: ../lib/spandsp_logging.h %.strhash.c: %.c ../utils/const_str_hash ../utils/const_str_hash "$<" $(CFLAGS) < "$<" > "$@" -$(BUILD_TEST_ALTS): $(wildcard ../lib/$(subst .h,-*,$(BUILD_TEST_ALTS))) +$(BUILD_TEST_ALTS): $(wildcard $(subst .h,-*,$(BUILD_TEST_ALTS))) ../utils/build_test_wrapper "$@" 2> /dev/null .PHONY: all debug clean install diff --git a/lib/lib.Makefile b/lib/lib.Makefile index a857ecf62..9b603babc 100644 --- a/lib/lib.Makefile +++ b/lib/lib.Makefile @@ -1,4 +1,5 @@ CC ?= gcc +AS ?= gcc ifeq ($(DO_ASAN_FLAGS),1) ASAN_FLAGS = -ggdb -O0 -fsanitize=address -fsanitize=leak -fsanitize=undefined diff --git a/perf-tester/.gitignore b/perf-tester/.gitignore index 67ded8f73..915359455 100644 --- a/perf-tester/.gitignore +++ b/perf-tester/.gitignore @@ -4,17 +4,3 @@ rtpengine-perftest core core.* .ycm_extra_conf.pyc -auxlib.c -loglib.c -rtplib.c -codeclib.c -resample.c -str.c -fix_frame_channel_layout.h -mvr2s_x64_avx512.S -mvr2s_x64_avx2.S -dtmflib.c -poller.c -ssllib.c -bufferpool.c -uring.c diff --git a/perf-tester/Makefile b/perf-tester/Makefile index b75debc0b..a84dc4c67 100644 --- a/perf-tester/Makefile +++ b/perf-tester/Makefile @@ -58,11 +58,9 @@ LIBSRCS = codeclib.strhash.c loglib.c auxlib.c resample.c str.c dtmflib.c rtplib bencode.c uring.c LIBASM = mvr2s_x64_avx2.S mvr2s_x64_avx512.S -OBJS = $(SRCS:.c=.o) $(LIBSRCS:.c=.o) $(LIBASM:.S=.o) - include ../lib/common.Makefile -main.o: fix_frame_channel_layout.h +main.o: ../lib/fix_frame_channel_layout.h install: $(TARGET) install -m 0755 -D $(TARGET) $(DESTDIR)/usr/bin/$(TARGET) diff --git a/recording-daemon/.gitignore b/recording-daemon/.gitignore index 2cf407246..454105da0 100644 --- a/recording-daemon/.gitignore +++ b/recording-daemon/.gitignore @@ -4,24 +4,4 @@ core core.* .ycm_extra_conf.pyc rtpengine-recording -auxlib.c -loglib.c -rtplib.c -codeclib.c -resample.c -str.c -fix_frame_channel_layout.h -socket.c -streambuf.c -ssllib.c -dtmflib.c -*-test -*-test.c *.8 -mvr2s_x64_avx512.S -mvr2s_x64_avx2.S -mix_in_x64_avx2.S -mix_in_x64_avx512bw.S -mix_in_x64_sse2.S -bufferpool.c -uring.c diff --git a/recording-daemon/Makefile b/recording-daemon/Makefile index 7810dd2d9..b929fac38 100644 --- a/recording-daemon/Makefile +++ b/recording-daemon/Makefile @@ -52,7 +52,6 @@ SRCS= epoll.c garbage.c inotify.c main.c metafile.c stream.c recaux.c packet.c LIBSRCS= loglib.c auxlib.c rtplib.c codeclib.strhash.c resample.c str.c socket.c streambuf.c ssllib.c \ dtmflib.c bufferpool.c bencode.c LIBASM= mvr2s_x64_avx2.S mvr2s_x64_avx512.S mix_in_x64_avx2.S mix_in_x64_avx512bw.S mix_in_x64_sse2.S -OBJS= $(SRCS:.c=.o) $(LIBSRCS:.c=.o) $(LIBASM:.S=.o) MDS= rtpengine-recording.ronn MANS= $(MDS:.ronn=.8) diff --git a/t/.gitignore b/t/.gitignore index 828d533b6..9895d25c6 100644 --- a/t/.gitignore +++ b/t/.gitignore @@ -4,89 +4,27 @@ amr-encode-test amr-decode-test core .depend -auxlib.c -codeclib.c -fix_frame_channel_layout.h -loglib.c -resample.c -rtplib.c -str.c -crypto.c aes-crypt -bencode.c -call.c -call_interfaces.c -cdr.c -codec.c -control_ng.c -control_ng_flags_parser.c -cookie_cache.c -dtls.c -graphite.c -helpers.c -homer.c -ice.c -iptables.c -kernel.c -load.c -media_socket.c -poller.c -recording.c -redis.c -rtcp.c -rtp.c -sdp.c -socket.c -ssrc.c -statistics.c -streambuf.c -stun.c transcode-test -udp_listener.c payload-tracker-test -dtmf.c const_str_hash-test.strhash tests-preload.so -timerthread.c -media_player.c -dtmflib.c test-dtmf-detect test-bitstr test-const_str_hash.strhash test-payload-tracker test-transcode -dtmf_rx_fillin.h -*-test.c -jitter_buffer.c -t38.c spandsp_recv_fax_pcm spandsp_recv_fax_t38 spandsp_send_fax_pcm spandsp_send_fax_t38 -spandsp_logging.h aead-aes-crypt -tcp_listener.c test-kernel-module test-resample mqtt.c -cli.c -janus.c -websocket.c test-stats -ssllib.c time-fudge-preload.so -mvr2s_x64_avx2.S -mvr2s_x64_avx512.S test-mix-buffer -mix_buffer.c -audio_player.c -mix_in_x64_avx2.S -mix_in_x64_avx512bw.S -mix_in_x64_sse2.S test-amr-decode test-amr-encode -bufferpool.c -uring.c aead-decrypt -arena.c -ng_client.c diff --git a/t/Makefile b/t/Makefile index 43d049d7c..ce724019f 100644 --- a/t/Makefile +++ b/t/Makefile @@ -72,8 +72,7 @@ LDLIBS+= $(LDLIBS_CODEC_CHAIN) SRCS= test-bitstr.c aes-crypt.c aead-aes-crypt.c test-const_str_hash.strhash.c aead-decrypt.c LIBSRCS= loglib.c auxlib.c str.c rtplib.c ssllib.c mix_buffer.c bufferpool.c bencode.c -DAEMONSRCS= crypto.c ssrc.c helpers.c rtp.c -HASHSRCS= cli.c +DAEMONSRCS= crypto.c ssrc.c helpers.c rtp.c cli.strhash.c ifeq ($(with_transcoding),yes) SRCS+= test-transcode.c test-dtmf-detect.c test-payload-tracker.c test-resample.c test-stats.c @@ -87,16 +86,14 @@ DAEMONSRCS+= control_ng_flags_parser.c codec.c call.c ice.c kernel.c media_socke dtls.c recording.c statistics.c rtcp.c redis.c iptables.c graphite.c \ cookie_cache.c udp_listener.c homer.c load.c cdr.c dtmf.c timerthread.c \ media_player.c jitter_buffer.c t38.c tcp_listener.c mqtt.c websocket.c \ - audio_player.c arena.c ng_client.c -HASHSRCS+= call_interfaces.c control_ng.c sdp.c janus.c + audio_player.c arena.c ng_client.c call_interfaces.strhash.c sdp.strhash.c \ + janus.strhash.c control_ng.strhash.c cli.strhash.c LIBASM= mvr2s_x64_avx2.S mvr2s_x64_avx512.S mix_in_x64_avx2.S mix_in_x64_avx512bw.S mix_in_x64_sse2.S endif ifneq ($(have_liburing),yes) LIBSRCS+= uring.c endif -OBJS= $(SRCS:.c=.o) $(LIBSRCS:.c=.o) $(DAEMONSRCS:.c=.o) $(HASHSRCS:.c=.strhash.o) $(LIBASM:.S=.o) - COMMONOBJS= str.o auxlib.o rtplib.o loglib.o ssllib.o include ../lib/common.Makefile @@ -118,7 +115,7 @@ TESTS+= test-amr-decode test-amr-encode endif endif -ADD_CLEAN= tests-preload.so time-fudge-preload.so $(TESTS) +ADD_CLEAN= tests-preload.so time-fudge-preload.so $(TESTS) aead-decrypt ifeq ($(with_transcoding),yes) all-tests: unit-tests daemon-tests @@ -345,7 +342,7 @@ tests-preload.so: tests-preload.c time-fudge-preload.so: time-fudge-preload.c $(CC) $(PRELOAD_CFLAGS) -o $@ -shared -fPIC $< $(PRELOAD_LIBS) -spandsp_send_fax_pcm.c: spandsp_logging.h -spandsp_send_fax_t38.c: spandsp_logging.h -spandsp_recv_fax_t38.c: spandsp_logging.h -spandsp_recv_fax_pcm.c: spandsp_logging.h +spandsp_send_fax_pcm.c: ../lib/spandsp_logging.h +spandsp_send_fax_t38.c: ../lib/spandsp_logging.h +spandsp_recv_fax_t38.c: ../lib/spandsp_logging.h +spandsp_recv_fax_pcm.c: ../lib/spandsp_logging.h diff --git a/utils/build_test_wrapper b/utils/build_test_wrapper index 492264f95..47f500d52 100755 --- a/utils/build_test_wrapper +++ b/utils/build_test_wrapper @@ -6,9 +6,8 @@ if test "$MAKE" = ""; then MAKE=make fi echo "Looking for usable alternative for $TARGET" -rm -f "$ROOT"-test "$ROOT"-test.c -ln -s ../lib/"$ROOT"-test.c . -for x in ../lib/"$ROOT"*.h; do +rm -f "$ROOT"-test +for x in "$ROOT"*.h; do echo "Trying build with $x" rm -f "$TARGET" (echo '/******** GENERATED FILE ********/'; cat "$x") > "$TARGET" @@ -16,5 +15,5 @@ for x in ../lib/"$ROOT"*.h; do echo "Failed build with $x" rm -f "$TARGET" done -rm -f "$ROOT"-test "$ROOT"-test.c +rm -f "$ROOT"-test test -f "$TARGET"