-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathmakefile
63 lines (50 loc) · 1.36 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
SRCDIR = src
OBJDIR = bin
DISTDIR = dist
SRCS := $(shell find $(SRCDIR) -name '*.c*')
SRCDIRS := $(shell find . -name '*.c*' -exec dirname {} \; | uniq)
TEMP := $(patsubst %.cpp,$(OBJDIR)/%.o,$(SRCS))
OBJS := $(patsubst %.c,$(OBJDIR)/%.o,$(TEMP))
APPS = $(DISTDIR)/dcraw.js
target: $(DISTDIR)/dcraw.js
all: buildrepo $(APPS)
EMFLAGS = -s USE_ZLIB=1 \
-s ALLOW_MEMORY_GROWTH=1 \
-s TOTAL_MEMORY=134217728 \
-s NO_EXIT_RUNTIME=1 \
-s FORCE_FILESYSTEM=1 \
-s EXPORT_NAME="'dcraw'" \
-s NODEJS_CATCH_EXIT=1 \
-s INVOKE_RUN=0 \
-s MODULARIZE=1 \
--memory-init-file 0 \
--pre-js js-wrapper.js \
-O3
# DCRAW
CFLAGS = -DNODEPS=1
$(DISTDIR)/dcraw.js : $(OBJS)
emcc --bind $(OBJS) -o $@ \
-s EXPORTED_FUNCTIONS="[ '_main' ]" \
$(EMFLAGS)
@$(call make-module, $@)
$(OBJDIR)/%.o: %.c
echo $<
emcc -s USE_ZLIB=1 $(CFLAGS) --bind $< -o $@
$(OBJDIR)/%.o: %.cpp
emcc -s USE_ZLIB=1 $(CFLAGS) --bind -std=c++11 $< -o $@
clean: distclean
$(RM) $(OBJS)
distclean:
$(RM) $(APPS)
buildrepo:
@$(call make-repo)
define make-repo
mkdir -p $(DISTDIR); \
for dir in $(SRCDIRS); \
do \
mkdir -p $(OBJDIR)/$$dir; \
done
endef
define make-module
echo 'if (dcraw) { const em_module = dcraw; dcraw = function() { return em_module().dcraw.apply(this, arguments); }; if (typeof module === "object" && module.exports) { module.exports = dcraw; } }' >> $(1);
endef