@@ -0,0 +1,94 @@
1+# PureScript to native binary (via C++) Makefile
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
6+# You can also perform a parallel build with 'make -jN', where N is the
7+# number of cores to use.
9+# PURS, SRC, OUTPUT, and BIN can all be overridden with the
10+# command itself. For example: 'make BIN=myutil'
12+# Flags can be added to either the codegen or native build phases.
13+# For example: 'make PURSFLAGS=--codegen,js CFLAGS=-DDEBUG LDFLAGS=lgmp'
15+# You can also edit the generated version of this file directly.
18+PSC_PACKAGE := psc-package
22+CC_SRC := $(OUTPUT)/src
26+override PURSFLAGS += compile --codegen corefn
27+override CFLAGS += --std=c++11
32+INCLUDES := -I $(CC_SRC)
33+BIN_DIR := $(OUTPUT)/bin
35+PACKAGE_SOURCES = $(subst \,/,$(shell $(PSC_PACKAGE) sources))
36+PURESCRIPT_PKGS := $(firstword $(subst /, ,$(PACKAGE_SOURCES)))
38+## Not all environments support globstar (** dir pattern)
39+rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
42+ @$(MAKE) $(BIN) CFLAGS+=$(RELEASE)
45+ @$(MAKE) $(BIN) CFLAGS+=$(DEBUG)
48+corefn: PURESCRIPT_PKG_SRCS=$(foreach d,$(PACKAGE_SOURCES),$(call rwildcard,$(firstword $(subst *, ,$(d))),*.purs))
49+corefn: PURESCRIPT_SRCS=$(call rwildcard,$(SRC)/,*.purs)
50+corefn: $(PURESCRIPT_PKGS)
51+ @$(PURS) $(PURSFLAGS) --output $(OUTPUT) $(PURESCRIPT_PKG_SRCS) $(PURESCRIPT_SRCS)
54+codegen: COREFN_SRCS=$(call rwildcard,$(OUTPUT)/,corefn.json)
56+ @$(PSOBJC) $(COREFN_SRCS)
59+ @echo "Getting packages using" $(PSC_PACKAGE) "..."
60+ @$(PSC_PACKAGE) update
62+SRCS := $(call rwildcard,$(CC_SRC)/,*.cpp)
63+SRCS += $(call rwildcard,$(FFI_SRC)/,*.cpp)
64+SRCS += $(call rwildcard,$(FFI_SRC)/,*.c)
66+OBJS1 = $(SRCS:.cpp=.o)
71+ @echo "Linking" $(BIN_DIR)/$(BIN)
73+ @$(CXX) $^ -o $(BIN_DIR)/$@ $(LDFLAGS)
79+ @$(CXX) $(CFLAGS) $(INCLUDES) -MMD -MP -c $< -o $@
83+ @$(CXX) $(CFLAGS) $(INCLUDES) -MMD -MP -c $< -o $@
94+ @$(BIN_DIR)/$(BIN) $(ARGS)