Created
March 19, 2013 19:15
-
-
Save rolandoam/5199237 to your computer and use it in GitHub Desktop.
makefile for both native and emscripten projects: make js # will make the js port, output a projectname.js
make native # will compile the native port, output project.native make sure there are no important files named `project.*` because they will be cleaned by the `clean` target
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
EMSCRIPTEN_HOME = ~/Documents/inbox/emscripten | |
PROJECT = myproject | |
SOURCES = $(wildcard *.cc) $(wildcard *.c) | |
OBJECTS = $(patsubst %.cc,%.o,$(patsubst %.c,%.o,$(SOURCES))) | |
set-native: | |
$(eval CXX := clang -x c++) | |
$(eval CC := clang) | |
$(eval CPPFLAGS := -g -O2 -DHAS_TR1) | |
$(eval CXXFLAGS := -std=c++11) | |
$(eval LDFLAGS := -lstdc++) | |
$(eval TARGET := native) | |
set-js: | |
$(eval CXX := $(EMSCRIPTEN_HOME)/em++) | |
$(eval CC := $(EMSCRIPTEN_HOME)/emcc) | |
$(eval CXXFLAGS := -std=c++11 -s ASM_JS=1) | |
$(eval LDFLAGS := -lc++ -O2) | |
$(eval TARGET := js) | |
compile: $(OBJECTS) | |
$(CC) $(LDFLAGS) $^ -o $(PROJECT).$(TARGET) | |
native: set-native compile | |
js: set-js compile | |
show-vars: | |
echo $(SOURCES) | |
echo $(OBJECTS) | |
clean: | |
rm -f *.o | |
rm -rf $(PROJECT).* *.dSYM |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks a lot!