From 6c0abcb890e1720c12ee9bc6a5e3fd74c28615c4 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sat, 30 Mar 2013 11:26:07 -0400 Subject: [PATCH] update make config --- configure/CONFIG_SITE | 2 ++ configure/Makefile | 5 +++++ devsupApp/src/Makefile | 29 +++++++++++++++++++--------- makehelper.py | 44 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+), 9 deletions(-) create mode 100644 makehelper.py diff --git a/configure/CONFIG_SITE b/configure/CONFIG_SITE index 72b399d..15bb1a7 100644 --- a/configure/CONFIG_SITE +++ b/configure/CONFIG_SITE @@ -31,3 +31,5 @@ CHECK_RELEASE = YES # You must rebuild in the iocBoot directory for this to # take effect. #IOCS_APPL_TOP = + +PYTHON ?= python diff --git a/configure/Makefile b/configure/Makefile index 9254309..3f54d2c 100644 --- a/configure/Makefile +++ b/configure/Makefile @@ -5,4 +5,9 @@ include $(TOP)/configure/CONFIG TARGETS = $(CONFIG_TARGETS) CONFIGS += $(subst ../,,$(wildcard $(CONFIG_INSTALLS))) +TARGETS += CONFIG_PY + include $(TOP)/configure/RULES + +CONFIG_PY: $(TOP)/makehelper.py + $(PYTHON) $< $@ diff --git a/devsupApp/src/Makefile b/devsupApp/src/Makefile index 5c132b5..e4a0db7 100644 --- a/devsupApp/src/Makefile +++ b/devsupApp/src/Makefile @@ -5,16 +5,19 @@ include $(TOP)/configure/CONFIG # ADD MACRO DEFINITIONS AFTER THIS LINE #============================= -PYTHON = python -# EG 2.7 -PY_VER = $(shell $(PYTHON) -c 'from distutils.sysconfig import get_config_var; print get_config_var("VERSION")') -# EG -I/usr/include/python2.7 -PY_CFLAGS := -I$(shell $(PYTHON) -c 'from distutils.sysconfig import get_python_inc; print get_python_inc()') -# EG -L/usr/lib -PY_LIBDIR := -L$(shell $(PYTHON) -c 'from distutils.sysconfig import get_config_var; print get_config_var("LIBDIR")') +ifdef T_A +include $(TOP)/configure/O.$(T_A)/CONFIG_PY +ifneq ($(PY_OK),YES) +$(error Unable to get python configuration) +endif +endif -USR_CPPFLAGS += $(PY_CFLAGS) -USR_LDFLAGS += $(PY_LIBDIR) +USR_CPPFLAGS += $(PY_INCDIRS:%=-I%) +USR_LDFLAGS += $(PY_LIBDIRS:%=-L%) + +ifeq ($(HAVE_NUMPY),YES) +USR_CPPFLAGS += -DHAVE_NUMPY +endif #============================= # Build the IOC application @@ -53,3 +56,11 @@ include $(TOP)/configure/RULES #---------------------------------------- # ADD RULES AFTER THIS LINE +pyconfig: + @echo "Python Configuration for interpreter: $(PYTHON)" + @echo "Version: $(PY_VER)" + @echo "Found numpy: $(HAVE_NUMPY)" + @echo "Includes: $(PY_INCDIRS)" + @echo "Library path: $(PY_LIBDIRS)" + @echo "USR_CPPFLAGS: $(USR_CPPFLAGS)" + @echo "USR_LDFLAGS: $(USR_LDFLAGS)" diff --git a/makehelper.py b/makehelper.py new file mode 100644 index 0000000..9952d74 --- /dev/null +++ b/makehelper.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python +""" +Set some python derived Makefile variables. + +Emits something like the following + +PY_OK := YES # indicates success of this script +HAVE_NUMPY := YES/NO +PY_VER := 2.6 +PY_INCDIRS := /path ... +PY_LIBDIRS := /path ... +""" + +import sys + +if len(sys.argv)<2: + out = sys.stdout +else: + out = open(sys.argv[1], 'w') + +from distutils.sysconfig import get_config_var, get_python_inc + +incdirs = [get_python_inc()] +libdirs = [get_config_var('LIBDIR')] + +have_np='NO' +try: + from numpy.distutils.misc_util import get_numpy_include_dirs + incdirs += get_numpy_include_dirs() + have_np='YES' +except ImportError: + pass + +incdirs = [get_python_inc()]+get_numpy_include_dirs() +libdirs = [get_config_var('LIBDIR')] + +print >>out,'PY_VER :=',get_config_var('VERSION') +print >>out,'PY_INCDIRS :=',' '.join(incdirs) +print >>out,'PY_LIBDIRS :=',' '.join(libdirs) +print >>out,'HAVE_NUMPY :=',have_np + +print >>out,'PY_OK := YES' + +out.close()