Skip to content
This repository has been archived by the owner on Jan 26, 2024. It is now read-only.

use make variables #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

use make variables #7

wants to merge 1 commit into from

Conversation

mrfright
Copy link

Replace gcc with variables to allow cross compiling.

Replace `gcc` with variables to allow cross compiling.
@@ -1,5 +1,5 @@
udp-broadcast-relay-redux: main.c
gcc -g main.c -o udp-broadcast-relay-redux
$(CC) $(CFLAGS) -g main.c -o udp-broadcast-relay-redux
Copy link
Collaborator

Choose a reason for hiding this comment

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

For this change to not break if these vars are not defined, the Makefile needs the original defaults. Something along the lines of:

ifndef CC
override CC = gcc
endif

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the review.

My understanding, and testing confirmed, that if CC was not defined, make used the default value cc, which on Linux for me at least links to gcc.

My testing without environment variables set gives basically the original command, but setting the environment variables to what I need allows me to cross compile.

Does this not work for you or others if the vars are not defined?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It might not always be set. Then the Makefile will fail in interesting ways. Always nice to have a default. This is defensive programming in action.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants