From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Monjalon Subject: [virtio-net-pmd PATCH 10/16] mk: allow to build outside of the source directory Date: Tue, 4 Feb 2014 16:54:25 +0100 Message-ID: <1391529271-24606-11-git-send-email-thomas.monjalon@6wind.com> References: <1391529271-24606-1-git-send-email-thomas.monjalon@6wind.com> To: dev-VfR2kkLFssw@public.gmane.org Return-path: In-Reply-To: <1391529271-24606-1-git-send-email-thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" S specify source directory (when not already in). O specify output directory (when different of current one). Signed-off-by: Thomas Monjalon --- Makefile | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 4b51057..4ff4c1d 100644 --- a/Makefile +++ b/Makefile @@ -36,16 +36,27 @@ override CPPFLAGS += -Wall -Wextra -Werror override CFLAGS += -fPIC override LDFLAGS += -shared -all : +S ?= . +O ?= . + +all : $O/$(SOLIB) + +$O : + mkdir -p $@ + +$O/$(SOLIB) : $S/virtio_user.c | $O ifeq '$(RTE_INCLUDE)' '' @ echo 'ERROR: RTE_INCLUDE is not set' && false endif $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) \ -I$(RTE_INCLUDE) -include $(RTE_INCLUDE)/rte_config.h \ - -o $(SOLIB) virtio_user.c + -o $@ $< clean : - rm -f $(SOLIB) + - rm -f $O/$(SOLIB) +ifneq '$(abspath $O)' '$(CURDIR)' + - rmdir -p $O 2>&- +endif help : @ echo 'rules:' @@ -53,6 +64,7 @@ help : @ echo ' clean' @ echo 'variables:' @ echo ' RTE_INCLUDE (e.g. ../dpdk/build/include),' - @ echo ' CPPFLAGS, CFLAGS, LDFLAGS' + @ echo ' CPPFLAGS, CFLAGS, LDFLAGS,' + @ echo ' S (source directory), O (build directory)' .PHONY : all clean help -- 1.7.10.4