TARGET_NAME = mpg123
LIBS += libc
include_rules

SOURCE_LINK = port-source
API_LINK = port-api

: |> $(NIX_BUILD) .. --out-link port \
	--attr %d.source --attr %d.api |> $(SOURCE_LINK) $(API_LINK) {port}

: $(API_LINK) |> cp %f/pkg-config/%d.pc %o \
	|> $(PKG_CONFIG_DIR)/%d.pc $(GENODE_DIR)/<pkg-config>

: mpg123.symbols |> !abi_stub |>

INCLUDES += -I.
INCLUDES += -I$(SOURCE_LINK)/src/libmpg123
INCLUDES += -I$(SOURCE_LINK)/src/compat
INCLUDES += -I$(SOURCE_LINK)/src
INCLUDES += -I$(API_LINK)/include

ifeq (@(TUP_ARCH),x86_64)
	DEFINES += -DOPT_X86_64
	run ./port_rules.sh $(SOURCE_LINK) common.files x86_64.files
endif

ifeq (@(TUP_ARCH),arm)
	DEFINES += -DOPT_ARM
	run ./port_rules.sh $(SOURCE_LINK) common.files arm.files
endif

: {obj} |> !lib |> %d.lib.so {bin}
: {bin} |> !collect_bin |>

include &(BIN_RULES)
