From 58a0047d4349789b4038b6b29e9b26273ec1e3a6 Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh Date: Thu, 1 May 2014 22:53:52 +0800 Subject: [PATCH] Makefile: put common functions into functions.mk --- Makefile | 9 +++------ functions.mk | 12 ++++++++++++ tests/Makefile | 8 ++------ 3 files changed, 17 insertions(+), 12 deletions(-) create mode 100644 functions.mk diff --git a/Makefile b/Makefile index 9c8743d127..9d25e7db1c 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,7 @@ include config.mk include pkgconfig.mk # package version +include functions.mk # Verbose output? V ?= 0 @@ -373,19 +374,18 @@ else $(compile) endif -define compile - $(CC) $(CFLAGS) -c $< -o $@ -endef define create-archive $(AR) q $(ARCHIVE) $(LIBOBJ) $(RANLIB) $(ARCHIVE) endef + define create-library $(CC) $(LDFLAGS) $(LIBOBJ) -o $(LIBRARY) endef + define generate-pkgcfg echo 'Name: capstone' > $(PKGCFGF) echo 'Description: Capstone disassembly engine' >> $(PKGCFGF) @@ -397,6 +397,3 @@ define generate-pkgcfg echo 'Cflags: -I$${includedir}' >> $(PKGCFGF) endef -define log - @printf " %-7s %s\n" "$(1)" "$(2)" -endef diff --git a/functions.mk b/functions.mk new file mode 100644 index 0000000000..d946cd34e6 --- /dev/null +++ b/functions.mk @@ -0,0 +1,12 @@ +# Capstone Disassembly Engine +# Common functions used by Makefile & tests/Makefile + +define compile + ${CC} ${CFLAGS} -c $< -o $@ +endef + + +define log + @printf " %-7s %s\n" "$(1)" "$(2)" +endef + diff --git a/tests/Makefile b/tests/Makefile index db93757ca2..288b924736 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -2,6 +2,7 @@ # By Nguyen Anh Quynh , 2013-2014 include ../config.mk +include ../functions.mk # Verbose output? V ?= 0 @@ -112,20 +113,15 @@ else $(compile) endif -define compile - ${CC} ${CFLAGS} -c $< -o $@ -endef define link-dynamic ${CC} $(CFLAGS) $(LDFLAGS) $< -O3 -Wall -l$(LIBNAME) -o $@ endef + define link-static ${CC} $(CFLAGS) $(LDFLAGS) $< -O3 -Wall $(LIBDIR)/lib$(LIBNAME).$(AR_EXT) -o $(call staticname,$@) endef -define log - @printf " %-7s %s\n" "$(1)" "$(2)" -endef staticname = $(subst $(BIN_EXT),,$(1)).static$(BIN_EXT)