summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Monjalon <thomas.monjalon@6wind.com>2014-02-03 17:04:08 +0100
committerThomas Monjalon <thomas.monjalon@6wind.com>2014-03-27 10:23:12 +0100
commit12bafe7c46bb21b10f67dd70399487110855d36d (patch)
tree279d614e624b8622c23a1057c5ed8acfb38ca67c
parentf6b2e876d1cd2702f967507165db787945b9fc6e (diff)
downloadvirtio-net-pmd-12bafe7c46bb21b10f67dd70399487110855d36d.zip
virtio-net-pmd-12bafe7c46bb21b10f67dd70399487110855d36d.tar.gz
virtio-net-pmd-12bafe7c46bb21b10f67dd70399487110855d36d.tar.xz
mk: allow to build outside of the source directory
S specify source directory (when not already in). O specify output directory (when different of current one). Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com> Reviewed-by: Olivier Matz <olivier.matz@6wind.com>
-rw-r--r--Makefile20
1 files 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