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