Create my own advanced Makefile#342
Conversation
Signed-off-by: ericsandu <eric_andrei.sandu@stud.acs.upb.ro>
There was a problem hiding this comment.
Pull request overview
Adds a custom GNU Make Makefile intended to build two small C executables (greeting and twoparter) and provide a clean target, as part of the repository’s gnumake/ examples.
Changes:
- Introduces
gnumake/custom/Makefilewithall,greeting,twoparter, andcleantargets. - Adds variables for compiler selection and flags, and attempts to use
wildcardto detect built executables.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ifdef GREETING_EXISTS | ||
| rm greeting | ||
| endif | ||
| ifdef TWOPARTER_EXISTS | ||
| rm twoparter |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Fixed by assigning NULL value instead of 0 in variables
| greeting: greeting.c | ||
|
|
There was a problem hiding this comment.
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).
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: ericsandu <eric_andrei.sandu@stud.acs.upb.ro>
Add Makefile for compiling
greetings.candtwoparterbuilt frompart1.c, part2.candheader.hThe makefile uses the wildcard function, variables for file states and compiler flags and multiple declaration formats for build rules
All operations and their behaviours are explained in comments inside the file