From 098efbc6e35d1672cae7150f5f081149226b8341 Mon Sep 17 00:00:00 2001 From: Justin Schneck Date: Wed, 30 Nov 2016 20:49:48 -0500 Subject: [PATCH] support cross compiling --- .gitignore | 1 + Makefile | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index e11e9ad..ad715ba 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ /priv erl_crash.dump *.ez +/src/*.o diff --git a/Makefile b/Makefile index b407c4c..3108d92 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,8 @@ +SRC=$(wildcard src/*.c) + +CFLAGS += -std=c99 -D_GNU_SOURCE +CC ?= $(CROSSCOMPILER)gcc + UNAME := $(shell uname) ifeq ($(UNAME),MSYS_NT-6.1) @@ -8,11 +13,18 @@ else SOURCES = src/baud-posix.c src/baud.c src/util.c src/loop.c endif +OBJ=$(SOURCES:.c=.o) + +.PHONY: all clean + all: $(TARGET) -$(TARGET): src/* +%.o: %.c + $(CC) -c $(CFLAGS) -o $@ $< + +$(TARGET): $(OBJ) mkdir -p priv/native - gcc -o $(TARGET) $(SOURCES) + $(CC) $^ -o $@ clean: - rm -f priv/native/* + rm -f priv/native/* src/*.o