pcap: fix build with empty LIBPCAP_CFLAGS
[dpdk.git] / mk / rte.sdkbuild.mk
1 #   BSD LICENSE
2
3 #   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
4 #   All rights reserved.
5
6 #   Redistribution and use in source and binary forms, with or without
7 #   modification, are permitted provided that the following conditions
8 #   are met:
9
10 #     * Redistributions of source code must retain the above copyright
11 #       notice, this list of conditions and the following disclaimer.
12 #     * Redistributions in binary form must reproduce the above copyright
13 #       notice, this list of conditions and the following disclaimer in
14 #       the documentation and/or other materials provided with the
15 #       distribution.
16 #     * Neither the name of Intel Corporation nor the names of its
17 #       contributors may be used to endorse or promote products derived
18 #       from this software without specific prior written permission.
19
20 #   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 #   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 #   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 #   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 #   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 #   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 #   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 #   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 #   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 #   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 #   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
32 # If DESTDIR variable is given, install binary dpdk
33
34 #
35 # include rte.vars.mk if config file exists
36 #
37 ifeq (,$(wildcard $(RTE_OUTPUT)/.config))
38   $(error "need a make config first")
39 else
40   include $(RTE_SDK)/mk/rte.vars.mk
41 endif
42
43 ifeq ($(CONFIG_RTE_LIBRTE_PMD_PCAP),y)
44 LIBPCAP_CFLAGS ?= $(shell pcap-config --cflags)
45 EXTERNAL_LIB_CFLAGS += $(LIBPCAP_CFLAGS)
46 endif
47
48 export EXTERNAL_LIB_CFLAGS
49
50 #
51 # include .depdirs and define rules to order priorities between build
52 # of directories.
53 #
54 -include $(RTE_OUTPUT)/.depdirs
55
56 define depdirs_rule
57 $(1): $(sort $(LOCAL_DEPDIRS-$(1)))
58 endef
59
60 $(foreach d,$(ROOTDIRS-y),$(eval $(call depdirs_rule,$(d))))
61
62 #
63 # build and clean targets
64 #
65
66 CLEANDIRS = $(addsuffix _clean,$(ROOTDIRS-y) $(ROOTDIRS-n) $(ROOTDIRS-))
67
68 .PHONY: build
69 build: $(ROOTDIRS-y)
70         @echo Build complete
71 ifneq ($(DESTDIR),)
72         $(Q)mkdir -p $(DESTDIR)
73         $(Q)tar -C $(RTE_SDK) -cf - mk | tar -C $(DESTDIR) -x \
74           --keep-newer-files --warning=no-ignore-newer -f -
75         $(Q)mkdir -p $(DESTDIR)/`basename $(RTE_OUTPUT)`
76         $(Q)tar -C $(RTE_OUTPUT) -chf - \
77           --exclude app --exclude hostapp --exclude build \
78           --exclude Makefile --exclude .depdirs . | \
79           tar -C $(DESTDIR)/`basename $(RTE_OUTPUT)` -x --keep-newer-files \
80           --warning=no-ignore-newer -f -
81         $(Q)install -D $(RTE_OUTPUT)/app/testpmd \
82           $(DESTDIR)/`basename $(RTE_OUTPUT)`/app/testpmd
83         @echo Installation in $(DESTDIR) complete
84 endif
85
86 .PHONY: clean
87 clean: $(CLEANDIRS)
88         @rm -rf $(RTE_OUTPUT)/include $(RTE_OUTPUT)/app \
89                 $(RTE_OUTPUT)/hostapp $(RTE_OUTPUT)/lib \
90                 $(RTE_OUTPUT)/hostlib $(RTE_OUTPUT)/kmod
91         @[ -d $(RTE_OUTPUT)/include ] || mkdir -p $(RTE_OUTPUT)/include
92         @$(RTE_SDK)/scripts/gen-config-h.sh $(RTE_OUTPUT)/.config \
93                 > $(RTE_OUTPUT)/include/rte_config.h
94         $(Q)$(MAKE) -f $(RTE_SDK)/GNUmakefile gcovclean
95         @echo Clean complete
96
97 .SECONDEXPANSION:
98 .PHONY: $(ROOTDIRS-y)
99 $(ROOTDIRS-y):
100         @[ -d $(BUILDDIR)/$@ ] || mkdir -p $(BUILDDIR)/$@
101         @echo "== Build $@"
102         $(Q)$(MAKE) S=$@ -f $(RTE_SRCDIR)/$@/Makefile -C $(BUILDDIR)/$@ all
103         @if [ $@ = lib -a $(RTE_BUILD_COMBINE_LIBS) = y ]; then \
104                 $(MAKE) -f $(RTE_SDK)/lib/Makefile sharelib; \
105         fi
106
107 %_clean:
108         @echo "== Clean $*"
109         $(Q)if [ -f $(RTE_SRCDIR)/$*/Makefile -a -d $(BUILDDIR)/$* ]; then \
110                 $(MAKE) S=$* -f $(RTE_SRCDIR)/$*/Makefile -C $(BUILDDIR)/$* clean ; \
111         fi
112
113 RTE_MAKE_SUBTARGET ?= all
114
115 %_sub: $(addsuffix _sub,$(FULL_DEPDIRS-$(*)))
116         @echo $(addsuffix _sub,$(FULL_DEPDIRS-$(*)))
117         @[ -d $(BUILDDIR)/$* ] || mkdir -p $(BUILDDIR)/$*
118         @echo "== Build $*"
119         $(Q)$(MAKE) S=$* -f $(RTE_SRCDIR)/$*/Makefile -C $(BUILDDIR)/$* \
120                 $(RTE_MAKE_SUBTARGET)
121
122 .PHONY: all
123 all: build
124
125 .PHONY: FORCE
126 FORCE: