pygomx/pygomx-module/Makefile

79 lines
1.5 KiB
Makefile
Raw Normal View History

2026-02-13 14:46:36 +01:00
# set some defaults
# one of static, shared
2026-02-24 08:45:16 +01:00
BUILD_MODE ?= static
2026-02-13 14:46:36 +01:00
# one of none, colm, goolm, vodozemac
2026-02-24 09:51:20 +01:00
OLM_FLAVOR ?= colm
2026-02-13 14:46:36 +01:00
2026-02-21 13:10:45 +01:00
ifndef GO_TAGS
GO_TAGS =
else
2026-02-24 08:45:16 +01:00
GO_TAGS := $(GO_TAGS),
2026-02-21 13:10:45 +01:00
endif
2026-02-24 09:51:20 +01:00
ifeq ($(OLM_FLAVOR),none)
2026-02-24 08:45:16 +01:00
GO_TAGS := $(GO_TAGS)nocrypto
2026-02-24 09:51:20 +01:00
else ifeq ($(OLM_FLAVOR),colm)
2026-02-24 08:45:16 +01:00
GO_TAGS := $(GO_TAGS)colm
2026-02-24 09:51:20 +01:00
else ifeq ($(OLM_FLAVOR),goolm)
2026-02-24 08:45:16 +01:00
GO_TAGS := $(GO_TAGS)goolm
2026-02-24 09:51:20 +01:00
else ifeq ($(OLM_FLAVOR),vodozemac)
2026-02-24 08:45:16 +01:00
GO_TAGS := $(GO_TAGS)vodozemac
2026-02-21 13:10:45 +01:00
else
2026-02-24 09:51:20 +01:00
$(error unknown OLM_FLAVOR $(OLM_FLAVOR))
2026-02-21 13:10:45 +01:00
endif
2026-02-13 14:46:36 +01:00
# calculate configuration matrix
ifeq ($(BUILD_MODE),static)
build_mode_name=c-archive
build_mode_ext=a
else ifeq ($(BUILD_MODE),shared)
build_mode_name=c-shared
build_mode_ext=so
else
$(error unknown BUILD_MODE $(BUILD_MODE))
endif
link_list =
ifeq ($(BUILD_MODE),static)
2026-02-24 09:51:20 +01:00
ifeq ($(OLM_FLAVOR),colm)
2026-02-13 14:46:36 +01:00
link_list += olm
endif
endif
2026-02-10 00:08:30 +01:00
SOURCE_GO=$(shell find ../libmxclient/ -iname "*.go")
2026-02-13 14:46:36 +01:00
ifndef GO_OUTDIR
GO_OUTDIR = ../pygomx-module
endif
2026-02-10 00:08:30 +01:00
.PHONY:
all: _pygomx.o libmxclient.h
mkdir -p build/lib
cp *.so build/lib
_pygomx.o: libmxclient.h build_ffi.py
2026-02-13 14:46:36 +01:00
python3 build_ffi.py $(link_list)
2026-02-10 00:08:30 +01:00
libmxclient.h: ../libmxclient/go.mod ../libmxclient/go.sum $(SOURCE_GO)
cd ../libmxclient/ && \
2026-02-21 13:10:45 +01:00
CGO_ENABLED=1 go build -buildmode=$(build_mode_name) -tags $(GO_TAGS) -o $(GO_OUTDIR)/libmxclient.$(build_mode_ext) .
2026-02-10 00:08:30 +01:00
.PHONY:
clean:
2026-02-24 08:45:16 +01:00
@rm -f _pygomx.*
@rm -f libmxclient.*
@rm -rf dist/
@rm -rf build/
@rm -rf pygomx_module.egg-info
2026-02-10 00:08:30 +01:00
.PHONY:
install: all
python setup.py bdist_wheel
python setup.py install