Skip to content

Commit 58a0047

Browse files
committed
Makefile: put common functions into functions.mk
1 parent 39e1317 commit 58a0047

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

Makefile

+3-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
include config.mk
55
include pkgconfig.mk # package version
6+
include functions.mk
67

78
# Verbose output?
89
V ?= 0
@@ -373,19 +374,18 @@ else
373374
$(compile)
374375
endif
375376

376-
define compile
377-
$(CC) $(CFLAGS) -c $< -o $@
378-
endef
379377

380378
define create-archive
381379
$(AR) q $(ARCHIVE) $(LIBOBJ)
382380
$(RANLIB) $(ARCHIVE)
383381
endef
384382

383+
385384
define create-library
386385
$(CC) $(LDFLAGS) $(LIBOBJ) -o $(LIBRARY)
387386
endef
388387

388+
389389
define generate-pkgcfg
390390
echo 'Name: capstone' > $(PKGCFGF)
391391
echo 'Description: Capstone disassembly engine' >> $(PKGCFGF)
@@ -397,6 +397,3 @@ define generate-pkgcfg
397397
echo 'Cflags: -I$${includedir}' >> $(PKGCFGF)
398398
endef
399399

400-
define log
401-
@printf " %-7s %s\n" "$(1)" "$(2)"
402-
endef

functions.mk

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Capstone Disassembly Engine
2+
# Common functions used by Makefile & tests/Makefile
3+
4+
define compile
5+
${CC} ${CFLAGS} -c $< -o $@
6+
endef
7+
8+
9+
define log
10+
@printf " %-7s %s\n" "$(1)" "$(2)"
11+
endef
12+

tests/Makefile

+2-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# By Nguyen Anh Quynh <[email protected]>, 2013-2014
33

44
include ../config.mk
5+
include ../functions.mk
56

67
# Verbose output?
78
V ?= 0
@@ -112,20 +113,15 @@ else
112113
$(compile)
113114
endif
114115

115-
define compile
116-
${CC} ${CFLAGS} -c $< -o $@
117-
endef
118116

119117
define link-dynamic
120118
${CC} $(CFLAGS) $(LDFLAGS) $< -O3 -Wall -l$(LIBNAME) -o $@
121119
endef
122120

121+
123122
define link-static
124123
${CC} $(CFLAGS) $(LDFLAGS) $< -O3 -Wall $(LIBDIR)/lib$(LIBNAME).$(AR_EXT) -o $(call staticname,$@)
125124
endef
126125

127-
define log
128-
@printf " %-7s %s\n" "$(1)" "$(2)"
129-
endef
130126

131127
staticname = $(subst $(BIN_EXT),,$(1)).static$(BIN_EXT)

0 commit comments

Comments
 (0)