# # Name: Makehead.linux # # Purpose: This file is used to customize operating system and installation # dependent features of the Mp makefiles. This version is # customized for Linux. # #MX_PYTHON = 2.7 ifndef MX_PYTHON MX_PYTHON = $(shell python3 -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d'.') endif $(info Python is [${MX_PYTHON}]) # # Relatively recent versions of Python have a pythonX.Y-config command. # # We check to see if this command exists and use it to find the include # file directory and linker flags. If this version of Python is so old # that the command does _not_ exist, then we construct the necessary # include file directory name and linker flags by hand. # MX_PYTHON_CONFIG_NAME = python$(MX_PYTHON)-config MX_PYTHON_CONFIG = $(shell which ${MX_PYTHON_CONFIG_NAME}) $(info PYTHON_CONFIG is [${PYTHON_CONFIG}]) ifeq ($(MX_PYTHON_CONFIG),) PYTHON_INCLUDES = -I/usr/include/python$(MX_PYTHON) PYTHON_LINK = else PYTHON_INCLUDES = $(shell python$(MX_PYTHON)-config --includes) PYTHON_LINK = $(shell python$(MX_PYTHON)-config --ldflags) endif PYTHON_MAJOR = $(shell echo $(MX_PYTHON) | cut -f1 -d'.') $(info PYTHON_INCLUDES is [${PYTHON_INCLUDES}]) $(info PYTHON_LINK is [${PYTHON_LINK}]) #$(info PYTHON_MAJOR is [${PYTHON_MAJOR}]) # # The following optional modules import external Python modules that may not # be available at all sites and for all operating systems. Comment out any # that will not build at your site. # # MpNum.py - Requires the 'numpy' module. OPTIONAL_MODULES += MpNum.pyc # Turn on optimization # #OPTIMIZE = -O2 #OPTIMIZE = -O3 #CFLAGS += $(OPTIMIZE) # # DEBUGGING SUPPORT # # If you want to use the debugging version of Python called "python-dbg", # then you must set MP_DEBUG to 'true' below when you compile your # code and also use python-dbg to build the pyc files. # # If you try to run a non-debug build of Mp with the debug version of # Python, namely python-dbg, you will get an error message similar # to this: # # ImportError: /opt/mx/lib/mp/MpPrivate.so: undefined symbol: Py_InitModule4 # MP_DEBUG = false #--- MP_DEBUG_LIBRARY_PATH = /usr/lib/debug/usr/lib/libpython2.4.so.1.0 # #========================================================================= # _libc_version = $(shell ../../mx/tools/mx_config library) ifeq ($(_have_conda),true) _have_tirpc := false else _have_tirpc := $(shell ../../mx/scripts/directory_exists /usr/include/tirpc) endif $(info _have_tirpc is [${_have_tirpc}]) ifeq ($(_libc_version),musl) CFLAGS += -I/usr/include/tirpc LIBRARIES += -ltirpc else ifeq ($(_have_tirpc),true) CFLAGS += -I/usr/include/tirpc LIBRARIES += -ltirpc endif endif _pycache_exists = $(shell ../../mx/scripts/directory_exists __pycache__) $(info _pycache_exists is [${_pycache_exists}]) # #========================================================================= # # Generally, you should not have to modify anything after this point. # ifeq ($(MP_DEBUG),true) PYTHON = python$(MX_PYTHON)-dbg else PYTHON = python$(MX_PYTHON) endif $(info PYTHON is [${PYTHON}]) #=== PYTHON_BIN = $(shell which ${PYTHON}) $(info PYTHON_BIN is [${PYTHON_BIN}]) ifeq ($(MP_DEBUG),true) MP_DEBUG_LIBRARY = $(MP_DEBUG_LIBRARY_PATH) endif MP_BUILD_PYC = $(PYTHON) MpBuildPyc.pyx # # The Python developers have chosen to always compile Python with the # -Wno-strict-aliasing flag set. If the MP code is compiled with # strict-aliasing turned on, then at high optimization levels we can # get GCC warnings about the mere use of Python objects like Py_True # and Py_False. This unfortunately means that we must set the # -Wno-strict-aliasing flag for MP as well. # # Versions of GCC before GCC 3.0 do not support the -Wno-strict-aliasing # flag, so we test for and only use it with newer GCC versions. # GCC_VERSION = $(shell ../../mx/tools/mx_config gcc) NEW_GCC = $(shell expr $(GCC_VERSION) \>= 3000000) ifeq ($(NEW_GCC),1) GCCFLAGS += -Wno-strict-aliasing endif # CFLAGS += -g -fPIC $(GCCFLAGS) $(INCLUDES) $(PYTHON_INCLUDES) \ -DOS_LINUX $(EXTRA_FLAGS) -DDEBUG ifeq ($(MP_DEBUG),true) CFLAGS += -DPy_DEBUG endif # MAKEDEPEND = gcc -MM $(CFLAGS) libMp.c mp_*.c MpMtr*.c > Makefile.depend MAKEDEPEND_CLEAN = rm Makefile.depend #--------------------------------------------------------------------- LIBMP_OBJS = $(LIBMP_SRCS:.c=.$(OBJ)) LIBMP_SONAME = libMp.so.$(MX_MAJOR_VERSION) LIBMP_NAME = $(LIBMP_SONAME).$(MX_MINOR_VERSION).$(MX_UPDATE_VERSION) LIBMP_STATIC_NAME = libMp.a LIBMP_DELETE = rm $(LIBMP_NAME) $(LIBMP_SONAME) libMp.so $(LIBMP_STATIC_NAME) #--- $(LIBMP_NAME): $(LIBMP_OBJS) -$(LIBMP_DELETE) gcc -shared -Wl,-soname,$(LIBMP_SONAME) \ -o $(LIBMP_NAME) $(LIBMP_OBJS) ln -sf $(LIBMP_NAME) $(LIBMP_SONAME) ln -sf $(LIBMP_NAME) libMp.so ar rcs $(LIBMP_STATIC_NAME) $(LIBMP_OBJS) ranlib $(LIBMP_STATIC_NAME) #--------------------------------------------------------------------- MP_PYTHON_MODULES = Mp.pyc MpScan.pyc MP_MODULE_NAME = MpPrivate.so MP_MODULE_OBJS = $(MP_MODULE_SRCS:.c=.$(OBJ)) MP_MODULE_DELETE = rm $(MP_MODULE_NAME) #--- $(MP_MODULE_NAME): $(MP_MODULE_OBJS) -$(MP_MODULE_DELETE) gcc -g -shared -o $(MP_MODULE_NAME) $(MP_DEBUG_LIBRARY) \ $(MP_MODULE_DIRS) $(MP_MODULE_OBJS) \ $(MP_LIBRARIES) -lc # echo "#! ${PYTHON_BIN}" > mpscript.temp tail -n +2 ../mpscript/mpscript >> mpscript.temp # echo "#! ${PYTHON_BIN}" > mpenv.temp tail -n +2 ../mpscript/mpenv >> mpenv.temp #--------------------------------------------------------------------- MPMTR_MODULE_NAME = MpMtr.so MPMTR_MODULE_DELETE = rm $(MPMTR_MODULE_NAME) #--- $(MPMTR_MODULE_NAME): MpMtr.$(OBJ) -$(MPMTR_MODULE_DELETE) gcc -g -shared -o $(MPMTR_MODULE_NAME) $(MP_DEBUG_LIBRARY) \ $(MP_MODULE_DIRS) MpMtr.$(OBJ) \ $(MP_LIBRARIES) -lc MpMtr.$(OBJ): MpMtr.c gcc $(CFLAGS) -c MpMtr.c #--------------------------------------------------------------------- INCLUDES = -I$(LIBMXSRC) MP_MODULE_DIRS = -L$(LIBMXSRC) -L. $(LIB_DIRS) MP_LIBRARIES = -lMp -lMx $(LIBRARIES) #MP_LIBRARIES = ./libMp.so -lMx $(LIBRARIES) ifeq ($(MP_DEBUG),true) MP_MODULE_DIRS += $(MP_DEBUG_LIBRARY_DIR) endif #--------------------------------------------------------------------- mp_install: -mkdir $(MX_INSTALL_DIR)/bin -mkdir $(MX_INSTALL_DIR)/lib -mkdir $(MX_INSTALL_DIR)/lib/mp install -m 644 $(LIBMP_NAME) $(MX_INSTALL_DIR)/lib ( cd $(MX_INSTALL_DIR)/lib ; ln -sf $(LIBMP_NAME) $(LIBMP_SONAME) ) ( cd $(MX_INSTALL_DIR)/lib ; ln -sf $(LIBMP_NAME) libMp.so ) install -m 644 mp.h $(MX_INSTALL_DIR)/include install -m 644 $(LIBMP_STATIC_NAME) $(MX_INSTALL_DIR)/lib install -m 644 *.py $(MX_INSTALL_DIR)/lib/mp install -m 644 MpPrivate.so $(MX_INSTALL_DIR)/lib/mp install -m 644 MpMtr.so $(MX_INSTALL_DIR)/lib/mp install -m 755 ../mpscript/mpshell $(MX_INSTALL_DIR)/bin install -m 755 mpscript.temp $(MX_INSTALL_DIR)/bin/mpscript install -m 755 mpenv.temp $(MX_INSTALL_DIR)/bin/mpenv install -m 755 ../net/mpnet $(MX_INSTALL_DIR)/bin/mpnet ( cd $(MX_INSTALL_DIR)/bin ; ln -sf mpnet mpget ) ( cd $(MX_INSTALL_DIR)/bin ; ln -sf mpnet mpput ) ( cd $(MX_INSTALL_DIR)/bin ; ln -sf mpnet mnget ) ( cd $(MX_INSTALL_DIR)/bin ; ln -sf mpnet mnput ) ifeq ($(_pycache_exists),false) -install -m 644 *.pyc $(MX_INSTALL_DIR)/lib/mp else -mkdir $(MX_INSTALL_DIR)/lib/mp/__pycache__ -install -m 644 __pycache__/*.pyc $(MX_INSTALL_DIR)/lib/mp/__pycache__ endif