From fd29153131699fc669f427150a6a289a1ae4cc66 Mon Sep 17 00:00:00 2001 From: ericsandu Date: Sun, 22 Mar 2026 15:07:28 +0200 Subject: [PATCH 1/5] Create my own advanced Makefile Signed-off-by: ericsandu --- gnumake/custom/Makefile | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 gnumake/custom/Makefile diff --git a/gnumake/custom/Makefile b/gnumake/custom/Makefile new file mode 100644 index 0000000..edcc828 --- /dev/null +++ b/gnumake/custom/Makefile @@ -0,0 +1,28 @@ +.PHONY: clean + +# Compiler flags +CC=gcc +CFLAGS=-Wall -Wextra -std=c99 + +# Checks if executables exist +GREETING_EXISTS := $(or $(and $(wildcard $(./greeting)),1),0): +TWOPARTER_EXISTS := $(or $(and $(wildcard $(./twoparter)),1),0): + +# Builds two executables, greeting and twoparter +all: greeting twoparter + +# Builds greeting with default compilation settings +greeting: greeting.c + +# Builds executable from multiple .c files and a .h header +twoparter: part1.c part2.c header.h + $(CC) -o $@ $^ + +# Removes executables if they exist +clean: +ifdef GREETING_EXISTS + rm greeting +endif +ifdef TWOPARTER_EXISTS + rm twoparter +endif From 80cbadda43e3949d8cefc2921d260e918c51a5c7 Mon Sep 17 00:00:00 2001 From: Eric Andrei Sandu Date: Sun, 22 Mar 2026 15:14:07 +0200 Subject: [PATCH 2/5] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- gnumake/custom/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gnumake/custom/Makefile b/gnumake/custom/Makefile index edcc828..0592aec 100644 --- a/gnumake/custom/Makefile +++ b/gnumake/custom/Makefile @@ -5,8 +5,8 @@ CC=gcc CFLAGS=-Wall -Wextra -std=c99 # Checks if executables exist -GREETING_EXISTS := $(or $(and $(wildcard $(./greeting)),1),0): -TWOPARTER_EXISTS := $(or $(and $(wildcard $(./twoparter)),1),0): +GREETING_EXISTS := $(or $(and $(wildcard greeting),1),0) +TWOPARTER_EXISTS := $(or $(and $(wildcard twoparter),1),0) # Builds two executables, greeting and twoparter all: greeting twoparter From 30f1e2de704dbbb4552dee8aee9130d32f00633a Mon Sep 17 00:00:00 2001 From: Eric Andrei Sandu Date: Sun, 22 Mar 2026 15:14:13 +0200 Subject: [PATCH 3/5] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- gnumake/custom/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnumake/custom/Makefile b/gnumake/custom/Makefile index 0592aec..bb9903a 100644 --- a/gnumake/custom/Makefile +++ b/gnumake/custom/Makefile @@ -12,7 +12,7 @@ TWOPARTER_EXISTS := $(or $(and $(wildcard twoparter),1),0) all: greeting twoparter # Builds greeting with default compilation settings -greeting: greeting.c +greeting: greeting.c # Builds executable from multiple .c files and a .h header twoparter: part1.c part2.c header.h From 438ec2b6a88ad3ff0071f9f3863e71f4bde80cb5 Mon Sep 17 00:00:00 2001 From: Eric Andrei Sandu Date: Sun, 22 Mar 2026 15:14:26 +0200 Subject: [PATCH 4/5] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- gnumake/custom/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnumake/custom/Makefile b/gnumake/custom/Makefile index bb9903a..2f6ad08 100644 --- a/gnumake/custom/Makefile +++ b/gnumake/custom/Makefile @@ -16,7 +16,7 @@ greeting: greeting.c # Builds executable from multiple .c files and a .h header twoparter: part1.c part2.c header.h - $(CC) -o $@ $^ + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ # Removes executables if they exist clean: From 3ae481c3d4740f301968dad7152d75edc72849e8 Mon Sep 17 00:00:00 2001 From: ericsandu Date: Sun, 22 Mar 2026 15:16:29 +0200 Subject: [PATCH 5/5] Fix file existence checks Signed-off-by: ericsandu --- gnumake/custom/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gnumake/custom/Makefile b/gnumake/custom/Makefile index 2f6ad08..9f30810 100644 --- a/gnumake/custom/Makefile +++ b/gnumake/custom/Makefile @@ -5,8 +5,8 @@ CC=gcc CFLAGS=-Wall -Wextra -std=c99 # Checks if executables exist -GREETING_EXISTS := $(or $(and $(wildcard greeting),1),0) -TWOPARTER_EXISTS := $(or $(and $(wildcard twoparter),1),0) +GREETING_EXISTS := $(or $(and $(wildcard greeting),1),) +TWOPARTER_EXISTS := $(or $(and $(wildcard twoparter),1),) # Builds two executables, greeting and twoparter all: greeting twoparter