From f06a54cb18adc62fe575f55a8e143613f17d3775 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 5 Jan 2021 20:59:50 +0100 Subject: [PATCH] With make, build query_config.c only once Build query_config.o then link it, instead of building query_config.c in each of the four programs that use it. Signed-off-by: Gilles Peskine --- programs/.gitignore | 3 +++ programs/Makefile | 22 ++++++++++++++-------- programs/fuzz/.gitignore | 1 - 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/programs/.gitignore b/programs/.gitignore index 88fb9d52b..6c8c51571 100644 --- a/programs/.gitignore +++ b/programs/.gitignore @@ -2,6 +2,9 @@ *.sln *.vcxproj +*.o +*.exe + aes/aescrypt2 aes/crypt_and_hash hash/generic_sum diff --git a/programs/Makefile b/programs/Makefile index 9cbc47167..f53724ea9 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -267,21 +267,23 @@ ssl/ssl_client1$(EXEXT): ssl/ssl_client1.c $(DEP) echo " CC ssl/ssl_client1.c" $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_client1.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ -ssl/ssl_client2$(EXEXT): ssl/ssl_client2.c test/query_config.c $(DEP) +SSL_TEST_OBJECTS = test/query_config.o + +ssl/ssl_client2$(EXEXT): ssl/ssl_client2.c $(SSL_TEST_OBJECTS) $(DEP) echo " CC ssl/ssl_client2.c" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_client2.c test/query_config.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_client2.c $(SSL_TEST_OBJECTS) $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ ssl/ssl_server$(EXEXT): ssl/ssl_server.c $(DEP) echo " CC ssl/ssl_server.c" $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_server.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ -ssl/ssl_server2$(EXEXT): ssl/ssl_server2.c test/query_config.c $(DEP) +ssl/ssl_server2$(EXEXT): ssl/ssl_server2.c $(SSL_TEST_OBJECTS) $(DEP) echo " CC ssl/ssl_server2.c" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_server2.c test/query_config.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_server2.c $(SSL_TEST_OBJECTS) $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ -ssl/ssl_context_info$(EXEXT): ssl/ssl_context_info.c test/query_config.c $(DEP) +ssl/ssl_context_info$(EXEXT): ssl/ssl_context_info.c test/query_config.o $(DEP) echo " CC ssl/ssl_context_info.c" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_context_info.c test/query_config.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_context_info.c test/query_config.o $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ ssl/ssl_fork_server$(EXEXT): ssl/ssl_fork_server.c $(DEP) echo " CC ssl/ssl_fork_server.c" @@ -307,6 +309,10 @@ test/cpp_dummy_build$(EXEXT): test/cpp_dummy_build.cpp $(DEP) echo " CXX test/cpp_dummy_build.cpp" $(CXX) $(LOCAL_CXXFLAGS) $(CXXFLAGS) test/cpp_dummy_build.cpp $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ +test/query_config.o: test/query_config.c $(DEP) + echo " CC test/query_config.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) -c test/query_config.c -o $@ + test/selftest$(EXEXT): test/selftest.c $(DEP) echo " CC test/selftest.c" $(CC) $(LOCAL_CFLAGS) $(CFLAGS) test/selftest.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ @@ -319,9 +325,9 @@ test/zeroize$(EXEXT): test/zeroize.c $(DEP) echo " CC test/zeroize.c" $(CC) $(LOCAL_CFLAGS) $(CFLAGS) test/zeroize.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ -test/query_compile_time_config$(EXEXT): test/query_compile_time_config.c test/query_config.c $(DEP) +test/query_compile_time_config$(EXEXT): test/query_compile_time_config.c test/query_config.o $(DEP) echo " CC test/query_compile_time_config.c" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) test/query_compile_time_config.c test/query_config.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) test/query_compile_time_config.c test/query_config.o $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ util/pem2der$(EXEXT): util/pem2der.c $(DEP) echo " CC util/pem2der.c" diff --git a/programs/fuzz/.gitignore b/programs/fuzz/.gitignore index 6fcc004b7..5dc096055 100644 --- a/programs/fuzz/.gitignore +++ b/programs/fuzz/.gitignore @@ -1,4 +1,3 @@ -*.o fuzz_client fuzz_dtlsclient fuzz_dtlsserver