-
Notifications
You must be signed in to change notification settings - Fork 191
Create my own advanced Makefile #342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ericsandu
wants to merge
5
commits into
rosedu:cdl-08
Choose a base branch
from
ericsandu:gnumake-custom
base: cdl-08
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fd29153
Create my own advanced Makefile
ericsandu 80cbadd
Apply suggestion from @Copilot
ericsandu 30f1e2d
Apply suggestion from @Copilot
ericsandu 438ec2b
Apply suggestion from @Copilot
ericsandu 3ae481c
Fix file existence checks
ericsandu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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),) | ||
| TWOPARTER_EXISTS := $(or $(and $(wildcard twoparter),1),) | ||
|
|
||
| # 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) $(CFLAGS) $(LDFLAGS) -o $@ $^ | ||
|
|
||
| # Removes executables if they exist | ||
| clean: | ||
| ifdef GREETING_EXISTS | ||
| rm greeting | ||
| endif | ||
| ifdef TWOPARTER_EXISTS | ||
| rm twoparter | ||
| endif | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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_EXISTSwill always evaluate true here because both variables are assigned unconditionally (and are non-empty). This makescleantry to remove files even when they don’t exist, andrmwill fail the target. Preferrm -f greeting twoparter, or useifneq ($(wildcard greeting),)style checks instead ofifdef.There was a problem hiding this comment.
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