Packages

A semi-useful tool to generate boilerplate when you want to use a NIF in your project. You don't really want to use a NIF in your project, until you do. Then this might save you writing most of the boilerplate.

Current section

Files

Jump to
nifty templates Makefile.eex
Raw

templates/Makefile.eex

ERLANG_PATH = $(shell erl -eval 'io:format("~s", [lists:concat([code:root_dir(), "/erts-", erlang:system_info(version), "/include"])])' -s init stop -noshell)
CFLAGS = -g -O3 -pedantic -Wall -Wextra -I$(ERLANG_PATH)
ifneq ($(OS),Windows_NT)
CFLAGS += -fPIC
ifeq ($(shell uname),Darwin)
LDFLAGS += -dynamiclib -undefined dynamic_lookup
endif
endif
priv/lib/lib_<%= name %>.so: clean
@$(CC) $(CFLAGS) -shared $(LDFLAGS) -o $@ c_src/<%= name %>_nif.c
clean:
@$(RM) -r priv/lib/*