# # Name: Makehead.linux-clang # # Purpose: This file is used to customize operating system and installation # dependent features of the Mp makefiles. This version is # customized for the Clang compiler on Linux. # #MX_PYTHON = 2.7 ifndef MX_PYTHON MX_PYTHON = $(shell python -V 2>&1 | cut -f2 -d' ' | cut -c1-3) endif $(info Python is [${MX_PYTHON}]) PYTHON_INCLUDES = -I/usr/include/python$(MX_PYTHON) #PYTHON_INCLUDES = -I/usr/local/include/python$(MX_PYTHON) #PYTHON_INCLUDES = -I/home/lavender/local/include/python$(MX_PYTHON) PYTHON_LINK = $(shell python$(MX_PYTHON)-config --ldflags) PYTHON_MAJOR = $(shell echo $(MX_PYTHON) | cut -f1 -d'.') # # 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 Address Sanitizer # #SANITIZE = -fsanitize=address -fno-omit-frame-pointer #SANITIZE_LINK = -lasan -lubsan #CFLAGS += $(SANITIZE) # 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 # #========================================================================= # # Generally, you should not have to modify anything after this point. # ifeq ($(PYTHON_MAJOR),2) ifeq ($(MP_DEBUG),true) PYTHON = python-dbg else PYTHON = python endif else ifeq ($(MP_DEBUG),true) PYTHON = python$(PYTHON_MAJOR)-dbg else PYTHON = python$(PYTHON_MAJOR) endif endif 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. # CFLAGS += -g -fPIC -Wno-strict-aliasing $(INCLUDES) $(PYTHON_INCLUDES)\ -DOS_LINUX $(EXTRA_FLAGS) -DDEBUG ifeq ($(MP_DEBUG),true) CFLAGS += -DPy_DEBUG endif # MAKEDEPEND = $(CC) -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) $(CC) $(SANITIZE) -shared -Wl,-soname,$(LIBMP_SONAME) \ -o $(LIBMP_NAME) $(LIBMP_OBJS) $(PYTHON_LINK) $(SANITIZE_LINK) 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) $(CC) $(SANITIZE) -g -shared \ -o $(MP_MODULE_NAME) $(MP_DEBUG_LIBRARY) \ $(MP_MODULE_DIRS) $(MP_MODULE_OBJS) \ $(MP_LIBRARIES) -lc $(SANITIZE_LINK) #--------------------------------------------------------------------- MPMTR_MODULE_NAME = MpMtr.so MPMTR_MODULE_DELETE = rm $(MPMTR_MODULE_NAME) #--- $(MPMTR_MODULE_NAME): MpMtr.$(OBJ) -$(MPMTR_MODULE_DELETE) $(CC) $(SANITIZE) -g -shared \ -o $(MPMTR_MODULE_NAME) $(MP_DEBUG_LIBRARY) \ $(MP_MODULE_DIRS) MpMtr.$(OBJ) \ $(MP_LIBRARIES) -lc $(SANITIZE_LINK) MpMtr.$(OBJ): MpMtr.c $(CC) $(CFLAGS) -c MpMtr.c #--------------------------------------------------------------------- INCLUDES = -I$(LIBMXSRC) MP_MODULE_DIRS = -L$(LIBMXSRC) -L. $(LIB_DIRS) MP_LIBRARIES = -lMp -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 $(LIBMP_STATIC_NAME) $(MX_INSTALL_DIR)/lib install -m 644 *.py $(MX_INSTALL_DIR)/lib/mp install -m 644 *.pyc $(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/mpscript $(MX_INSTALL_DIR)/bin install -m 755 ../mpscript/mpshell $(MX_INSTALL_DIR)/bin install -m 755 ../mpscript/mpenv $(MX_INSTALL_DIR)/bin