git.iko.soy/rowtype-yoga/purescript-native
on ebbc4e4 help sign in
68 lines 1.9 kB history raw
1# PureScript to native binary (via C++) Makefile
2#
3# Run 'make' or 'make release' to build an optimized release build
4# Run 'make debug' to build a non-optimized build suitable for debugging
5#
6# You can also perform a parallel build with 'make -jN', where N is the
7# number of cores to use.
8#
9# PCC, PURESCRIPT_PKGS, OUTPUT, and BIN can all be overridden with the
10# command itself. For example: 'make PURESCRIPT_PKGS=../gitpackages BIN=myexe'
12# Flags can be added to either the codegen or native build phases.
13# For example: 'make PCCFLAGS=--no-tco CXXFLAGS=-DDEBUG LDFLAGS=lobjc'
15# You can also edit the generated version of this file directly.
17PCC := {bin/pcc} # example: /usr/local/bin/pcc
18PURESCRIPT_PKGS := packages # example: bower_components
19PURESCRIPT_SRC := src
20OUTPUT := output
21BIN := main
23override PCCFLAGS += --comments
24override CXXFLAGS += -std=c++11
25override LDFLAGS +=
27ifeq ($(USE_GC),yes)
28 override CXXFLAGS += -DUSE_GC
29 override LDFLAGS += -lgc
30endif
32DEBUG := "-DDEBUG -g"
33RELEASE := "-O3 -flto"
35PURESCRIPT_PKG_SRCS := $(shell find $(PURESCRIPT_PKGS) -name '*.purs' | grep -v \/test\/ | grep -v \/example\/ | grep -v \/examples\/)
36PURESCRIPT_SRCS := $(shell find $(PURESCRIPT_SRC) -name '*.purs')
38INCLUDES := -I $(OUTPUT)
39BIN_DIR := $(OUTPUT)/bin
41release: codegen
42 @$(MAKE) $(BIN) CXXFLAGS+=$(RELEASE)
44debug: codegen
45 @$(MAKE) $(BIN) CXXFLAGS+=$(DEBUG)
47codegen:
48 @$(PCC) $(PCCFLAGS) --output $(OUTPUT) $(PURESCRIPT_PKG_SRCS) $(PURESCRIPT_SRCS)
50SRCS := $(shell find $(OUTPUT) 2>/dev/null -name '*.cc')
52OBJS = $(SRCS:.cc=.o)
53DEPS = $(SRCS:.cc=.d)
55$(BIN): $(OBJS)
56 @echo "Linking" $(BIN_DIR)/$(BIN)
57 @mkdir -p $(BIN_DIR)
58 @$(CXX) $(LDFLAGS) $^ -o $(BIN_DIR)/$@
60-include $(DEPS)
62%.o: %.cc
63 @echo "Creating" $@
64 @$(CXX) $(CXXFLAGS) $(INCLUDES) -MMD -MP -c $< -o $@
66.PHONY: clean
67clean:
68 @-rm -rf $(OUTPUT)