forked from GoogleChromeLabs/web-gphoto2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
82 lines (58 loc) · 2.71 KB
/
Makefile
File metadata and controls
82 lines (58 loc) · 2.71 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
SYSROOT := $(shell em-config CACHE)/sysroot
# Add custom sysroot to library & macro search paths.
export LDFLAGS += -L$(SYSROOT)/lib
# Common linking flags for all targets.
export LDFLAGS += -s DYNAMIC_EXECUTION=0 -s AUTO_JS_LIBRARIES=0 -s AUTO_NATIVE_LIBRARIES=0
# Common compilation & linking flags for all langs and targets.
COMMON_FLAGS = -Os -flto
export CFLAGS += $(COMMON_FLAGS)
export CXXFLAGS += $(COMMON_FLAGS)
export LDFLAGS += $(COMMON_FLAGS)
## Main API module
build/libapi.mjs: src/api.o $(SYSROOT)/lib/libltdl.la $(SYSROOT)/lib/libgphoto2.la
set -eu; \
PTP2_LA=$$(find $(SYSROOT)/lib/libgphoto2 -name ptp2.la -print -quit); \
USB1_LA=$$(find $(SYSROOT)/lib/libgphoto2_port -name usb1.la -print -quit); \
: $${PTP2_LA:?missing libgphoto2 ptp2.la}; \
: $${USB1_LA:?missing libgphoto2_port usb1.la}; \
libtool --verbose --mode=link $(LD) $(LDFLAGS) -o $@ $+ \
-fexceptions --bind -s ASYNCIFY -s ALLOW_MEMORY_GROWTH -s ENVIRONMENT=web,worker \
-dlpreopen $$PTP2_LA \
-dlpreopen $$USB1_LA
src/api.o: deps/libgphoto2/configure.ac
src/api.o: CPPFLAGS += -Ideps/libgphoto2 -Ideps/libgphoto2/libgphoto2_port
src/api.o: CXXFLAGS += -std=c++17 -fexceptions -pthread
## Generic rules for deps
$(SYSROOT):
mkdir -p $(@D)
LIBGPHOTO2_PATCH := deps/libgphoto2/.emscripten-patched
$(LIBGPHOTO2_PATCH): patches/libgphoto2-emscripten.patch deps/libgphoto2/configure.ac
cd deps/libgphoto2 && patch -p1 --forward --silent < ../../patches/libgphoto2-emscripten.patch
touch $@
deps/%/configure.ac:
git submodule update --init $(@D)
deps/libgphoto2/configure: $(LIBGPHOTO2_PATCH)
deps/%/configure: deps/%/configure.ac | $(SYSROOT)/lib/libltdl.la
cd $(@D) && autoreconf -fiv
deps/%/Makefile: deps/%/configure
cd $(@D) && ./configure --prefix=$(SYSROOT) --disable-shared $(CONFIGURE_ARGS)
## libtool
deps/libtool/configure:
mkdir -p deps/libtool
curl -L https://ftpmirror.gnu.org/libtool/libtool-2.4.6.tar.gz | tar zx --strip 1 -C deps/libtool
$(SYSROOT)/lib/libltdl.la: deps/libtool/Makefile | $(SYSROOT)
$(MAKE) -C deps/libtool install
## libusb
deps/libusb/configure:
mkdir -p deps/libusb
curl -L https://github.com/libusb/libusb/releases/download/v1.0.27/libusb-1.0.27.tar.bz2 | tar jx --strip 1 -C deps/libusb
deps/libusb/Makefile: CONFIGURE_ARGS = --host=wasm32-emscripten
$(SYSROOT)/lib/libusb-1.0.la: deps/libusb/Makefile
$(MAKE) -C deps/libusb install
## libgphoto2
deps/libgphoto2/Makefile: | $(SYSROOT)/lib/libusb-1.0.la
deps/libgphoto2/Makefile: CONFIGURE_ARGS = --host=wasm32-emscripten \
--without-libxml-2.0 --disable-nls --disable-ptpip --disable-disk \
--with-camlibs=ptp2
$(SYSROOT)/lib/libgphoto2.la: deps/libgphoto2/Makefile $(SYSROOT)/lib/libusb-1.0.la $(SYSROOT)/lib/libltdl.la
$(MAKE) -C deps/libgphoto2 install