Skip to content
This repository has been archived by the owner on May 18, 2022. It is now read-only.

Commit

Permalink
Makefile: put common functions into functions.mk
Browse files Browse the repository at this point in the history
  • Loading branch information
aquynh committed May 1, 2014
1 parent 39e1317 commit 58a0047
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
9 changes: 3 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

include config.mk
include pkgconfig.mk # package version
include functions.mk

# Verbose output?
V ?= 0
Expand Down Expand Up @@ -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)
Expand All @@ -397,6 +397,3 @@ define generate-pkgcfg
echo 'Cflags: -I$${includedir}' >> $(PKGCFGF)
endef

define log
@printf " %-7s %s\n" "$(1)" "$(2)"
endef
12 changes: 12 additions & 0 deletions functions.mk
Original file line number Diff line number Diff line change
@@ -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

8 changes: 2 additions & 6 deletions tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# By Nguyen Anh Quynh <[email protected]>, 2013-2014

include ../config.mk
include ../functions.mk

# Verbose output?
V ?= 0
Expand Down Expand Up @@ -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)

0 comments on commit 58a0047

Please sign in to comment.