summaryrefslogtreecommitdiffhomepage
path: root/webassembly/Makefile
blob: 49a5ed39e77b9e6435c374e1e5c4fed052aa24c6 (plain)
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
TARGET=libwhiteboard.wasm
TARGETJS=$(TARGET:.wasm=.js)

OBJS=diff.o

CXX=em++

CXXFLAGS=-I./include -O2 -std=c++20
LDFLAGS=-s WASM=1 -s EXPORTED_FUNCTIONS=_diff_create,_diff_apply,_free
# Note: Instead of the above explicit EXPORTED_FUNCTIONS, the following causes ~7x wasm file size:
#-s LINKABLE=1 -s EXPORT_ALL=1

default: $(TARGET)

$(OBJS): include

include:
	mkdir include
	cp -r /usr/include/boost include/boost

$(TARGET): $(OBJS)
	$(CXX) $(LDFLAGS) $(OBJS) -o $(TARGETJS)
	cp $(TARGETJS) $(TARGET) ../html/

diff.o: ../diff.cpp
	$(CXX) -c $< $(CXXFLAGS) -o $@

clean:
	-rm -f *.o *.js *.wasm *.html
	-rm -rf include