mk: add rule to list configs
[dpdk.git] / mk / rte.sdkconfig.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 .PHONY: showversion
33 showversion:
34         @sed -rn 's,^#define RTE_VER_[A-Z_]*[[:space:]]+([0-9]+).*,\1,p' \
35                 $(RTE_SRCDIR)/lib/librte_eal/common/include/rte_version.h | \
36                 tr '\n' '.' | sed -r 's,\.([0-9]+)\.$$,r\1\n,'
37
38 INSTALL_CONFIGS := $(filter-out %~,\
39         $(patsubst $(RTE_SRCDIR)/config/defconfig_%,%,\
40         $(wildcard $(RTE_SRCDIR)/config/defconfig_*)))
41 INSTALL_TARGETS := $(addsuffix _install,$(INSTALL_CONFIGS))
42
43 .PHONY: showconfigs
44 showconfigs:
45         @$(foreach CONFIG, $(INSTALL_CONFIGS), echo $(CONFIG);)
46
47 .PHONY: config
48 ifeq ($(RTE_CONFIG_TEMPLATE),)
49 config:
50         @printf "No template specified. "
51         @echo "Use T=template among the following list:"
52         @$(MAKE) -rR showconfigs | sed 's,^,  ,'
53 else
54 config: $(RTE_OUTPUT)/include/rte_config.h $(RTE_OUTPUT)/Makefile
55         $(Q)$(MAKE) depdirs
56         @echo "Configuration done"
57 endif
58
59 ifdef NODOTCONF
60 $(RTE_OUTPUT)/.config: ;
61 else
62 $(RTE_OUTPUT)/.config: $(RTE_CONFIG_TEMPLATE) FORCE
63         @[ -d $(RTE_OUTPUT) ] || mkdir -p $(RTE_OUTPUT)
64         $(Q)if [ "$(RTE_CONFIG_TEMPLATE)" != "" -a -f "$(RTE_CONFIG_TEMPLATE)" ]; then \
65                 $(CPP) -undef -P -x assembler-with-cpp \
66                 -fdirectives-only -ffreestanding \
67                 -o $(RTE_OUTPUT)/.config_tmp $(RTE_CONFIG_TEMPLATE) ; \
68                 if ! cmp -s $(RTE_OUTPUT)/.config_tmp $(RTE_OUTPUT)/.config; then \
69                         cp $(RTE_OUTPUT)/.config_tmp $(RTE_OUTPUT)/.config ; \
70                 fi ; \
71                 rm -f $(RTE_OUTPUT)/.config_tmp ; \
72         else \
73                 echo -n "No template specified. Use T=template " ; \
74                 echo "among the following list:" ; \
75                 for t in $(INSTALL_CONFIGS); do \
76                         echo "  $$t" ; \
77                 done ; \
78         fi
79 endif
80
81 # generate a Makefile for this build directory
82 # use a relative path so it will continue to work even if we move the directory
83 SDK_RELPATH=$(shell $(RTE_SDK)/scripts/relpath.sh $(abspath $(RTE_SRCDIR)) \
84                                 $(abspath $(RTE_OUTPUT)))
85 OUTPUT_RELPATH=$(shell $(RTE_SDK)/scripts/relpath.sh $(abspath $(RTE_OUTPUT)) \
86                                 $(abspath $(RTE_SRCDIR)))
87 $(RTE_OUTPUT)/Makefile:
88         @[ -d $(RTE_OUTPUT) ] || mkdir -p $(RTE_OUTPUT)
89         $(Q)$(RTE_SDK)/scripts/gen-build-mk.sh $(SDK_RELPATH) $(OUTPUT_RELPATH) \
90                 > $(RTE_OUTPUT)/Makefile
91
92 # clean installed files, and generate a new config header file
93 # if NODOTCONF variable is defined, don't try to rebuild .config
94 $(RTE_OUTPUT)/include/rte_config.h: $(RTE_OUTPUT)/.config
95         $(Q)rm -rf $(RTE_OUTPUT)/include $(RTE_OUTPUT)/app \
96                 $(RTE_OUTPUT)/hostapp $(RTE_OUTPUT)/lib \
97                 $(RTE_OUTPUT)/hostlib $(RTE_OUTPUT)/kmod $(RTE_OUTPUT)/build
98         @[ -d $(RTE_OUTPUT)/include ] || mkdir -p $(RTE_OUTPUT)/include
99         $(Q)$(RTE_SDK)/scripts/gen-config-h.sh $(RTE_OUTPUT)/.config \
100                 > $(RTE_OUTPUT)/include/rte_config.h
101
102 # generate the rte_config.h
103 .PHONY: headerconfig
104 headerconfig: $(RTE_OUTPUT)/include/rte_config.h
105         @true
106
107 # check that .config is present, and if yes, check that rte_config.h
108 # is up to date
109 .PHONY: checkconfig
110 checkconfig:
111         @if [ ! -f $(RTE_OUTPUT)/.config ]; then \
112                 echo "No .config in build directory"; \
113                 exit 1; \
114         fi
115         $(Q)$(MAKE) -f $(RTE_SDK)/mk/rte.sdkconfig.mk \
116                 headerconfig NODOTCONF=1
117
118 .PHONY: FORCE
119 FORCE: