#########
# Makefile for emscripten
CC=emcc
CXX=em++
AR=emar
LD=emcc

######### Configurations defining feature set #########
# Use "make target DRACO_CONFIG=full|limited" to set the desired configuration

# Select the correct version based on the input flags.
DRACO_CONFIG ?= full

# Full config - all features included.
DRACO_FULL_MESH_CONFIG_DEFINES := -DDRACO_MESH_COMPRESSION_SUPPORTED
DRACO_FULL_MESH_CONFIG_DEFINES += -DDRACO_STANDARD_EDGEBREAKER_SUPPORTED
DRACO_FULL_MESH_CONFIG_DEFINES += -DDRACO_PREDICTIVE_EDGEBREAKER_SUPPORTED

DRACO_FULL_POINT_CLOUD_CONFIG_DEFINES := -DDRACO_POINT_CLOUD_COMPRESSION_SUPPORTED

DRACO_FULL_CONFIG_DEFINES := $(DRACO_FULL_MESH_CONFIG_DEFINES)
DRACO_FULL_CONFIG_DEFINES += $(DRACO_FULL_POINT_CLOUD_CONFIG_DEFINES)

# Default limited config with only some core features enabled.
DRACO_LIMITED_CONFIG_DEFINES := -DDRACO_STANDARD_EDGEBREAKER_SUPPORTED
DRACO_LIMITED_CONFIG_DEFINES += -DDRACO_POINT_CLOUD_COMPRESSION_SUPPORTED
DRACO_LIMITED_CONFIG_DEFINES += -DDRACO_MESH_COMPRESSION_SUPPORTED

ifeq ($(DRACO_CONFIG), limited)
  DRACO_CONFIG_DEFINES := $(DRACO_LIMITED_CONFIG_DEFINES)
else ifeq ($(DRACO_CONFIG), full_mesh)
  DRACO_CONFIG_DEFINES := $(DRACO_FULL_MESH_CONFIG_DEFINES)
else ifeq ($(DRACO_CONFIG), full_point_cloud)
  DRACO_CONFIG_DEFINES := $(DRACO_FULL_POINT_CLOUD_CONFIG_DEFINES)
else
  DRACO_CONFIG_DEFINES := $(DRACO_FULL_CONFIG_DEFINES)
endif
#########

DEFINES   := $(DRACO_CONFIG_DEFINES)
INCLUDES  := -I../../ -I./ -I./src/
SRCDIR    := src/draco
OBJDIR    := obj
LIBDIR    := libs
IDL       := $(SRCDIR)/javascript/emscripten/draco_web_encoder.idl
BINDER    := $(EMSCRIPTEN)/tools/webidl_binder.py

# In order to open an input mesh file with test_mesh_encoder, you need to add
# the mesh here. Then you need to add the test_mesh_encoder command line
# arguments to the generated html file. E.g.
# arguments: ["-m","1","-q","9", "-noerror","-no3rdparty","-f","cube.obj"],
#MESH_FILE := --preload-file cube.obj
MESH_FILE :=

ALL_C_OPTS := -std=c++11

# Options to reduce JavaScript size.
#ALL_C_OPTS += -Oz -s NO_FILESYSTEM=1 -s DISABLE_EXCEPTION_CATCHING=1
#ALL_C_OPTS += -s USE_SDL=0 -s USE_SDL_IMAGE=0 -s USE_SDL_TTF=0

# Options for speed.
ALL_C_OPTS += -O3
ALL_C_OPTS += -s NO_FILESYSTEM=1 -s ELIMINATE_DUPLICATE_FUNCTIONS=1
ALL_C_OPTS += -s EXPORTED_RUNTIME_METHODS=[]
ALL_C_OPTS += -s PRECISE_F32=1

# Option to get about a 10% speed increase at the cost of about 10% in size.
# Use "make target DRACO_PERFORMANCE_TYPE=extra_speed"
ifeq ($(DRACO_PERFORMANCE_TYPE), extra_speed)
  ALL_C_OPTS += --llvm-lto 1
endif

# Options for debug
#ALL_C_OPTS += -g -s DEMANGLE_SUPPORT=1

# If you use -s ALLOW_MEMORY_GROWTH=1 it may turn off some optimizations which
# will hurt performance.
ALL_C_OPTS += -s ALLOW_MEMORY_GROWTH=1
#ALL_C_OPTS += -s TOTAL_MEMORY=67108864

# Export the main module as "DracoEncoderModule".
ALL_C_OPTS += -s MODULARIZE=1 -s EXPORT_NAME="'DracoEncoderModule'"

# Do not create a .mem file.
ALL_C_OPTS += --memory-init-file 0

# Options to separate asm.js and mem file.
#ALL_C_OPTS += --separate-asm --memory-init-file 1

# Options to output WebAssembly code.
# Use "make target DRACO_BUILD_TYPE=wasm"
ifeq ($(DRACO_BUILD_TYPE), wasm)
  ALL_C_OPTS += -s WASM=1 -s BINARYEN_IMPRECISE=1
endif

CFLAGS     := $(ALL_C_OPTS)
CXXFLAGS   := $(ALL_C_OPTS)
CFLAGS     += -Wno-sign-compare -fno-omit-frame-pointer
CXXFLAGS   += -Wno-sign-compare -fno-omit-frame-pointer

ALL_CXXFLAGS := -MMD -MP $(DEFINES) $(INCLUDES) $(CXXFLAGS)

DATA_BUFFER_A    := libdata_buffer.a
DATA_BUFFER_OBJS := core/data_buffer.o

QUANTIZATION_UTILS_A    := libquantization_utils.a
QUANTIZATION_UTILS_OBJS := core/quantization_utils.o
CYCLE_TIMER_A    := libcycle_timer.a
CYCLE_TIMER_OBJS := core/cycle_timer.o

ENCODER_BUFFER_A    := libencoder_buffer.a
ENCODER_BUFFER_OBJS := core/encoder_buffer.o

DECODER_BUFFER_A    := libdecoder_buffer.a
DECODER_BUFFER_OBJS := core/decoder_buffer.o

RANS_BIT_DECODER_A    := librans_bit_decoder.a
RANS_BIT_DECODER_OBJS := core/divide.o core/bit_coders/rans_bit_decoder.o

RANS_BIT_ENCODER_A    := librans_bit_encoder.a
RANS_BIT_ENCODER_OBJS := core/divide.o core/bit_coders/rans_bit_encoder.o

ADAPTIVE_RANS_BIT_DECODER_A    := libadaptive_rans_bit_decoder.a
ADAPTIVE_RANS_BIT_DECODER_OBJS := core/bit_coders/adaptive_rans_bit_decoder.o

