1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
|
# Python interface Makefile
#
# Part of the Routino routing software.
#
# This file Copyright 2018, 2019, 2023 Andrew M. Bishop
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# All configuration is in the top-level Makefile.conf
include ../Makefile.conf
# Programs
PYTHON=python3
SWIG=swig
# Compilation targets
PY_FILES=$(wildcard src/*.py)
C_FILES=$(wildcard src/*.c)
CC_FILES=$(wildcard src/*.cc)
SWIG_C=src/_router.c
SWIG_CC=src/_database.cc
SWIG_PY=src/router.py src/database.py
ifneq ($(HOST),MINGW)
LIBROUTINO=../src/libroutino.so
else
LIBROUTINO=../src/routino.dll
endif
BUILD_TIMESTAMP=build/.timestamp
# Check that we have Python3 and swig installed
# Note: We need to use swig here and not have it called from setup.py because
# setuptools copies 'py_modules' before building 'ext_modules' so will
# miss the python files that are generated by swig.
HAVE_PYTHON=$(shell $(PYTHON) --version 2> /dev/null)
HAVE_SWIG=$(shell $(SWIG) -version 2> /dev/null)
ifeq ($(HAVE_PYTHON),)
$(warning Python3 not installed - skipping Python module creation)
endif
ifeq ($(HAVE_SWIG),)
$(warning Swig not installed - skipping Python module creation)
endif
########
all: $(and $(HAVE_SWIG),$(HAVE_PYTHON),all-if-python)
all-if-python: $(BUILD_TIMESTAMP)
########
$(BUILD_TIMESTAMP): $(SWIG_C) $(SWIG_CC) $(SWIG_PY) $(PY_FILES) $(C_FILES) $(CC_FILES) $(LIBROUTINO) setup.py
@rm -f $@
CFLAGS= LDFLAGS= $(PYTHON) setup.py build && touch $(BUILD_TIMESTAMP)
src/_router.c : src/router.i ../src/routino.h
$(SWIG) -python -o $@ $<
src/router.py : src/_router.c
@true # fake rule since src/router.py is created by the same rule as src/_router.c
src/_database.cc : src/database.i src/database.hh
$(SWIG) -c++ -python -o $@ $<
src/database.py : src/_database.cc
@true # fake rule since src/database.py is created by the same rule as src/_database.cc
$(LIBROUTINO):
cd ../src && $(MAKE) all-lib
########
test: $(and $(HAVE_SWIG),$(HAVE_PYTHON),test-if-python)
test-if-python: $(BUILD_TIMESTAMP)
cd test && $(MAKE) test
########
install: $(and $(HAVE_SWIG),$(HAVE_PYTHON),install-if-python)
install-if-python: all
@echo "WARNING: '$(PYTHON) setup.py install' is not supported by Python v3.10 and above."
@echo "WARNING: This Makefile therefore no longer tries to install the Routino module."
@echo "WARNING: You could try this to install it but it might not work on your system:"
@echo "WARNING: $(PYTHON) -m pip $(DESTDIR)$(prefix)"
@echo "WARNING: You could try this to build a Python 'wheel' and install that manually:"
@echo "WARNING: $(PYTHON) -m build --wheel"
-@false
########
clean: clean-local
cd test && $(MAKE) $@
clean-local:
rm -f *~
rm -rf build
rm -rf dist
rm -rf Routino.egg-info
rm -f $(SWIG_C)
rm -f $(SWIG_CC)
rm -f $(SWIG_PY)
########
distclean: distclean-local
cd test && $(MAKE) $@
distclean-local: clean-local
########
.PHONY:: all test install clean distclean
.PHONY:: all-if-python test-if-python install-if-python
.PHONY:: clean-local distclean-local
|