Browse files

more distribution friendly Makefile improvements

- append CFLAGS instead of force-set it, this was distributions
  can also add their own CFLAGS in addition (this is very common).
- introduce LDFLAGS so distributions can set their own additional
  flags for the linker and append instead of set (this is very common)
- replace static /usr/local/lib with a PREFIX variable with default
  value of /usr/local so a distribution can easily use PREFIX=/usr
  (this is also common)
- introduce DESTDIR for distribution wide packaging as they build in
  chroots and deploy into a special directory structure that will later
  put into a tarball and lands in a distribution package.
  f.e. DESTDIR="/build/package" (this is also common for packaging)
- adding -D to install call to create all leading components of the
  destination. This is very important if the DESTDIR is set for
  packaging the therefor the structure does not yet exists. This will
  then basically freate the directory structure. in case DESTDIR is not
  used and /usr/local/lib f.e. already exists this will do nothing
  this is highly common to do it this way.
  We add the ${TARGET} to the end because we use the -D parameter and
  therefor we need to also pass the resulting filename
  • Loading branch information...
anthraxx committed Jun 5, 2016
1 parent 28b3af2 commit 26d3959ac90cfbecd36458fee2fbb67807457d54
Showing with 6 additions and 3 deletions.
  1. +6 −3 make/linux/Makefile
@@ -5,19 +5,22 @@
COBJS = ../../src/mnemonics.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
CC = gcc
LDFLAGS += -shared
PREFIX = /usr/local
all: clib
/bin/rm -rf ../../src/*.o ${TARGET} ../../distorm3.a ./../*.o
clib: ${COBJS}
${CC} ${CFLAGS} ${VERSION} ${COBJS} -shared -o ${TARGET}
ar rs ../../distorm3.a ${COBJS}
install -s ${TARGET} /usr/local/lib
install -D -s ${TARGET} ${DESTDIR}/${PREFIX}/lib/${TARGET}
@echo "... running ldconfig might be smart ..."

0 comments on commit 26d3959

Please sign in to comment.