From 1d8c6ab7b5cb837f8aa5f2d5ae8976ffa3c88c26 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Fri, 2 Nov 2018 16:47:57 -0700 Subject: [PATCH] Makefile updates from p4p --- configure/CONFIG_PY | 39 ++++++++++++++++++++++++--------------- configure/CONFIG_SITE | 2 +- configure/Makefile | 9 ++++----- makehelper.py | 26 +++++++++++++++++++++----- 4 files changed, 50 insertions(+), 26 deletions(-) diff --git a/configure/CONFIG_PY b/configure/CONFIG_PY index 5e2ea78..f2edef8 100644 --- a/configure/CONFIG_PY +++ b/configure/CONFIG_PY @@ -2,24 +2,22 @@ ifneq ($(T_A),) PYMODULE ?= YES -ifeq ($(PY_VER),) -$(error Must set PY_VER to select a python version) +ifeq ($(PYTHON),) +$(error Must set PYTHON to select a python version) endif --include $(dir $(lastword $(MAKEFILE_LIST)))/os/CONFIG_PY$(PY_VER).$(EPICS_HOST_ARCH).Common --include $(dir $(lastword $(MAKEFILE_LIST)))/os/CONFIG_PY$(PY_VER).Common.$(T_A) --include $(dir $(lastword $(MAKEFILE_LIST)))/os/CONFIG_PY$(PY_VER).$(EPICS_HOST_ARCH).$(T_A) +-include $(dir $(lastword $(MAKEFILE_LIST)))/os/CONFIG_PY.$(EPICS_HOST_ARCH).Common +-include $(dir $(lastword $(MAKEFILE_LIST)))/os/CONFIG_PY.Common.$(T_A) +-include $(dir $(lastword $(MAKEFILE_LIST)))/os/CONFIG_PY.$(EPICS_HOST_ARCH).$(T_A) --include $(dir $(lastword $(MAKEFILE_LIST)))/os/CONFIG_SITE_PY$(PY_VER).$(EPICS_HOST_ARCH).Common --include $(dir $(lastword $(MAKEFILE_LIST)))/os/CONFIG_SITE_PY$(PY_VER).Common.$(T_A) --include $(dir $(lastword $(MAKEFILE_LIST)))/os/CONFIG_SITE_PY$(PY_VER).$(EPICS_HOST_ARCH).$(T_A) +-include $(dir $(lastword $(MAKEFILE_LIST)))/os/CONFIG_SITE_PY.$(EPICS_HOST_ARCH).Common +-include $(dir $(lastword $(MAKEFILE_LIST)))/os/CONFIG_SITE_PY.Common.$(T_A) +-include $(dir $(lastword $(MAKEFILE_LIST)))/os/CONFIG_SITE_PY.$(EPICS_HOST_ARCH).$(T_A) ifneq ($(PY_OK),YES) -$(error No usable configuration for python$(PY_VER)) +$(error No usable configuration for $(PYTHON)) endif -PYTHON ?= python$(PY_VER) - SHRLIB_DEPLIB_DIRS += $(PY_LIBDIRS) PROD_DEPLIB_DIRS += $(PY_LIBDIRS) @@ -27,18 +25,29 @@ INCLUDES += $(PY_INCDIRS:%=-I%) ifeq ($(HAVE_NUMPY),YES) TARGET_CPPFLAGS += -DHAVE_NUMPY +else +$(error numpy required) endif -LIB_SYS_LIBS += python$(PY_LD_VER) -PROD_SYS_LIBS += python$(PY_LD_VER) +#LIB_SYS_LIBS += python$(PY_LD_VER) +#PROD_SYS_LIBS += python$(PY_LD_VER) -PY_INSTALL_DIR = $(INSTALL_LOCATION)/python$(PY_VER)/$(T_A) +PY_INSTALL_DIR = $(INSTALL_LOCATION)/python$(PY_LD_VER)/$(T_A) + +ifneq ($(PYMODULE),NO) # Python loadables have no prefix (eg 'pymod.so') # and are installed alongsize .py files LOADABLE_SHRLIB_PREFIX = -ifneq ($(PYMODULE),NO) + INSTALL_SHRLIB = $(PY_INSTALL_DIR) + +ifeq ($(OS_CLASS),Darwin) +# need -undefined dynamic_lookup +LOADABLE_SHRLIB_LDFLAGS = -bundle -flat_namespace -undefined dynamic_lookup +LOADABLE_SHRLIB_SUFFIX = .so +endif + endif endif diff --git a/configure/CONFIG_SITE b/configure/CONFIG_SITE index 559e2d8..11ed558 100644 --- a/configure/CONFIG_SITE +++ b/configure/CONFIG_SITE @@ -37,7 +37,7 @@ PY_VER=2.7 # Module will be build against this version of the # Python interpreter -#PYTHON = python$(PY_VER) +PYTHON ?= python$(PY_VER) -include $(TOP)/configure/CONFIG_SITE.local -include $(TOP)/../CONFIG_SITE.local diff --git a/configure/Makefile b/configure/Makefile index 4ab05b9..deec5c9 100644 --- a/configure/Makefile +++ b/configure/Makefile @@ -2,20 +2,19 @@ TOP=.. include $(TOP)/configure/CONFIG -ifeq ($(PY_VER),) -$(error Must set PY_VER to select a python version) -endif PYTHON ?= python$(PY_VER) TARGETS = $(CONFIG_TARGETS) ifdef T_A -CONFIGS = CONFIG_PY RULES_PY os/CONFIG_PY$(PY_VER).Common.$(T_A) +CONFIGS = CONFIG_PY RULES_PY os/CONFIG_PY.Common.$(T_A) endif +CONFIGS += $(subst ../,,$(wildcard $(CONFIG_INSTALLS))) + include $(TOP)/configure/RULES -os/CONFIG_PY$(PY_VER).Common.$(T_A): $(TOP)/makehelper.py +os/CONFIG_PY.Common.$(T_A): $(TOP)/makehelper.py [ -d $(dir $@) ] || $(MKDIR) $(dir $@) $(PYTHON) $< $@ diff --git a/makehelper.py b/makehelper.py index c7bdc41..6ce8b8a 100644 --- a/makehelper.py +++ b/makehelper.py @@ -28,23 +28,39 @@ libdirs = [get_config_var('LIBDIR')] have_np='NO' try: from numpy.distutils.misc_util import get_numpy_include_dirs - incdirs += get_numpy_include_dirs() + incdirs = get_numpy_include_dirs()+incdirs have_np='YES' except ImportError: pass -incdirs = [get_python_inc()]+get_numpy_include_dirs() -libdirs = [get_config_var('LIBDIR')] - print('TARGET_CFLAGS +=',get_config_var('BASECFLAGS'), file=out) print('TARGET_CXXFLAGS +=',get_config_var('BASECFLAGS'), file=out) print('PY_VER :=',get_config_var('VERSION'), file=out) -print('PY_LD_VER :=',get_config_var('LDVERSION') or get_config_var('VERSION'), file=out) +ldver = get_config_var('LDVERSION') +if ldver is None: + ldver = get_config_var('VERSION') + if get_config_var('Py_DEBUG'): + ldver = ldver+'_d' +print('PY_LD_VER :=',ldver, file=out) print('PY_INCDIRS :=',' '.join(incdirs), file=out) print('PY_LIBDIRS :=',' '.join(libdirs), file=out) print('HAVE_NUMPY :=',have_np, file=out) +try: + import asyncio +except ImportError: + print('HAVE_ASYNCIO := NO', file=out) +else: + print('HAVE_ASYNCIO := YES', file=out) + +try: + import cothread +except ImportError: + print('HAVE_COTHREAD := NO', file=out) +else: + print('HAVE_COTHREAD := YES', file=out) + print('PY_OK := YES', file=out) out.close()