ADAPTIVE_RANS_BIT_ENCODER_A    := libadaptive_rans_bit_encoder.a
ADAPTIVE_RANS_BIT_ENCODER_OBJS := core/bit_coders/adaptive_rans_bit_encoder.o

CORNER_TABLE_A    := libcorner_table.a
CORNER_TABLE_OBJS := mesh/corner_table.o

SHANNON_ENTROPY_A    := libshannon_entropy.a
SHANNON_ENTROPY_OBJS := core/shannon_entropy.o

SYMBOL_CODING_A    := libsymbol_coding.a
SYMBOL_CODING_OBJS := \
    core/symbol_decoding.o core/symbol_encoding.o core/symbol_coding_utils.o

DIRECT_BIT_DECODER_A    := libdirect_bit_decoder.a
DIRECT_BIT_DECODER_OBJS := core/bit_coders/direct_bit_decoder.o

DIRECT_BIT_ENCODER_A    := libdirect_bit_encoder.a
DIRECT_BIT_ENCODER_OBJS := core/bit_coders/direct_bit_encoder.o

DRACO_TYPES_A    := libdraco_types.a
DRACO_TYPES_OBJS := core/draco_types.o

METADATA_A    :=metadata/metadata.a
METADATA_OBJS :=metadata/metadata.o
GEOMETRY_METADATA_A    :=metadata/geometry_metadata.a
GEOMETRY_METADATA_OBJS :=metadata/geometry_metadata.o
METADATA_ENCODER_A    :=metadata/metadata_encoder.a
METADATA_ENCODER_OBJS :=metadata/metadata_encoder.o
METADATA_DECODER_A    :=metadata/metadata_decoder.a
METADATA_DECODER_OBJS :=metadata/metadata_decoder.o

GEOMETRY_ATTRIBUTE_A    := geometry_attribute.a
GEOMETRY_ATTRIBUTE_OBJS := attributes/geometry_attribute.o
POINT_ATTRIBUTE_A    := point_attribute.a
POINT_ATTRIBUTE_OBJS := attributes/point_attribute.o
ATTRIBUTE_OCTAHEDRON_TRANSFORM_A    := attribute_octahedron_transform.a
ATTRIBUTE_OCTAHEDRON_TRANSFORM_OBJS := attributes/attribute_octahedron_transform.o
ATTRIBUTE_QUANTIZATION_TRANSFORM_A    := attribute_quantization_transform.a
ATTRIBUTE_QUANTIZATION_TRANSFORM_OBJS := attributes/attribute_quantization_transform.o
ATTRIBUTE_TRANSFORM_A    := attribute_transform.a
ATTRIBUTE_TRANSFORM_OBJS := attributes/attribute_transform.o
POINT_CLOUD_A    := point_cloud.a
POINT_CLOUD_OBJS := point_cloud/point_cloud.o
MESH_A    := libmesh.a
MESH_OBJS := mesh/mesh.o
OPTIONS_A    := options.a
OPTIONS_OBJS := core/options.o
POINT_CLOUD_ENCODER_BASE_A    := point_cloud_encoder_base.a
POINT_CLOUD_ENCODER_BASE_OBJS := compression/attributes/attributes_encoder.o
POINT_CLOUD_ENCODER_BASE_OBJS += compression/point_cloud/point_cloud_encoder.o
POINT_CLOUD_DECODER_BASE_A    := point_cloud_decoder_base.a
POINT_CLOUD_DECODER_BASE_OBJS := compression/attributes/attributes_decoder.o
POINT_CLOUD_DECODER_BASE_OBJS += compression/point_cloud/point_cloud_decoder.o

MESH_ENCODER_BASE_A    := mesh_encoder_base.a
MESH_ENCODER_BASE_OBJS := compression/mesh/mesh_encoder.o
MESH_DECODER_BASE_A    := mesh_decoder_base.a
MESH_DECODER_BASE_OBJS := compression/mesh/mesh_decoder.o
SEQUENTIAL_ATTRIBUTE_ENCODER_A    := sequential_attribute_encoder.a
SEQUENTIAL_ATTRIBUTE_ENCODER_OBJS := \
    compression/attributes/sequential_attribute_encoder.o
SEQUENTIAL_ATTRIBUTE_DECODER_A    := sequential_attribute_decoder.a
SEQUENTIAL_ATTRIBUTE_DECODER_OBJS := \
    compression/attributes/sequential_attribute_decoder.o
SEQUENTIAL_INTEGER_ATTRIBUTE_ENCODER_A    := \
    sequential_integer_attribute_encoder.a
SEQUENTIAL_INTEGER_ATTRIBUTE_ENCODER_OBJS := \
    compression/attributes/sequential_integer_attribute_encoder.o
SEQUENTIAL_INTEGER_ATTRIBUTE_DECODER_A    := \
    sequential_integer_attribute_decoder.a
SEQUENTIAL_INTEGER_ATTRIBUTE_DECODER_OBJS := \
    compression/attributes/sequential_integer_attribute_decoder.o
SEQUENTIAL_QUANTIZATION_ATTRIBUTE_ENCODER_A    := \
    sequential_quantization_attribute_encoder.a
SEQUENTIAL_QUANTIZATION_ATTRIBUTE_ENCODER_OBJS := \
    compression/attributes/sequential_quantization_attribute_encoder.o
SEQUENTIAL_QUANTIZATION_ATTRIBUTE_DECODER_A    := \
    sequential_quantization_attribute_decoder.a
SEQUENTIAL_QUANTIZATION_ATTRIBUTE_DECODER_OBJS := \
    compression/attributes/sequential_quantization_attribute_decoder.o
KD_TREE_ATTRIBUTES_ENCODER_A    := kd_tree_attributes_encoder.a
KD_TREE_ATTRIBUTES_ENCODER_OBJS := \
    compression/attributes/kd_tree_attributes_encoder.o
KD_TREE_ATTRIBUTES_DECODER_A    := kd_tree_attributes_decoder.a
KD_TREE_ATTRIBUTES_DECODER_OBJS := \
    compression/attributes/kd_tree_attributes_decoder.o

SEQUENTIAL_NORMAL_ATTRIBUTE_ENCODER_A    := \
    sequential_normal_attribute_encoder.a
SEQUENTIAL_NORMAL_ATTRIBUTE_ENCODER_OBJS := \
    compression/attributes/sequential_normal_attribute_encoder.o
SEQUENTIAL_NORMAL_ATTRIBUTE_DECODER_A    := \
    sequential_normal_attribute_decoder.a
SEQUENTIAL_NORMAL_ATTRIBUTE_DECODER_OBJS := \
    compression/attributes/sequential_normal_attribute_decoder.o

SEQUENTIAL_ATTRIBUTE_ENCODERS_CONTROLLER_A    := \
    sequential_attribute_encoders_controller.a
SEQUENTIAL_ATTRIBUTE_ENCODERS_CONTROLLER_OBJS := \
    compression/attributes/sequential_attribute_encoders_controller.o
SEQUENTIAL_ATTRIBUTE_DECODERS_CONTROLLER_A    := \
    sequential_attribute_decoders_controller.a
SEQUENTIAL_ATTRIBUTE_DECODERS_CONTROLLER_OBJS := \
    compression/attributes/sequential_attribute_decoders_controller.o
PREDICTION_SCHEME_ENCODER_FACTORY_A    := \
    prediction_scheme_encoder_factory.a
PREDICTION_SCHEME_ENCODER_FACTORY_OBJS    := \
    compression/attributes/prediction_schemes/prediction_scheme_encoder_factory.o

POINT_CLOUD_SEQUENTIAL_ENCODER_A    := point_cloud_sequential_encoder.a
POINT_CLOUD_SEQUENTIAL_ENCODER_OBJS := \
    compression/point_cloud/point_cloud_sequential_encoder.o
POINT_CLOUD_SEQUENTIAL_DECODER_A    := point_cloud_sequential_decoder.a
POINT_CLOUD_SEQUENTIAL_DECODER_OBJS := \
    compression/point_cloud/point_cloud_sequential_decoder.o
POINT_CLOUD_KD_TREE_ENCODER_A    := point_cloud_kd_tree_encoder.a
POINT_CLOUD_KD_TREE_ENCODER_OBJS := \
    compression/point_cloud/point_cloud_kd_tree_encoder.o
POINT_CLOUD_KD_TREE_DECODER_A    := point_cloud_kd_tree_decoder.a
POINT_CLOUD_KD_TREE_DECODER_OBJS := \
    compression/point_cloud/point_cloud_kd_tree_decoder.o
MESH_SEQUENTIAL_ENCODER_A    := mesh_sequential_encoder.a
MESH_SEQUENTIAL_ENCODER_OBJS := compression/mesh/mesh_sequential_encoder.o
MESH_SEQUENTIAL_DECODER_A    := mesh_sequential_decoder.a
MESH_SEQUENTIAL_DECODER_OBJS := compression/mesh/mesh_sequential_decoder.o

MESH_EDGEBREAKER_ENCODER_A    := mesh_edgebreaker_encoder.a
MESH_EDGEBREAKER_ENCODER_OBJS := compression/mesh/mesh_edgebreaker_encoder.o
MESH_EDGEBREAKER_ENCODER_OBJS += \
    compression/mesh/mesh_edgebreaker_encoder_impl.o
MESH_EDGEBREAKER_DECODER_A    := mesh_edgebreaker_encoder.a
MESH_EDGEBREAKER_DECODER_OBJS := compression/mesh/mesh_edgebreaker_decoder.o
MESH_EDGEBREAKER_DECODER_OBJS += \
    compression/mesh/mesh_edgebreaker_decoder_impl.o
ENCODE_A    := encode.a
ENCODE_OBJS := compression/encode.o
ENCODE_A    := expert_encode.a
EXPERT_ENCODE_OBJS := compression/expert_encode.o
DECODE_A    := decode.a
DECODE_OBJS := compression/decode.o

OBJ_DECODER_A    := libobj_decoder.a
OBJ_DECODER_OBJS := io/obj_decoder.o

PLY_DECODER_A    := libply_decoder.a
PLY_DECODER_OBJS := core/hash_utils.o io/ply_decoder.o

PLY_ENCODER_A    := libply_encoder.a
PLY_ENCODER_OBJS := io/ply_encoder.o

MESH_IO_A    := libmesh_io.a
MESH_IO_OBJS := io/mesh_io.o

MESH_ATTRIBUTE_CORNER_TABLE_A    := libmesh_attribute_corner_table.a
MESH_ATTRIBUTE_CORNER_TABLE_OBJS := mesh/mesh_attribute_corner_table.o

MESH_MISC_A    := libmesh_misc.a
MESH_MISC_OBJS := mesh/mesh_misc_functions.o

FLOAT_POINTS_TREE_DECODER_A    := \
    libfloat_points_tree_decoder.a
FLOAT_POINTS_TREE_DECODER_OBJS := \
    compression/point_cloud/algorithms/float_points_tree_decoder.o

FLOAT_POINTS_TREE_ENCODER_A    := \
    libfloat_points_tree_encoder.a
FLOAT_POINTS_TREE_ENCODER_OBJS := \
    compression/point_cloud/algorithms/float_points_tree_encoder.o

DYNAMIC_INTEGER_POINTS_KD_TREE_DECODER_A    := \
    libdynamic_integer_points_kd_tree_decoder.a
DYNAMIC_INTEGER_POINTS_KD_TREE_DECODER_OBJS := \
    compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_decoder.o

DYNAMIC_INTEGER_POINTS_KD_TREE_ENCODER_A    := \
    libdynamic_integer_points_kd_tree_encoder.a
DYNAMIC_INTEGER_POINTS_KD_TREE_ENCODER_OBJS := \
    compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_encoder.o

CORNER_TABLE_OBJSA := $(addprefix $(OBJDIR)/,$(CORNER_TABLE_OBJS:.o=_a.o))
SHANNON_ENTROPY_OBJSA := $(addprefix $(OBJDIR)/,$(SHANNON_ENTROPY_OBJS:.o=_a.o))
SYMBOL_CODING_OBJSA := $(addprefix $(OBJDIR)/,$(SYMBOL_CODING_OBJS:.o=_a.o))
DIRECT_BIT_DECODER_OBJSA := \
    $(addprefix $(OBJDIR)/,$(DIRECT_BIT_DECODER_OBJS:.o=_a.o))
DIRECT_BIT_ENCODER_OBJSA := \
    $(addprefix $(OBJDIR)/,$(DIRECT_BIT_ENCODER_OBJS:.o=_a.o))
DECODER_BUFFER_OBJSA := $(addprefix $(OBJDIR)/,$(DECODER_BUFFER_OBJS:.o=_a.o))
DATA_BUFFER_OBJSA := $(addprefix $(OBJDIR)/,$(DATA_BUFFER_OBJS:.o=_a.o))
DRACO_TYPES_OBJSA := $(addprefix $(OBJDIR)/,$(DRACO_TYPES_OBJS:.o=_a.o))

METADATA_OBJSA := \
    $(addprefix $(OBJDIR)/,$(METADATA_OBJS:.o=_a.o))
GEOMETRY_METADATA_OBJSA := \
    $(addprefix $(OBJDIR)/,$(GEOMETRY_METADATA_OBJS:.o=_a.o))
