git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
C++: more Makefile integration with psc-package
e6bc5faAndy Arvanitis
pcc/support/Makefile+18−12
@@ -6,8 +6,8 @@
6# You can also perform a parallel build with 'make -jN', where N is the
6# You can also perform a parallel build with 'make -jN', where N is the
7# number of cores to use.
7# number of cores to use.
8#
8#
9−# PCC, PURESCRIPT_PKGS, OUTPUT, and BIN can all be overridden with the
9+# PCC, PURESCRIPT_SRC, OUTPUT, and BIN can all be overridden with the
10−# command itself. For example: 'make PURESCRIPT_PKGS=../gitpackages BIN=myexe'
10+# command itself. For example: 'make BIN=myutil'
11#
11#
12# Flags can be added to either the codegen or native build phases.
12# Flags can be added to either the codegen or native build phases.
13# For example: 'make PCCFLAGS=--no-tco CXXFLAGS=-DDEBUG LDFLAGS=lobjc'
13# For example: 'make PCCFLAGS=--no-tco CXXFLAGS=-DDEBUG LDFLAGS=lobjc'
@@ -15,9 +15,6 @@
15# You can also edit the generated version of this file directly.
15# You can also edit the generated version of this file directly.
16#
16#
17PCC := {{path}}/pcc
17PCC := {{path}}/pcc
18−PSC_PKG_BIN := psc-package
19−PSC_PACKAGE := {{path}}/$(PSC_PKG_BIN)
20−PURESCRIPT_PKGS := .psc-package
21PURESCRIPT_SRC := src
18PURESCRIPT_SRC := src
22OUTPUT := output
19OUTPUT := output
23BIN := main
20BIN := main
@@ -26,10 +23,6 @@ override PCCFLAGS += --comments
26override CXXFLAGS += -std=c++11
23override CXXFLAGS += -std=c++11
27override LDFLAGS +=
24override LDFLAGS +=
28
25
29−ifeq ("$(wildcard $(PSC_PACKAGE))","")
30− PSC_PACKAGE := $(PSC_PKG_BIN)
31−endif
32−
33ifeq ($(GC),yes)
26ifeq ($(GC),yes)
34 override CXXFLAGS += -DUSE_GC
27 override CXXFLAGS += -DUSE_GC
35 override LDFLAGS += -lgc
28 override LDFLAGS += -lgc
@@ -41,14 +34,27 @@ RELEASE := "-O3 -flto"
41INCLUDES := -I $(OUTPUT)
34INCLUDES := -I $(OUTPUT)
42BIN_DIR := $(OUTPUT)/bin
35BIN_DIR := $(OUTPUT)/bin
43
36
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+
44release: codegen
50release: codegen
45 @$(MAKE) $(BIN) CXXFLAGS+=$(RELEASE)
51 @$(MAKE) $(BIN) CXXFLAGS+=$(RELEASE)
46
52
47debug: codegen
53debug: codegen
48 @$(MAKE) $(BIN) CXXFLAGS+=$(DEBUG)
54 @$(MAKE) $(BIN) CXXFLAGS+=$(DEBUG)
49
55
50−codegen: PURESCRIPT_PKG_SRCS=$(shell find $(PURESCRIPT_PKGS) -name '*.purs' | grep -v \/test\/ | grep -v \/example\/ | grep -v \/examples\/)
56+codegen: PURESCRIPT_PKG_SRCS=$(foreach d,$(PACKAGE_SOURCES),$(call rwildcard,$(firstword $(subst *, ,$(d))),*.purs))
51−codegen: PURESCRIPT_SRCS=$(shell find $(PURESCRIPT_SRC) -name '*.purs')
57+codegen: PURESCRIPT_SRCS=$(call rwildcard,$(PURESCRIPT_SRC)/,*.purs)
52#
58#
53codegen: $(PURESCRIPT_PKGS)
59codegen: $(PURESCRIPT_PKGS)
54 @$(PCC) $(PCCFLAGS) --output $(OUTPUT) $(PURESCRIPT_PKG_SRCS) $(PURESCRIPT_SRCS)
60 @$(PCC) $(PCCFLAGS) --output $(OUTPUT) $(PURESCRIPT_PKG_SRCS) $(PURESCRIPT_SRCS)
@@ -57,7 +63,7 @@ $(PURESCRIPT_PKGS):
57 @echo "Getting packages using" $(PSC_PACKAGE) "..."
63 @echo "Getting packages using" $(PSC_PACKAGE) "..."
58 @$(PSC_PACKAGE) update
64 @$(PSC_PACKAGE) update
59
65
60−SRCS := $(shell find $(OUTPUT) 2>/dev/null -name '*.cc')
66+SRCS := $(call rwildcard,$(OUTPUT)/,*.cc)
61
67
62OBJS = $(SRCS:.cc=.o)
68OBJS = $(SRCS:.cc=.o)
63DEPS = $(SRCS:.cc=.d)
69DEPS = $(SRCS:.cc=.d)