Packages
glazer
0.1.6
0.5.17
0.5.16
0.5.15
0.5.14
retired
0.5.13
retired
0.5.12
retired
0.5.11
retired
0.5.10
retired
0.5.9
retired
0.5.8
retired
0.5.7
retired
0.5.6
retired
0.5.5
retired
0.5.4
retired
0.5.3
retired
0.5.2
retired
0.5.1
retired
0.5.0
retired
0.3.2
retired
0.3.0
retired
0.2.6
retired
0.2.5
retired
0.2.4
retired
0.2.3
retired
0.2.2
retired
0.2.1
retired
0.2.0
retired
0.1.7
retired
0.1.6
retired
0.1.5
retired
0.1.4
retired
Erlang NIF JSON encoder/decoder using the glaze C++ library
Retired package: Deprecated - Deprecated
Current section
Files
Jump to
Current section
Files
c_src/Makefile
CURDIR := $(shell pwd)
BASEDIR := $(abspath $(dir $(CURDIR)))
CXX ?= g++
PRIV_DIR ?= $(if $(REBAR_BARE_COMPILER_OUTPUT_DIR),$(REBAR_BARE_COMPILER_OUTPUT_DIR),$(BASEDIR))/priv
OBJ_DIR ?= $(BASEDIR)/obj
DEBUG ?= 0
SRC := glaze_nif.cpp
OBJ := $(OBJ_DIR)/glaze_nif.o
TARGET := $(PRIV_DIR)/glazer.so
ERL_ERTS_INCLUDE := $(shell erl -noshell -noinput \
-eval "io:format(\"~ts/erts-~ts/include\",[code:root_dir(),erlang:system_info(version)]),halt(0).")
ERL_EI_INCLUDE := $(shell erl -noshell -noinput \
-eval "io:format(\"~ts\",[code:lib_dir(erl_interface,include)]),halt(0).")
ERL_EI_LIB := $(shell erl -noshell -noinput \
-eval "io:format(\"~ts\",[code:lib_dir(erl_interface,lib)]),halt(0).")
CXXFLAGS := -std=c++23 -fPIC -Wall -finline-functions \
-I$(ERL_ERTS_INCLUDE) -I$(ERL_EI_INCLUDE) -I.
# Detect compiler family for LTO flags.
# AppleClang uses ld64 which handles thin-LTO natively — no -fuse-ld=lld.
# Upstream Clang on Linux emits LLVM bitcode that requires lld.
# GCC uses -flto=auto with GNU ld/gold.
CXX_ID := $(shell $(CXX) --version 2>&1 | head -1)
ifneq ($(findstring Apple,$(CXX_ID)),)
LTO_FLAGS := -flto=thin
LINK_FLAGS :=
else ifneq ($(findstring clang,$(CXX_ID)),)
LTO_FLAGS := -flto=thin
LINK_FLAGS := -fuse-ld=lld
else
LTO_FLAGS := -flto=auto -fno-fat-lto-objects
LINK_FLAGS :=
endif
ifeq ($(DEBUG),1)
CXXFLAGS += -O0 -g
else
CXXFLAGS += -O3 -DNDEBUG -march=native -mtune=native $(LTO_FLAGS)
LDFLAGS += $(LINK_FLAGS)
endif
LDFLAGS += -shared -L$(ERL_EI_LIB) -lei
ifeq ($(shell uname -s),Darwin)
LDFLAGS += -undefined dynamic_lookup
endif
.PHONY: all clean
all: $(TARGET)
$(TARGET): $(OBJ) | $(PRIV_DIR)
$(CXX) $(OBJ) $(LDFLAGS) -o $@
$(OBJ): $(SRC) | $(OBJ_DIR)
$(CXX) $(CXXFLAGS) -c $< -o $@
$(PRIV_DIR) $(OBJ_DIR):
@mkdir -p $@
clean:
rm -f $(OBJ) $(TARGET)