METADATA_ENCODER_OBJSA := \
    $(addprefix $(OBJDIR)/,$(METADATA_ENCODER_OBJS:.o=_a.o))
METADATA_DECODER_OBJSA := \
    $(addprefix $(OBJDIR)/,$(METADATA_DECODER_OBJS:.o=_a.o))

GEOMETRY_ATTRIBUTE_OBJSA := \
    $(addprefix $(OBJDIR)/,$(GEOMETRY_ATTRIBUTE_OBJS:.o=_a.o))
POINT_ATTRIBUTE_OBJSA := $(addprefix $(OBJDIR)/,$(POINT_ATTRIBUTE_OBJS:.o=_a.o))
ATTRIBUTE_OCTAHEDRON_TRANSFORM_OBJSA := $(addprefix $(OBJDIR)/,$(ATTRIBUTE_OCTAHEDRON_TRANSFORM_OBJS:.o=_a.o))
ATTRIBUTE_QUANTIZATION_TRANSFORM_OBJSA := $(addprefix $(OBJDIR)/,$(ATTRIBUTE_QUANTIZATION_TRANSFORM_OBJS:.o=_a.o))
ATTRIBUTE_TRANSFORM_OBJSA := $(addprefix $(OBJDIR)/,$(ATTRIBUTE_TRANSFORM_OBJS:.o=_a.o))
POINT_CLOUD_OBJSA := $(addprefix $(OBJDIR)/,$(POINT_CLOUD_OBJS:.o=_a.o))
MESH_OBJSA := $(addprefix $(OBJDIR)/,$(MESH_OBJS:.o=_a.o))
OPTIONS_OBJSA := $(addprefix $(OBJDIR)/,$(OPTIONS_OBJS:.o=_a.o))
POINT_CLOUD_ENCODER_BASE_OBJSA := \
    $(addprefix $(OBJDIR)/,$(POINT_CLOUD_ENCODER_BASE_OBJS:.o=_a.o))
POINT_CLOUD_DECODER_BASE_OBJSA := \
    $(addprefix $(OBJDIR)/,$(POINT_CLOUD_DECODER_BASE_OBJS:.o=_a.o))

MESH_ENCODER_BASE_OBJSA := \
    $(addprefix $(OBJDIR)/,$(MESH_ENCODER_BASE_OBJS:.o=_a.o))
MESH_DECODER_BASE_OBJSA := \
    $(addprefix $(OBJDIR)/,$(MESH_DECODER_BASE_OBJS:.o=_a.o))
SEQUENTIAL_ATTRIBUTE_ENCODER_OBJSA := \
    $(addprefix $(OBJDIR)/,$(SEQUENTIAL_ATTRIBUTE_ENCODER_OBJS:.o=_a.o))
SEQUENTIAL_ATTRIBUTE_DECODER_OBJSA := \
    $(addprefix $(OBJDIR)/,$(SEQUENTIAL_ATTRIBUTE_DECODER_OBJS:.o=_a.o))
SEQUENTIAL_INTEGER_ATTRIBUTE_ENCODER_OBJSA := \
    $(addprefix $(OBJDIR)/,$(SEQUENTIAL_INTEGER_ATTRIBUTE_ENCODER_OBJS:.o=_a.o))
PREDICTION_SCHEME_ENCODER_FACTORY_OBJSA := \
    $(addprefix $(OBJDIR)/,$(PREDICTION_SCHEME_ENCODER_FACTORY_OBJS:.o=_a.o))
SEQUENTIAL_INTEGER_ATTRIBUTE_DECODER_OBJSA := \
    $(addprefix $(OBJDIR)/,$(SEQUENTIAL_INTEGER_ATTRIBUTE_DECODER_OBJS:.o=_a.o))
SEQUENTIAL_QUANTIZATION_ATTRIBUTE_ENCODER_OBJSA := \
    $(addprefix $(OBJDIR)/, \
        $(SEQUENTIAL_QUANTIZATION_ATTRIBUTE_ENCODER_OBJS:.o=_a.o))
SEQUENTIAL_QUANTIZATION_ATTRIBUTE_DECODER_OBJSA := \
    $(addprefix $(OBJDIR)/, \
        $(SEQUENTIAL_QUANTIZATION_ATTRIBUTE_DECODER_OBJS:.o=_a.o))
KD_TREE_ATTRIBUTES_ENCODER_OBJSA := \
    $(addprefix $(OBJDIR)/, $(KD_TREE_ATTRIBUTES_ENCODER_OBJS:.o=_a.o))
KD_TREE_ATTRIBUTES_DECODER_OBJSA := \
    $(addprefix $(OBJDIR)/, $(KD_TREE_ATTRIBUTES_DECODER_OBJS:.o=_a.o))

SEQUENTIAL_NORMAL_ATTRIBUTE_ENCODER_OBJSA := \
    $(addprefix $(OBJDIR)/, \
        $(SEQUENTIAL_NORMAL_ATTRIBUTE_ENCODER_OBJS:.o=_a.o))
SEQUENTIAL_NORMAL_ATTRIBUTE_DECODER_OBJSA := \
    $(addprefix $(OBJDIR)/, \
        $(SEQUENTIAL_NORMAL_ATTRIBUTE_DECODER_OBJS:.o=_a.o))

SEQUENTIAL_ATTRIBUTE_ENCODERS_CONTROLLER_OBJSA := \
    $(addprefix $(OBJDIR)/, \
        $(SEQUENTIAL_ATTRIBUTE_ENCODERS_CONTROLLER_OBJS:.o=_a.o))
SEQUENTIAL_ATTRIBUTE_DECODERS_CONTROLLER_OBJSA := \
    $(addprefix $(OBJDIR)/, \
        $(SEQUENTIAL_ATTRIBUTE_DECODERS_CONTROLLER_OBJS:.o=_a.o))
POINT_CLOUD_SEQUENTIAL_ENCODER_OBJSA := \
    $(addprefix $(OBJDIR)/,$(POINT_CLOUD_SEQUENTIAL_ENCODER_OBJS:.o=_a.o))
POINT_CLOUD_SEQUENTIAL_DECODER_OBJSA := \
    $(addprefix $(OBJDIR)/,$(POINT_CLOUD_SEQUENTIAL_DECODER_OBJS:.o=_a.o))
POINT_CLOUD_KD_TREE_ENCODER_OBJSA := \
    $(addprefix $(OBJDIR)/,$(POINT_CLOUD_KD_TREE_ENCODER_OBJS:.o=_a.o))
POINT_CLOUD_KD_TREE_DECODER_OBJSA := \
    $(addprefix $(OBJDIR)/,$(POINT_CLOUD_KD_TREE_DECODER_OBJS:.o=_a.o))
MESH_SEQUENTIAL_ENCODER_OBJSA := \
    $(addprefix $(OBJDIR)/,$(MESH_SEQUENTIAL_ENCODER_OBJS:.o=_a.o))
MESH_SEQUENTIAL_DECODER_OBJSA := \
    $(addprefix $(OBJDIR)/,$(MESH_SEQUENTIAL_DECODER_OBJS:.o=_a.o))
MESH_EDGEBREAKER_ENCODER_OBJSA := \
    $(addprefix $(OBJDIR)/,$(MESH_EDGEBREAKER_ENCODER_OBJS:.o=_a.o))
MESH_EDGEBREAKER_DECODER_OBJSA := \
    $(addprefix $(OBJDIR)/,$(MESH_EDGEBREAKER_DECODER_OBJS:.o=_a.o))
ENCODE_OBJSA := $(addprefix $(OBJDIR)/,$(ENCODE_OBJS:.o=_a.o))
EXPERT_ENCODE_OBJSA := $(addprefix $(OBJDIR)/,$(EXPERT_ENCODE_OBJS:.o=_a.o))
DECODE_OBJSA := $(addprefix $(OBJDIR)/,$(DECODE_OBJS:.o=_a.o))

MESH_MISC_OBJSA := $(addprefix $(OBJDIR)/,$(MESH_MISC_OBJS:.o=_a.o))
MESH_ATTRIBUTE_CORNER_TABLE_OBJSA := \
    $(addprefix $(OBJDIR)/,$(MESH_ATTRIBUTE_CORNER_TABLE_OBJS:.o=_a.o))

QUANTIZATION_UTILS_OBJSA := \
    $(addprefix $(OBJDIR)/,$(QUANTIZATION_UTILS_OBJS:.o=_a.o))
CYCLE_TIMER_OBJSA := $(addprefix $(OBJDIR)/,$(CYCLE_TIMER_OBJS:.o=_a.o))

ENCODER_BUFFER_OBJSA := $(addprefix $(OBJDIR)/,$(ENCODER_BUFFER_OBJS:.o=_a.o))
RANS_BIT_DECODER_OBJSA := \
    $(addprefix $(OBJDIR)/,$(RANS_BIT_DECODER_OBJS:.o=_a.o))
RANS_BIT_ENCODER_OBJSA := \
    $(addprefix $(OBJDIR)/,$(RANS_BIT_ENCODER_OBJS:.o=_a.o))
ADAPTIVE_RANS_BIT_DECODER_OBJSA := \
    $(addprefix $(OBJDIR)/,$(ADAPTIVE_RANS_BIT_DECODER_OBJS:.o=_a.o))
ADAPTIVE_RANS_BIT_ENCODER_OBJSA := \
    $(addprefix $(OBJDIR)/,$(ADAPTIVE_RANS_BIT_ENCODER_OBJS:.o=_a.o))
OBJ_DECODER_OBJSA := $(addprefix $(OBJDIR)/,$(OBJ_DECODER_OBJS:.o=_a.o))
MESH_IO_OBJSA := $(addprefix $(OBJDIR)/,$(MESH_IO_OBJS:.o=_a.o))
PLY_ENCODER_OBJSA := $(addprefix $(OBJDIR)/,$(PLY_ENCODER_OBJS:.o=_a.o))
PLY_DECODER_OBJSA := $(addprefix $(OBJDIR)/,$(PLY_DECODER_OBJS:.o=_a.o))

FLOAT_POINTS_TREE_DECODER_OBJSA := \
    $(addprefix $(OBJDIR)/,$(FLOAT_POINTS_TREE_DECODER_OBJS:.o=_a.o))
FLOAT_POINTS_TREE_ENCODER_OBJSA := \
    $(addprefix $(OBJDIR)/,$(FLOAT_POINTS_TREE_ENCODER_OBJS:.o=_a.o))
DYNAMIC_INTEGER_POINTS_KD_TREE_DECODER_OBJSA := \
    $(addprefix $(OBJDIR)/,$(DYNAMIC_INTEGER_POINTS_KD_TREE_DECODER_OBJS:.o=_a.o))
DYNAMIC_INTEGER_POINTS_KD_TREE_ENCODER_OBJSA := \
    $(addprefix $(OBJDIR)/,$(DYNAMIC_INTEGER_POINTS_KD_TREE_ENCODER_OBJS:.o=_a.o))

# Core objs
DRACO_CORE_OBJSA := $(DRACO_TYPES_OBJSA)
DRACO_CORE_OBJSA += $(DIRECT_BIT_DECODER_OBJSA)
DRACO_CORE_OBJSA += $(DIRECT_BIT_ENCODER_OBJSA)
DRACO_CORE_OBJSA += $(RANS_BIT_DECODER_OBJSA)
DRACO_CORE_OBJSA += $(RANS_BIT_ENCODER_OBJSA)
DRACO_CORE_OBJSA += $(ADAPTIVE_RANS_BIT_DECODER_OBJSA)
DRACO_CORE_OBJSA += $(ADAPTIVE_RANS_BIT_ENCODER_OBJSA)

# Shared objs needed for both encoder and decoder
DRACO_SHARED_OBJSA := $(CORNER_TABLE_OBJSA) $(SYMBOL_CODING_OBJSA)
DRACO_SHARED_OBJSA += $(SHANNON_ENTROPY_OBJSA)
DRACO_SHARED_OBJSA += $(DATA_BUFFER_OBJSA) $(DRACO_CORE_OBJSA)
DRACO_SHARED_OBJSA += $(GEOMETRY_ATTRIBUTE_OBJSA)
DRACO_SHARED_OBJSA += $(POINT_ATTRIBUTE_OBJSA)
DRACO_SHARED_OBJSA += $(ATTRIBUTE_OCTAHEDRON_TRANSFORM_OBJSA)
DRACO_SHARED_OBJSA += $(ATTRIBUTE_QUANTIZATION_TRANSFORM_OBJSA)
DRACO_SHARED_OBJSA += $(ATTRIBUTE_TRANSFORM_OBJSA)
DRACO_SHARED_OBJSA += $(POINT_CLOUD_OBJSA)
DRACO_SHARED_OBJSA += $(MESH_OBJSA)
DRACO_SHARED_OBJSA += $(MESH_MISC_OBJSA) $(MESH_ATTRIBUTE_CORNER_TABLE_OBJSA)
DRACO_SHARED_OBJSA += $(METADATA_OBJSA)
DRACO_SHARED_OBJSA += $(GEOMETRY_METADATA_OBJSA)
DRACO_SHARED_OBJSA += $(CYCLE_TIMER_OBJSA)
DRACO_SHARED_OBJSA += $(RANS_BIT_DECODER_OBJSA)
DRACO_SHARED_OBJSA += $(RANS_BIT_ENCODER_OBJSA)
DRACO_SHARED_OBJSA += $(QUANTIZATION_UTILS_OBJSA)

