Description: Add to Makefile usual facilities like DESTDIR and TARGET.
 With this patch Makefile accepts a DESTDIR for installation, and changing
 the name of the shared object is easier, as there's only one place to touch.
Forwarded: no
Last-Update: <2011-12-20>

--- a/build/linux/Makefile
+++ b/build/linux/Makefile
@@ -2,26 +2,29 @@
 # diStorm64 (Linux Port)
 #
 
-TARGET	= libdistorm64.so
+TARGET	= libdistorm64.so.1
+STATIC_TARGET = libdistorm64.a
 COBJS	= ../../src/x86defs.o ../../src/wstring.o ../../src/textdefs.o ../../src/prefix.o ../../src/operands.o ../../src/insts.o ../../src/instructions.o ../../src/distorm.o ../../src/decoder.o
 PYOBJS	= ../../src/x86defs.o ../../src/wstring.o ../../src/textdefs.o ../../src/pydistorm.o ../../src/prefix.o ../../src/operands.o ../../src/insts.o ../../src/instructions.o ../../src/decoder.o
 CC	= gcc
 CFLAGS	= -O2 -Wall -fPIC -DSUPPORT_64BIT_OFFSET -D_DLL
+DESTDIR ?= /usr/local/lib
 
 all: clib py
 
 clean:
-	/bin/rm -rf ../../src/*.o ${TARGET} ../../distorm64.a
+	/bin/rm -rf ../../src/*.o ${TARGET} ../../$(STATIC_TARGET)
 
 clib: ${COBJS}
-	${CC} ${CFLAGS} ${VERSION} ${COBJS} -fPIC -shared -o ${TARGET}
-	ar rs ../../distorm64.a ${COBJS}
+	${CC} ${CFLAGS} ${VERSION} ${COBJS} -fPIC -Wl,-soname,${TARGET} -shared -o ${TARGET}
+	ar rs ../../$(STATIC_TARGET) ${COBJS}
 
 py: ${PYOBJS}
-	${CC} ${CFLAGS} ${VERSION} ${PYOBJS} -fPIC -shared -o ${TARGET}
+	${CC} ${CFLAGS} ${VERSION} ${PYOBJS} -fPIC -Wl,-soname,${TARGET} -shared -o ${TARGET}
 
-install: libdistorm64.so
-	install -s ${TARGET} /usr/local/lib
+install: ${TARGET}
+	install -d ${DESTDIR}
+	install -s ${TARGET} ${DESTDIR}
 	@echo "... running ldconfig might be smart ..."
 
 .c.o:
