From 34482d67c07da4e9bdb658a59eadf3a5dd897de4 Mon Sep 17 00:00:00 2001 From: Alexander Egorenkov Date: Sat, 26 Jun 2021 10:54:58 +0200 Subject: [PATCH] libutil: Refactor and clean up Makefile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use idiomatic make constructs. Signed-off-by: Alexander Egorenkov Reviewed-by: Marc Hartmayer Reviewed-by: Jan Hoeppner Signed-off-by: Jan Höppner --- libutil/Makefile | 47 +++++++---------------------------------------- 1 file changed, 7 insertions(+), 40 deletions(-) diff --git a/libutil/Makefile b/libutil/Makefile index 15079d65..508df5ba 100644 --- a/libutil/Makefile +++ b/libutil/Makefile @@ -1,49 +1,16 @@ include ../common.mak -lib = libutil.a +lib := libutil.a -examples = util_base_example \ - util_panic_example \ - util_path_example \ - util_scandir_example \ - util_file_example \ - util_libc_example \ - util_log_example \ - util_opt_example \ - util_opt_command_example \ - util_prg_example \ - util_rec_example +sources := $(filter-out %_example.c,$(wildcard *.c)) +objects := $(patsubst %.c,%.o,$(sources)) + +examples := $(patsubst %.c,%,$(wildcard *_example.c)) all: $(lib) -examples: $(lib) $(examples) +examples: $(examples) -objects = util_base.o \ - util_path.o \ - util_scandir.o \ - util_file.o \ - util_libc.o \ - util_list.o \ - util_log.o \ - util_opt.o \ - util_panic.o \ - util_part.o \ - util_prg.o \ - util_proc.o \ - util_rec.o \ - util_sys.o - -util_base_example: util_base_example.o $(lib) -util_panic_example: util_panic_example.o $(lib) -util_path_example: util_path_example.o $(lib) -util_scandir_example: util_scandir_example.o $(lib) -util_file_example: util_file_example.o $(lib) -util_libc_example: util_libc_example.o $(lib) -util_log_example: util_log_example.o $(lib) -util_opt_example: util_opt_example.o $(lib) -util_opt_command_example: util_opt_command_example.o $(lib) -util_panic_example: util_panic_example.o $(lib) -util_prg_example: util_prg_example.o $(lib) -util_rec_example: util_rec_example.o $(lib) +$(examples): %: %.o $(lib) $(lib): $(objects) $(lib): ALL_CFLAGS += -fPIC