Created
February 12, 2018 00:46
-
-
Save bacongobbler/92d2cab46e236623967dc9a61d7cb0a8 to your computer and use it in GitHub Desktop.
This file contains 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
CC=gcc | |
CFLAGS=-lm | |
ODIR=obj | |
BINDIR=bin | |
HOST_OS := $(shell uname -s 2>/dev/null | tr "[:upper:]" "[:lower:]") | |
TARGET_OS ?= $(HOST_OS) | |
HOST_ARCH := $(shell uname -m) | |
TARGET_ARCH ?= $(HOST_ARCH) | |
ifeq ($(TARGET_ARCH),x86_64) | |
TARGET_ARCH = amd64 | |
endif | |
all: $(BINDIR)/helloworld-$(TARGET_OS)-$(TARGET_ARCH) | |
$(ODIR)/%.o: %.c | |
mkdir -p $(ODIR) | |
$(CC) -c -o $@ $^ $(CFLAGS) | |
$(BINDIR)/%-$(TARGET_OS)-$(TARGET_ARCH): $(ODIR)/%.o | |
mkdir -p $(BINDIR) | |
$(CC) -o $@ $^ $(CFLAGS) | |
clean: | |
rm -rf $(ODIR) $(BINDIR) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment