From 346032797a51c3345bce08c7f26c45bae9a3d970 Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh Date: Mon, 10 Oct 2016 22:54:16 +0800 Subject: [PATCH] cstool: compile/clean/install/uninstall from Makefile --- Makefile | 6 ++++++ cstool/Makefile | 21 +++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index d429ae91..cc42a789 100644 --- a/Makefile +++ b/Makefile @@ -74,6 +74,7 @@ LIBDIRARCH ?= lib # Or better, pass 'LIBDIRARCH=lib64' to 'make install/uninstall' via 'make.sh'. #LIBDIRARCH ?= lib64 LIBDIR = $(DESTDIR)$(PREFIX)/$(LIBDIRARCH) +BINDIR = $(DESTDIR)$(PREFIX)/bin LIBDATADIR = $(LIBDIR) @@ -326,6 +327,7 @@ PKGCFGF = $(BLDIR)/$(LIBNAME).pc all: $(LIBRARY) $(ARCHIVE) $(PKGCFGF) ifeq (,$(findstring yes,$(CAPSTONE_BUILD_CORE_ONLY))) + @V=$(V) $(MAKE) -C cstool ifndef BUILDDIR cd tests && $(MAKE) else @@ -384,16 +386,20 @@ endif $(INSTALL_DATA) include/*.h $(INCDIR)/$(LIBNAME) mkdir -p $(PKGCFGDIR) $(INSTALL_DATA) $(PKGCFGF) $(PKGCFGDIR)/ + mkdir -p $(BINDIR) + $(INSTALL_LIB) cstool/cstool $(BINDIR) uninstall: rm -rf $(INCDIR)/$(LIBNAME) rm -f $(LIBDIR)/lib$(LIBNAME).* rm -f $(PKGCFGDIR)/$(LIBNAME).pc + rm -f $(BINDIR)/cstool clean: rm -f $(LIBOBJ) rm -f $(BLDIR)/lib$(LIBNAME).* $(BLDIR)/$(LIBNAME).* rm -f $(PKGCFGF) + $(MAKE) -C cstool clean ifeq (,$(findstring yes,$(CAPSTONE_BUILD_CORE_ONLY))) cd tests && $(MAKE) clean diff --git a/cstool/Makefile b/cstool/Makefile index d7730560..2ef5bf60 100644 --- a/cstool/Makefile +++ b/cstool/Makefile @@ -1,9 +1,26 @@ # Sample Makefile for Capstone Disassembly Engine +include ../functions.mk + +.PHONY: clean + LIBNAME = capstone cstool: cstool.o - ${CC} $< -O3 -Wall -l$(LIBNAME) -o $@ +ifeq ($(V),0) + $(call log,LINK,$@) + @${CC} $< -O3 -Wall -L.. -l$(LIBNAME) -o $@ +else + ${CC} $< -O3 -Wall -L.. -l$(LIBNAME) -o $@ +endif + +clean: + ${RM} -rf *.o cstool %.o: %.c - ${CC} -c $< -o $@ +ifeq ($(V),0) + $(call log,CC,$@) + @$(compile) +else + $(compile) +endif