# Encoder specific objs
DRACO_ENCODER_OBJSA := $(OPTIONS_OBJSA)
DRACO_ENCODER_OBJSA += $(POINT_CLOUD_ENCODER_BASE_OBJSA)
DRACO_ENCODER_OBJSA += $(MESH_ENCODER_BASE_OBJSA)
DRACO_ENCODER_OBJSA += $(METADATA_ENCODER_OBJSA)
DRACO_ENCODER_OBJSA += $(SEQUENTIAL_ATTRIBUTE_ENCODER_OBJSA)
DRACO_ENCODER_OBJSA += $(SEQUENTIAL_INTEGER_ATTRIBUTE_ENCODER_OBJSA)
DRACO_ENCODER_OBJSA += $(PREDICTION_SCHEME_ENCODER_FACTORY_OBJSA)
DRACO_ENCODER_OBJSA += $(SEQUENTIAL_QUANTIZATION_ATTRIBUTE_ENCODER_OBJSA)
DRACO_ENCODER_OBJSA += $(SEQUENTIAL_NORMAL_ATTRIBUTE_ENCODER_OBJSA)
DRACO_ENCODER_OBJSA += $(SEQUENTIAL_ATTRIBUTE_ENCODERS_CONTROLLER_OBJSA)
DRACO_ENCODER_OBJSA += $(POINT_CLOUD_SEQUENTIAL_ENCODER_OBJSA)
DRACO_ENCODER_OBJSA += $(POINT_CLOUD_KD_TREE_ENCODER_OBJSA)
DRACO_ENCODER_OBJSA += $(KD_TREE_ATTRIBUTES_ENCODER_OBJSA)
DRACO_ENCODER_OBJSA += $(FLOAT_POINTS_TREE_ENCODER_OBJSA)
DRACO_ENCODER_OBJSA += $(DYNAMIC_INTEGER_POINTS_KD_TREE_ENCODER_OBJSA)
DRACO_ENCODER_OBJSA += $(MESH_SEQUENTIAL_ENCODER_OBJSA)
DRACO_ENCODER_OBJSA += $(MESH_EDGEBREAKER_ENCODER_OBJSA)
DRACO_ENCODER_OBJSA += $(ENCODE_OBJSA)
DRACO_ENCODER_OBJSA += $(EXPERT_ENCODE_OBJSA)
DRACO_ENCODER_OBJSA += $(ENCODER_BUFFER_OBJSA)

# Decoder specific objs
DRACO_DECODER_OBJSA := $(DECODER_BUFFER_OBJSA)
DRACO_DECODER_OBJSA += $(POINT_CLOUD_DECODER_BASE_OBJSA)
DRACO_DECODER_OBJSA += $(MESH_DECODER_BASE_OBJSA)
DRACO_DECODER_OBJSA += $(METADATA_DECODER_OBJSA)
DRACO_DECODER_OBJSA += $(SEQUENTIAL_ATTRIBUTE_DECODER_OBJSA)
DRACO_DECODER_OBJSA += $(SEQUENTIAL_INTEGER_ATTRIBUTE_DECODER_OBJSA)
DRACO_DECODER_OBJSA += $(SEQUENTIAL_QUANTIZATION_ATTRIBUTE_DECODER_OBJSA)
DRACO_DECODER_OBJSA += $(SEQUENTIAL_NORMAL_ATTRIBUTE_DECODER_OBJSA)
DRACO_DECODER_OBJSA += $(SEQUENTIAL_ATTRIBUTE_DECODERS_CONTROLLER_OBJSA)
DRACO_DECODER_OBJSA += $(POINT_CLOUD_SEQUENTIAL_DECODER_OBJSA)
DRACO_DECODER_OBJSA += $(POINT_CLOUD_KD_TREE_DECODER_OBJSA)
DRACO_DECODER_OBJSA += $(KD_TREE_ATTRIBUTES_DECODER_OBJSA)
DRACO_DECODER_OBJSA += $(FLOAT_POINTS_TREE_DECODER_OBJSA)
DRACO_DECODER_OBJSA += $(DYNAMIC_INTEGER_POINTS_KD_TREE_DECODER_OBJSA)
DRACO_DECODER_OBJSA += $(MESH_SEQUENTIAL_DECODER_OBJSA)
DRACO_DECODER_OBJSA += $(MESH_EDGEBREAKER_DECODER_OBJSA)
DRACO_DECODER_OBJSA += $(DECODE_OBJSA)

# I/O objs
DRACO_IO_OBJSA := $(OBJ_DECODER_OBJSA) $(MESH_IO_OBJSA)
DRACO_IO_OBJSA += $(PLY_ENCODER_OBJSA) $(PLY_DECODER_OBJSA)

# All objs
DRACO_OBJSA := $(DRACO_SHARED_OBJSA)
DRACO_OBJSA += $(DRACO_ENCODER_OBJSA)
DRACO_OBJSA += $(DRACO_DECODER_OBJSA)
DRACO_OBJSA += $(DRACO_IO_OBJSA)

OBJSA := $(DRACO_OBJSA)

