1ifndef BASE_NAME 2BASE_NAME = x86disasm 3endif 4 5ifndef SWIG 6SWIG = swig # apt-get install swig ! 7endif 8 9ifndef GCC 10GCC = gcc 11endif 12 13ifndef CC_FLAGS 14CC_FLAGS = -c -fPIC 15endif 16 17ifndef LD_FLAGS 18LD_FLAGS = -shared -L.. -ldisasm 19endif 20 21INTERFACE_FILE = libdisasm_oop.i 22 23SWIG_INTERFACE = ../$(INTERFACE_FILE) 24 25# PYTHON rules 26PYTHON_MOD = $(BASE_NAME)-python.so 27PYTHON_SHADOW = $(BASE_NAME)_wrap.c 28PYTHON_SWIG = $(BASE_NAME).py 29PYTHON_OBJ = $(BASE_NAME)_wrap.o 30PYTHON_INC = `/bin/echo -e 'import sys\nprint sys.prefix + "/include/python" + sys.version[:3]' | python` 31PYTHON_LIB = `/bin/echo -e 'import sys\nprint sys.prefix + "/lib/python" + sys.version[:3]' | python` 32PYTHON_DEST = $(PYTHON_LIB)/lib-dynload/_$(BASE_NAME).so 33 34#==================================================== 35# TARGETS 36 37all: swig-python 38 39dummy: swig-python install uninstall clean 40 41swig-python: $(PYTHON_MOD) 42 43$(PYTHON_MOD): $(PYTHON_OBJ) 44 $(GCC) $(LD_FLAGS) $(PYTHON_OBJ) -o $@ 45 46$(PYTHON_OBJ): $(PYTHON_SHADOW) 47 $(GCC) $(CC_FLAGS) -I$(PYTHON_INC) -I.. -o $@ $< 48 49$(PYTHON_SHADOW): $(SWIG_INTERFACE) 50 swig -python -shadow -o $(PYTHON_SHADOW) -outdir . $< 51 52# ================================================================== 53install: $(PYTHON_MOD) 54 sudo cp $(PYTHON_MOD) $(PYTHON_DEST) 55 sudo cp $(PYTHON_SWIG) $(PYTHON_LIB) 56 57# ================================================================== 58uninstall: 59 60# ================================================================== 61clean: 62 rm $(PYTHON_MOD) $(PYTHON_SWIG) $(PYTHON_OBJ) 63 rm $(PYTHON_SHADOW) 64 65