From d67ededccb83da3d47e5959a34063a737e0b96f2 Mon Sep 17 00:00:00 2001 From: Matei Vasiliu Date: Sat, 28 Mar 2026 22:12:38 +0200 Subject: [PATCH] Created Makefile + extra.mk and updated .c files against warnings Signed-off-by: Matei Vasiliu --- gnumake/custom/Makefile | 40 ++++++++++++++++++++++++++++++++++++++++ gnumake/custom/extra.mk | 9 +++++++++ 2 files changed, 49 insertions(+) create mode 100644 gnumake/custom/Makefile create mode 100644 gnumake/custom/extra.mk diff --git a/gnumake/custom/Makefile b/gnumake/custom/Makefile new file mode 100644 index 0000000..10e0af5 --- /dev/null +++ b/gnumake/custom/Makefile @@ -0,0 +1,40 @@ +# Compiler and flags +CC := gcc +CFLAGS := -Wall -Wextra -g + +# Conditional block (debug vs release) +ifeq ($(DEBUG),1) +CFLAGS += -DDEBUG +else +CFLAGS += -O2 +endif + +# Targets +TARGETS := greeting parts + +# Function to get executable name +make_exec = $(basename $(notdir $(1))) + +# Default rule +all: $(TARGETS) + +# Include extra rules +include extra.mk + +# Build greeting executable from greeting.c +greeting: greeting.c + @echo "Compiling greeting.c..." + $(CC) $(CFLAGS) -o $(call make_exec,$<) $< + +# Build parts executable using part1.c, part2.c and header.h +parts: part1.c part2.c header.h + @echo "Compiling parts (part1 + part2)..." + $(CC) $(CFLAGS) -o parts part1.c part2.c + +# Clean rule +clean: + @echo "Cleaning executables..." + rm -f greeting parts + +# Phony rules +.PHONY: all clean help \ No newline at end of file diff --git a/gnumake/custom/extra.mk b/gnumake/custom/extra.mk new file mode 100644 index 0000000..8a1a2da --- /dev/null +++ b/gnumake/custom/extra.mk @@ -0,0 +1,9 @@ +# Extra Makefile with additional rule + +help: + @echo "Available commands:" + @echo " make - build all targets" + @echo " make greeting - build greeting program" + @echo " make parts - build parts program" + @echo " make clean - remove executables" + @echo " make DEBUG=1 - build with debug flags" \ No newline at end of file