LIBS := $(LIBDIR)/libmesh_io.a
LIBS += $(LIBDIR)/libply_decoder.a
LIBS += $(LIBDIR)/libply_encoder.a
LIBS += $(LIBDIR)/libobj_decoder.a
LIBS += $(LIBDIR)/libgeometry_attribute.a
LIBS += $(LIBDIR)/libpoint_cloud.a
LIBS += $(LIBDIR)/libpoint_attribute.a
LIBS += $(LIBDIR)/libattribute_octahedron_transform.a
LIBS += $(LIBDIR)/libattribute_quantization_transform.a
LIBS += $(LIBDIR)/libattribute_transform.a
LIBS += $(LIBDIR)/liboptions.a
LIBS += $(LIBDIR)/libencode.a
LIBS += $(LIBDIR)/libexpert_encode.a
LIBS += $(LIBDIR)/libdecode.a
LIBS += $(LIBDIR)/libmesh.a
LIBS += $(LIBDIR)/libmesh_decoder_base.a
LIBS += $(LIBDIR)/libpoint_cloud_sequential_decoder.a
LIBS += $(LIBDIR)/libpoint_cloud_kd_tree_decoder.a
LIBS += $(LIBDIR)/libkd_tree_attributes_decoder.a
LIBS += $(LIBDIR)/libmesh_sequential_decoder.a
LIBS += $(LIBDIR)/libmesh_edgebreaker_decoder.a
LIBS += $(LIBDIR)/libsequential_attribute_decoders_controller.a
LIBS += $(LIBDIR)/libpoint_cloud_decoder_base.a
LIBS += $(LIBDIR)/libsequential_integer_attribute_decoder.a
LIBS += $(LIBDIR)/libsequential_attribute_decoder.a
LIBS += $(LIBDIR)/libsequential_quantization_attribute_decoder.a
LIBS += $(LIBDIR)/libsequential_normal_attribute_decoder.a
LIBS += $(LIBDIR)/libquantization_utils.a
LIBS += $(LIBDIR)/libmesh_encoder_base.a
LIBS += $(LIBDIR)/libpoint_cloud_sequential_encoder.a
LIBS += $(LIBDIR)/libpoint_cloud_kd_tree_encoder.a
LIBS += $(LIBDIR)/libkd_tree_attributes_encoder.a
LIBS += $(LIBDIR)/libmesh_sequential_encoder.a
LIBS += $(LIBDIR)/libmesh_edgebreaker_encoder.a
LIBS += $(LIBDIR)/libsequential_attribute_encoder.a
LIBS += $(LIBDIR)/libsequential_attribute_encoders_controller.a
LIBS += $(LIBDIR)/libpoint_cloud_encoder_base.a
LIBS += $(LIBDIR)/libsequential_integer_attribute_encoder.a
LIBS += $(LIBDIR)/libsequential_quantization_attribute_encoder.a
LIBS += $(LIBDIR)/libsequential_normal_attribute_encoder.a
LIBS += $(LIBDIR)/libcorner_table.a
LIBS += $(LIBDIR)/libmesh_attribute_corner_table.a
LIBS += $(LIBDIR)/libmesh_misc.a
LIBS += $(LIBDIR)/libshannon_entropy.a
LIBS += $(LIBDIR)/libsymbol_coding.a
LIBS += $(LIBDIR)/librans_bit_decoder.a
LIBS += $(LIBDIR)/librans_bit_encoder.a
LIBS += $(LIBDIR)/libdata_buffer.a
LIBS += $(LIBDIR)/libdraco_types.a
LIBS += $(LIBDIR)/libmetadata.a
LIBS += $(LIBDIR)/libgeometry_metadata.a
LIBS += $(LIBDIR)/libmetadata_encoder.a
LIBS += $(LIBDIR)/libmetadata_decoder.a
LIBS += $(LIBDIR)/libdecoder_buffer.a
LIBS += $(LIBDIR)/libencoder_buffer.a
LIBS += $(LIBDIR)/libcycle_timer.a

POINTS_LIBS := $(LIBDIR)/libfloat_points_tree_decoder.a
POINTS_LIBS += $(LIBDIR)/libfloat_points_tree_encoder.a
POINTS_LIBS += $(LIBDIR)/libdynamic_integer_points_kd_tree_decoder.a
POINTS_LIBS += $(LIBDIR)/libdynamic_integer_points_kd_tree_encoder.a
POINTS_LIBS += $(LIBDIR)/libdirect_bit_decoder.a
POINTS_LIBS += $(LIBDIR)/libdirect_bit_encoder.a
POINTS_LIBS += $(LIBDIR)/libadaptive_rans_bit_decoder.a
POINTS_LIBS += $(LIBDIR)/libadaptive_rans_bit_encoder.a

DEPS  := $(DRACO_OBJSA:_a.o=.d)
CLEAN := $(DEPS) $(OBJSA) $(LIBS) $(POINTS_LIBS)
CLEAN += glue_encoder.cpp glue_encoder.js draco_encoder.js WebIDLGrammar.pkl parser.out
CLEAN += $(OBJDIR)/javascript/emscripten/draco_encoder_glue_wrapper.o $(OBJDIR)/javascript/emscripten/draco_encoder_glue_wrapper.d
CLEAN += $(OBJDIR)/javascript/emscripten/encoder_webidl_wrapper.o $(OBJDIR)/javascript/emscripten/encoder_webidl_wrapper.d

all: jslib

jslib: build_glue draco_encoder

build_glue:
	python $(BINDER) $(IDL) glue_encoder

draco_encoder: $(OBJDIR)/javascript/emscripten/draco_encoder_glue_wrapper.o $(OBJDIR)/javascript/emscripten/encoder_webidl_wrapper.o $(DRACO_CORE_OBJSA) $(DRACO_SHARED_OBJSA) $(DRACO_ENCODER_OBJSA)
	$(CXX) $(ALL_C_OPTS) $^ --pre-js $(SRCDIR)/javascript/emscripten/prepareCallbacks.js --pre-js $(SRCDIR)/javascript/emscripten/version.js --post-js glue_encoder.js --post-js $(SRCDIR)/javascript/emscripten/finalize.js -o $@.js

$(LIBDIR)/libcorner_table.a: $(CORNER_TABLE_OBJSA)
	$(AR) rcs $@ $^

$(LIBDIR)/libshannon_entropy.a: $(SHANNON_ENTROPY_OBJSA)
	$(AR) rcs $@ $^

$(LIBDIR)/libsymbol_coding.a: $(SYMBOL_CODING_OBJSA)
	$(AR) rcs $@ $^

$(LIBDIR)/libdirect_bit_decoder.a: $(DIRECT_BIT_DECODER_OBJSA)
	$(AR) rcs $@ $^

$(LIBDIR)/libdirect_bit_encoder.a: $(DIRECT_BIT_ENCODER_OBJSA)
	$(AR) rcs $@ $^

$(LIBDIR)/libdecoder_buffer.a: $(DECODER_BUFFER_OBJSA)
	$(AR) rcs $@ $^

$(LIBDIR)/libdata_buffer.a: $(DATA_BUFFER_OBJSA)
	$(AR) rcs $@ $^

$(LIBDIR)/libdraco_types.a: $(DRACO_TYPES_OBJSA)
	$(AR) rcs $@ $^

