git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
C++: more Makefile integration with psc-package
commite6bc5fa2bff68204919f56a98d82dff94e89b06d authorAndy Arvanitis <andyarvanitis@gmail.com> dateFri 9 Dec 2016, 15:28 (10 years ago) parent6631ed4
1 file changed+18−12
pcc/support/Makefile+18−12
pcc/support/Makefile+18−12
@@ -6,8 +6,8 @@
66# You can also perform a parallel build with 'make -jN', where N is the
77# number of cores to use.
88#
9−# PCC, PURESCRIPT_PKGS, OUTPUT, and BIN can all be overridden with the
10−# command itself. For example: 'make PURESCRIPT_PKGS=../gitpackages BIN=myexe'
9+# PCC, PURESCRIPT_SRC, OUTPUT, and BIN can all be overridden with the
10+# command itself. For example: 'make BIN=myutil'
1111#
1212# Flags can be added to either the codegen or native build phases.
1313# For example: 'make PCCFLAGS=--no-tco CXXFLAGS=-DDEBUG LDFLAGS=lobjc'
@@ -15,9 +15,6 @@
1515# You can also edit the generated version of this file directly.
1616#
1717PCC := {{path}}/pcc
18−PSC_PKG_BIN := psc-package
19−PSC_PACKAGE := {{path}}/$(PSC_PKG_BIN)
20−PURESCRIPT_PKGS := .psc-package
2118PURESCRIPT_SRC := src
2219OUTPUT := output
2320BIN := main
@@ -26,10 +23,6 @@ override PCCFLAGS += --comments
2623override CXXFLAGS += -std=c++11
2724override LDFLAGS +=
2825
29−ifeq ("$(wildcard $(PSC_PACKAGE))","")
30− PSC_PACKAGE := $(PSC_PKG_BIN)
31−endif
32−
3326ifeq ($(GC),yes)
3427 override CXXFLAGS += -DUSE_GC
3528 override LDFLAGS += -lgc
@@ -41,14 +34,27 @@ RELEASE := "-O3 -flto"
4134INCLUDES := -I $(OUTPUT)
4235BIN_DIR := $(OUTPUT)/bin
4336
37+PSC_PKG_BIN := psc-package
38+PSC_PACKAGE := {{path}}/$(PSC_PKG_BIN)
39+
40+ifeq ("$(wildcard $(PSC_PACKAGE))","")
41+ PSC_PACKAGE := $(PSC_PKG_BIN)
42+endif
43+
44+PACKAGE_SOURCES = $(shell $(PSC_PACKAGE) sources)
45+PURESCRIPT_PKGS := $(firstword $(subst /, ,$(PACKAGE_SOURCES)))
46+
47+## Not all environments support globstar (** dir pattern)
48+rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
49+
4450release: codegen
4551 @$(MAKE) $(BIN) CXXFLAGS+=$(RELEASE)
4652
4753debug: codegen
4854 @$(MAKE) $(BIN) CXXFLAGS+=$(DEBUG)
4955
50−codegen: PURESCRIPT_PKG_SRCS=$(shell find $(PURESCRIPT_PKGS) -name '*.purs' | grep -v \/test\/ | grep -v \/example\/ | grep -v \/examples\/)
51−codegen: PURESCRIPT_SRCS=$(shell find $(PURESCRIPT_SRC) -name '*.purs')
56+codegen: PURESCRIPT_PKG_SRCS=$(foreach d,$(PACKAGE_SOURCES),$(call rwildcard,$(firstword $(subst *, ,$(d))),*.purs))
57+codegen: PURESCRIPT_SRCS=$(call rwildcard,$(PURESCRIPT_SRC)/,*.purs)
5258#
5359codegen: $(PURESCRIPT_PKGS)
5460 @$(PCC) $(PCCFLAGS) --output $(OUTPUT) $(PURESCRIPT_PKG_SRCS) $(PURESCRIPT_SRCS)
@@ -57,7 +63,7 @@ $(PURESCRIPT_PKGS):
5763 @echo "Getting packages using" $(PSC_PACKAGE) "..."
5864 @$(PSC_PACKAGE) update
5965
60−SRCS := $(shell find $(OUTPUT) 2>/dev/null -name '*.cc')
66+SRCS := $(call rwildcard,$(OUTPUT)/,*.cc)
6167
6268OBJS = $(SRCS:.cc=.o)
6369DEPS = $(SRCS:.cc=.d)