[dpdk-dev] [virtio-net-pmd PATCH 10/16] mk: allow to build outside of the source directory
Thomas Monjalon
thomas.monjalon at 6wind.com
Tue Feb 4 16:54:25 CET 2014
S specify source directory (when not already in).
O specify output directory (when different of current one).
Signed-off-by: Thomas Monjalon <thomas.monjalon at 6wind.com>
---
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
More information about the dev
mailing list