$(LIBDIR)/libmetadata.a: $(MEATDATA_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libgeometry_metadata.a: $(GEOMETRY_MEATDATA_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libmetadata_encoder.a: $(MEATDATA_ENCODER_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libmetadata_decoder.a: $(MEATDATA_DECODER_OBJSA)
	$(AR) rcs $@ $^

$(LIBDIR)/libgeometry_attribute.a: $(GEOMETRY_ATTRIBUTE_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libpoint_attribute.a: $(POINT_ATTRIBUTE_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libattribute_octahedron_transform.a: $(ATTRIBUTE_OCTAHEDRON_TRANSFORM_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libattribute_quantization_transform.a: $(ATTRIBUTE_QUANTIZATION_TRANSFORM_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libattribute_transform.a: $(ATTRIBUTE_TRANSFORM_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libpoint_cloud.a: $(POINT_CLOUD_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libmesh.a: $(MESH_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/liboptions.a: $(OPTIONS_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libpoint_cloud_encoder_base.a: $(POINT_CLOUD_ENCODER_BASE_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libpoint_cloud_decoder_base.a: $(POINT_CLOUD_DECODER_BASE_OBJSA)
	$(AR) rcs $@ $^

$(LIBDIR)/libmesh_encoder_base.a: $(MESH_ENCODER_BASE_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libmesh_decoder_base.a: $(MESH_DECODER_BASE_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libsequential_attribute_encoder.a: \
    $(SEQUENTIAL_ATTRIBUTE_ENCODER_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libsequential_attribute_decoder.a: \
    $(SEQUENTIAL_ATTRIBUTE_DECODER_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libsequential_integer_attribute_encoder.a: \
    $(SEQUENTIAL_INTEGER_ATTRIBUTE_ENCODER_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libpredicion_scheme_encoder_factory.a: \
    $(PREDICTION_SCHEME_ENCODER_FACTORY_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libsequential_integer_attribute_decoder.a: \
    $(SEQUENTIAL_INTEGER_ATTRIBUTE_DECODER_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libsequential_quantization_attribute_encoder.a: \
    $(SEQUENTIAL_QUANTIZATION_ATTRIBUTE_ENCODER_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libsequential_quantization_attribute_decoder.a: \
    $(SEQUENTIAL_QUANTIZATION_ATTRIBUTE_DECODER_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libkd_tree_attributes_encoder.a: $(KD_TREE_ATTRIBUTES_ENCODER_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libkd_tree_attributes_decoder.a: $(KD_TREE_ATTRIBUTES_DECODER_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libsequential_normal_attribute_encoder.a: \
    $(SEQUENTIAL_NORMAL_ATTRIBUTE_ENCODER_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libsequential_normal_attribute_decoder.a: \
    $(SEQUENTIAL_NORMAL_ATTRIBUTE_DECODER_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libsequential_attribute_encoders_controller.a: \
    $(SEQUENTIAL_ATTRIBUTE_ENCODERS_CONTROLLER_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libsequential_attribute_decoders_controller.a: \
    $(SEQUENTIAL_ATTRIBUTE_DECODERS_CONTROLLER_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libpoint_cloud_sequential_encoder.a: \
    $(POINT_CLOUD_SEQUENTIAL_ENCODER_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libpoint_cloud_sequential_decoder.a: \
    $(POINT_CLOUD_SEQUENTIAL_DECODER_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libpoint_cloud_kd_tree_encoder.a: \
    $(POINT_CLOUD_KD_TREE_ENCODER_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libpoint_cloud_kd_tree_decoder.a: \
    $(POINT_CLOUD_KD_TREE_DECODER_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libmesh_sequential_encoder.a: $(MESH_SEQUENTIAL_ENCODER_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libmesh_sequential_decoder.a: $(MESH_SEQUENTIAL_DECODER_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libmesh_edgebreaker_encoder.a: $(MESH_EDGEBREAKER_ENCODER_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libmesh_edgebreaker_decoder.a: $(MESH_EDGEBREAKER_DECODER_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libencode.a: $(ENCODE_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libencode.a: $(EXPERT_ENCODE_OBJSA)
	$(AR) rcs $@ $^
$(LIBDIR)/libdecode.a: $(DECODE_OBJSA)
	$(AR) rcs $@ $^

$(LIBDIR)/libmesh_misc.a: $(MESH_MISC_OBJSA)
	$(AR) rcs $@ $^

$(LIBDIR)/libmesh_attribute_corner_table.a: $(MESH_ATTRIBUTE_CORNER_TABLE_OBJSA)
	$(AR) rcs $@ $^

$(LIBDIR)/libencoder_buffer.a: $(ENCODER_BUFFER_OBJSA)
	$(AR) rcs $@ $^

$(LIBDIR)/libquantization_utils.a: $(QUANTIZATION_UTILS_OBJSA)
	$(AR) rcs $@ $^

$(LIBDIR)/libcycle_timer.a: $(CYCLE_TIMER_OBJSA)
	$(AR) rcs $@ $^

$(LIBDIR)/librans_bit_decoder.a: $(RANS_BIT_DECODER_OBJSA)
	$(AR) rcs $@ $^

$(LIBDIR)/librans_bit_encoder.a: $(RANS_BIT_ENCODER_OBJSA)
	$(AR) rcs $@ $^

$(LIBDIR)/libadaptive_rans_bit_decoder.a: $(ADAPTIVE_RANS_BIT_DECODER_OBJSA)
	$(AR) rcs $@ $^

$(LIBDIR)/libadaptive_rans_bit_encoder.a: $(ADAPTIVE_RANS_BIT_ENCODER_OBJSA)
	$(AR) rcs $@ $^

$(LIBDIR)/libobj_decoder.a: $(OBJ_DECODER_OBJSA)
	$(AR) rcs $@ $^

$(LIBDIR)/libmesh_io.a: $(MESH_IO_OBJSA)
	$(AR) rcs $@ $^

$(LIBDIR)/libply_encoder.a: $(PLY_ENCODER_OBJSA)
	$(AR) rcs $@ $^

$(LIBDIR)/libply_decoder.a: $(PLY_DECODER_OBJSA)
	$(AR) rcs $@ $^

$(LIBDIR)/libfloat_points_tree_decoder.a: $(FLOAT_POINTS_TREE_DECODER_OBJSA)
	$(AR) rcs $@ $^

$(LIBDIR)/libfloat_points_tree_encoder.a: $(FLOAT_POINTS_TREE_ENCODER_OBJSA)
	$(AR) rcs $@ $^

$(LIBDIR)/libdynamic_integer_points_kd_tree_decoder.a: \
    $(DYNAMIC_INTEGER_POINTS_KD_TREE_DECODER_OBJSA)
	$(AR) rcs $@ $^

$(LIBDIR)/libdynamic_integer_points_kd_tree_encoder.a: \
    $(DYNAMIC_INTEGER_POINTS_KD_TREE_ENCODER_OBJSA)
	$(AR) rcs $@ $^

$(OBJDIR)/%.o: $(SRCDIR)/%.cc
	@mkdir -p $(@D)
	$(CXX) $(ALL_CXXFLAGS) $< -o $@

$(OBJDIR)/%_a.o: $(SRCDIR)/%.cc
	@mkdir -p $(@D)
	$(CXX) $(ALL_CXXFLAGS) $< -o $@

clean:
	$(RM) $(CLEAN)
