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