This repository has been archived by the owner on Nov 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Makefile.emscripten
46 lines (32 loc) · 2.11 KB
/
Makefile.emscripten
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
CC = emcc
LD = $(CC)
SPARKLING_LIBDIR="/usr/local/lib/sparkling/"
# optimizations *MUST* be the same for compile- and link time
OPTIMIZE = -O3 -flto
CORE_DEFINES = -DUSE_LIBEDIT=0 -DUSE_DYNAMIC_LOADING=0 -DNDEBUG -D_POSIX_SOURCE -DSPARKLING_LIBDIR_RAW=$(SPARKLING_LIBDIR)
JSAPI_DEFINES = -DUSE_LIBEDIT=0 -DUSE_DYNAMIC_LOADING=0 -DDEBUG -D_POSIX_SOURCE
WARNINGS = -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-logical-op-parentheses -Wno-missing-field-initializers
EXPORT = "['_jspn_freeAll','_jspn_compile','_jspn_compileExpr','_jspn_parse','_jspn_parseExpr','_jspn_compileAST','_jspn_call','_jspn_lastErrorMessage','_jspn_lastErrorLine','_jspn_lastErrorColumn','_jspn_lastErrorType','_jspn_getGlobal','_jspn_setGlobal','_jspn_backtrace','_jspn_reset','_jspn_addNil','_jspn_addBool','_jspn_addNumber','_jspn_addString','_jspn_addArrayWithIndexBuffer','_jspn_addDictionaryWithIndexBuffer','_jspn_typeAtIndex','_jspn_valueTypeNameAtIndex','_jspn_getBool','_jspn_getNumber','_jspn_getString','_jspn_addValueFromArgv','_jspn_countOfArrayAtIndex','_jspn_countOfHashMapAtIndex','_jspn_getValueIndicesOfArrayAtIndex','_jspn_getKeyAndValueIndicesOfHashMapAtIndex','_jspn_addWrapperFunction','_jspn_getIntFromArray']"
CORE_CFLAGS = -c -std=c89 -pedantic -fpic $(WARNINGS) $(OPTIMIZE) $(CORE_DEFINES)
JSAPI_CFLAGS = -c -std=c99 -pedantic -fpic $(WARNINGS) $(OPTIMIZE) $(JSAPI_DEFINES)
LDFLAGS = $(OPTIMIZE) -dynamiclib -flto --post-js jsapi.js --js-library auxlib.js --memory-init-file 0 --embed-file lib@$(SPARKLING_LIBDIR) -s EXPORTED_FUNCTIONS=$(EXPORT)
OBJECTS = $(patsubst src/%.c, bld/%.bc, $(wildcard src/*.c)) jsapi.bc
PAGE = libspn.html
LIB = libspn.js
all: $(PAGE)
$(PAGE): $(OBJECTS)
$(LD) $(LDFLAGS) -o $@ $^
$(LIB): $(OBJECTS)
$(LD) $(LDFLAGS) -o $@ $^
bld/%.bc: src/%.c
$(CC) $(CORE_CFLAGS) -o $@ $<
jsapi.bc: jsapi.c
$(CC) $(JSAPI_CFLAGS) -Isrc -o $@ $<
# Script standard library loader
src/ctx.c: src/stdmodules.inc
src/stdmodules.inc:
find lib/ -name "*.spn" -exec basename {} \; \
| awk '{ print "\"" $(SPARKLING_LIBDIR) "/" $$0 "\"," }' > $@
clean:
rm -f $(OBJECTS) $(PAGE) $(LIB) src/stdmodules.inc
.PHONY: all clean