Packages

Alsa libasound2 bindings

Retired package: Release invalid - env.mk was incorrectly included in the package which caused compilation to fail

Current section

Files

Jump to
alsa c_src nif Makefile
Raw

c_src/nif/Makefile

CURDIR := $(shell pwd)
BASEDIR := $(abspath $(CURDIR)/../..)
ERL ?= erl
PKG_CONFIG ?= pkg-config
# System specific C compiler/flags.
UNAME_SYS := $(shell uname -s)
ifeq ($(UNAME_SYS), Darwin)
CC ?= cc
CFLAGS ?= -O2 -arch x86_64 -finline-functions -Wall -Wmissing-prototypes
LDFLAGS ?= -arch x86_64 -flat_namespace -undefined suppress
else ifeq ($(UNAME_SYS), FreeBSD)
CC ?= cc
CFLAGS ?= -O2 -finline-functions -Wall -Wmissing-prototypes
else ifeq ($(UNAME_SYS), Linux)
CC ?= gcc
CFLAGS ?= -O2 -finline-functions -Wall -Wmissing-prototypes
endif
# Project specific C compiler/flags.
ifeq ($(ERTS_INCLUDE_DIR),)
ERTS_INCLUDE_DIR := $(shell "$(ERL)" -noshell -s init stop -eval "io:format(\"~ts/erts-~ts/include/\", [code:root_dir(), erlang:system_info(version)]).")
endif
CFLAGS += -std=gnu11 -fPIC -I $(ERTS_INCLUDE_DIR)
CFLAGS += $(shell $(PKG_CONFIG) --cflags alsa)
LDFLAGS += -shared
LDFLAGS += $(shell $(PKG_CONFIG) --libs alsa)
# Verbosity.
V ?= 0
c_verbose_0 = @echo " C " $(@F);
c_verbose = $(c_verbose_$(V))
link_verbose_0 = @echo " LD " $(@F);
link_verbose = $(link_verbose_$(V))
# Files
HEADERS := $(wildcard *.h)
# Rules
.PHONY: install
install: _build/alsa_pcm_nif.so _build/alsa_ctl_nif.so | $(BASEDIR)/priv/
cp $^ $(BASEDIR)/priv
.PHONY: all
all: _build/alsa_pcm_nif.so _build/alsa_ctl_nif.so
_build/%.so: _build/%.o $(MAKEFILE_LIST) | _build/
$(link_verbose) $(CC) "$<" $(LDFLAGS) -o "$@"
_build/%.o: %.c $(HEADERS) $(MAKEFILE_LIST) | _build/
$(c_verbose) $(CC) $(CFLAGS) $(CPPFLAGS) -c "$<" -o "$@"
_build/:
mkdir -p "$@"
$(BASEDIR)/priv/:
mkdir -p "$@"
.PHONY: clean
clean:
rm -f "$(BASEDIR)/priv/alsa_pcm_nif.so"
rm -f "$(BASEDIR)/priv/alsa_ctl_nif.so"
rm -Rf "_build/"