Skip to content

Make images smaller using best-in-class codecs, right in the browser.

JavaScript

Download sources as tar.gz

Surma3c92f2d531f2
diff --git a/codecs/avif/Makefile b/codecs/avif/Makefile
index 3b14713f..7fa2a96c 100644
--- a/codecs/avif/Makefile
+++ b/codecs/avif/Makefile
@@ -1,16 +1,17 @@
-ROOT_DIR = ./node_modules
-CODEC_DIR_RELATIVE = libavif
-CODEC_DIR = $(addprefix $(ROOT_DIR)/, $(CODEC_DIR_RELATIVE))
-CODEC_OUT_RELATIVE = build/libavif.a
-CODEC_OUT := $(addprefix $(CODEC_DIR)/, $(CODEC_OUT_RELATIVE))
+ROOT_DIR = node_modules
+CODEC_DIR = $(ROOT_DIR)/libavif
+CODEC_BUILD_DIR = build
+CODEC_OUT := $(CODEC_DIR)/$(CODEC_BUILD_DIR)/libavif.a
+
+CODEC_URL = "https://github.com/AOMediaCodec/libavif"
CODEC_VERSION = "v0.8.0"
-LIBAOM_RELATIVE = ext/aom/
-LIBAOM_DIR := $(addprefix $(CODEC_DIR)/, $(LIBAOM_RELATIVE))
-LIBAOM_OUT_RELATIVE = build.libavif/libaom.a
-LIBAOM_OUT := $(addprefix $(LIBAOM_DIR)/, $(LIBAOM_OUT_RELATIVE))
+LIBAOM_DIR := $(CODEC_DIR)/ext/aom
+LIBAOM_BUILD_DIR = build.libavif
+LIBAOM_OUT := $(LIBAOM_DIR)/$(LIBAOM_BUILD_DIR)/libaom.a
+LIBAOM_URL = "https://aomedia.googlesource.com/aom/"
LIBAOM_VERSION = "v2.0.0"
OUT_JS = enc/avif_enc.js dec/avif_dec.js
@@ -28,14 +29,13 @@ all: $(OUT_JS)
--bind \
--closure 1 \
-s ALLOW_MEMORY_GROWTH=1 \
- -s MODULARIZE=1 \
- -s 'EXPORT_NAME="$(basename $(@F))"' \
+ -s MODULARIZE=1 \ -s 'EXPORT_NAME="$(basename $(@F))"' \
-o $@ \
$+
-$(LIBAOM_OUT): $(LIBAOM_DIR)/.git/index
- mkdir -p $(LIBAOM_DIR)/build.libavif && \
- cd $(LIBAOM_DIR)/build.libavif && \
+$(LIBAOM_OUT): $(LIBAOM_DIR)/README.md
+ mkdir -p $(LIBAOM_DIR)/$(LIBAOM_BUILD_DIR) && \
+ cd $(LIBAOM_DIR)/$(LIBAOM_BUILD_DIR) && \
emcmake cmake \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_CCACHE=0 \
@@ -50,13 +50,14 @@ $(LIBAOM_OUT): $(LIBAOM_DIR)/.git/index
../ && \
$(MAKE)
-$(LIBAOM_DIR)/.git/index: $(CODEC_DIR)/.git/index
- cd $(CODEC_DIR)/ext && \
- git clone -b $(LIBAOM_VERSION) --depth 1 https://aomedia.googlesource.com/aom aom
+$(LIBAOM_DIR)/README.md: $(CODEC_DIR)/README.md
+ mkdir -p $(LIBAOM_DIR) && \
+ cd $(LIBAOM_DIR) && \
+ curl -L $(LIBAOM_URL)/+archive/$(LIBAOM_VERSION).tar.gz | tar -xzf -
-$(CODEC_OUT): $(CODEC_DIR)/.git/index $(LIBAOM_OUT)
- mkdir -p $(CODEC_DIR)/build && \
- cd $(CODEC_DIR)/build && \
+$(CODEC_OUT): $(LIBAOM_OUT)
+ mkdir -p $(CODEC_DIR)/$(CODEC_BUILD_DIR) && \
+ cd $(CODEC_DIR)/$(CODEC_BUILD_DIR) && \
emcmake cmake \
DCMAKE_BUILD_TYPE=Release \
-DAVIF_CODEC_AOM=1 \
@@ -64,12 +65,12 @@ $(CODEC_OUT): $(CODEC_DIR)/.git/index $(LIBAOM_OUT)
../ && \
$(MAKE)
-$(CODEC_DIR)/.git/index:
- mkdir -p $(ROOT_DIR) && \
- cd $(ROOT_DIR) && \
- git clone -b $(CODEC_VERSION) --depth 1 https://github.com/AOMediaCodec/libavif $(CODEC_DIR_RELATIVE)
+$(CODEC_DIR)/README.md:
+ mkdir -p $(CODEC_DIR) && \
+ cd $(CODEC_DIR) && \
+ curl -L $(CODEC_URL)/archive/$(CODEC_VERSION).tar.gz | tar -xzf - --strip 1
clean:
$(RM) $(OUT_JS) $(OUT_WASM)
- $(RM) -rf $(LIBAOM_OUT)
- $(RM) -rf $(CODEC_OUT)
+ cd $(CODEC_DIR)/$(CODEC_BUILD_DIR) && $(MAKE) clean
+ cd $(LIBAOM_DIR)/$(LIBAOM_BUILD_DIR) && $(MAKE) clean