Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions gnumake/custom/Makefile
Original file line number Diff line number Diff line change
@@ -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):
Comment thread
ericsandu marked this conversation as resolved.
Outdated

# Builds two executables, greeting and twoparter
all: greeting twoparter

# Builds greeting with default compilation settings
greeting: greeting.c
Comment thread
ericsandu marked this conversation as resolved.
Outdated

Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR description mentions compiling greetings.c, but the Makefile (and the directory contents) refer to greeting.c. Please align the PR description with the actual filename (or rename the target/source if the intention was greetings.c).

Copilot uses AI. Check for mistakes.
# Builds executable from multiple .c files and a .h header
twoparter: part1.c part2.c header.h
$(CC) -o $@ $^
Comment thread
ericsandu marked this conversation as resolved.
Outdated

# Removes executables if they exist
clean:
ifdef GREETING_EXISTS
rm greeting
endif
ifdef TWOPARTER_EXISTS
rm twoparter
Comment on lines +23 to +27
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ifdef GREETING_EXISTS / ifdef TWOPARTER_EXISTS will always evaluate true here because both variables are assigned unconditionally (and are non-empty). This makes clean try to remove files even when they don’t exist, and rm will fail the target. Prefer rm -f greeting twoparter, or use ifneq ($(wildcard greeting),) style checks instead of ifdef.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed by assigning NULL value instead of 0 in variables

endif
Loading