Makefile: put common functions into functions.mk

This commit is contained in:
Nguyen Anh Quynh
2014-05-01 22:53:52 +08:00
parent 39e13174f6
commit 58a0047d43
3 changed files with 17 additions and 12 deletions

View File

@ -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

12
functions.mk Normal file
View File

@ -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

View File

@ -2,6 +2,7 @@
# By Nguyen Anh Quynh <aquynh@gmail.com>, 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)