crypto/snow3g: add dynamic logging
[dpdk.git] / mk / rte.sdkconfig.mk
1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2010-2014 Intel Corporation
3
4 .PHONY: showversion
5 showversion:
6         @set -- \
7                 $$(sed -rne 's,^#define RTE_VER_[A-Z_]*[[:space:]]+([0-9]+).*,\1,p' \
8                         -e 's,^#define RTE_VER_SUFFIX[[:space:]]+"(.*)",\1,p' \
9                         $(RTE_SRCDIR)/lib/librte_eal/common/include/rte_version.h) ;\
10                 printf '%d.%02d.%d' "$$1" "$$2" "$$3"; \
11                 if [ -z "$$5" ]; then echo; \
12                 else printf '%s' "$$4"; \
13                         if [ $$5 -lt 16 ] ; then echo $$5; \
14                         else echo $$(($$5 - 16)); fi; \
15                 fi
16
17 .PHONY: showversionum
18 showversionum:
19         @set -- \
20                 $$(sed -rne 's,^#define RTE_VER_[A-Z_]*[[:space:]]+([0-9]+).*,\1,p' \
21                         $(RTE_SRCDIR)/lib/librte_eal/common/include/rte_version.h); \
22                 printf '%02d%02d\n' "$$1" "$$2"
23
24 INSTALL_CONFIGS := $(sort $(filter-out %~,\
25         $(patsubst $(RTE_SRCDIR)/config/defconfig_%,%,\
26         $(wildcard $(RTE_SRCDIR)/config/defconfig_*))))
27 INSTALL_TARGETS := $(addsuffix _install,$(INSTALL_CONFIGS))
28
29 .PHONY: showconfigs
30 showconfigs:
31         @$(foreach CONFIG, $(INSTALL_CONFIGS), echo $(CONFIG);)
32
33 .PHONY: notemplate
34 notemplate:
35         @printf "No template specified. Use 'make defconfig' or "
36         @echo "use T=template from the following list:"
37         @$(MAKE) -rR showconfigs | sed 's,^,  ,'
38
39 .PHONY: defconfig
40 defconfig:
41         @$(MAKE) config T=$(shell \
42                 uname -m | awk '{ \
43                 if ($$0 == "aarch64") { \
44                         print "arm64-armv8a"} \
45                 else if ($$0 == "armv7l") { \
46                         print "arm-armv7a"} \
47                 else if ($$0 == "ppc64") { \
48                         print "ppc_64-power8"} \
49                 else if ($$0 == "amd64") { \
50                         print "x86_64-native"} \
51                 else { \
52                         printf "%s-native", $$0} }' \
53                 )-$(shell \
54                 uname | awk '{ \
55                 if ($$0 == "Linux") { \
56                         print "linuxapp"} \
57                 else { \
58                         print "bsdapp"} }' \
59                 )-$(shell \
60                 ${CC} --version | grep -o 'cc\|gcc\|icc\|clang' | awk \
61                 '{ \
62                 if ($$1 == "cc") { \
63                         print "gcc" } \
64                 else { \
65                         print $$1 } \
66                 }' \
67                 )
68
69 .PHONY: config
70 ifeq ($(RTE_CONFIG_TEMPLATE),)
71 config: notemplate
72 else
73 config: $(RTE_OUTPUT)/include/rte_config.h $(RTE_OUTPUT)/Makefile
74         @echo "Configuration done using" \
75                 $(patsubst defconfig_%,%,$(notdir $(RTE_CONFIG_TEMPLATE)))
76 endif
77
78 $(RTE_OUTPUT):
79         $(Q)mkdir -p $@
80
81 ifdef NODOTCONF
82 $(RTE_OUTPUT)/.config: ;
83 else
84 # Generate config from template, if there are duplicates keep only the last.
85 # To do so the temp config is checked for duplicate keys with cut/sort/uniq
86 # Then for each of those identified duplicates as long as there are more than
87 # just one left the last match is removed.
88 $(RTE_OUTPUT)/.config: $(RTE_CONFIG_TEMPLATE) FORCE | $(RTE_OUTPUT)
89         $(Q)if [ "$(RTE_CONFIG_TEMPLATE)" != "" -a -f "$(RTE_CONFIG_TEMPLATE)" ]; then \
90                 $(CPP) -undef -P -x assembler-with-cpp \
91                 -ffreestanding \
92                 -o $(RTE_OUTPUT)/.config_tmp $(RTE_CONFIG_TEMPLATE) ; \
93                 config=$$(cat $(RTE_OUTPUT)/.config_tmp) ; \
94                 echo "$$config" | awk -F '=' 'BEGIN {i=1} \
95                         /^#/ {pos[i++]=$$0} \
96                         !/^#/ {if (!s[$$1]) {pos[i]=$$0; s[$$1]=i++} \
97                                 else {pos[s[$$1]]=$$0}} END \
98                         {for (j=1; j<i; j++) print pos[j]}' \
99                         > $(RTE_OUTPUT)/.config_tmp ; \
100                 if ! cmp -s $(RTE_OUTPUT)/.config_tmp $(RTE_OUTPUT)/.config; then \
101                         cp $(RTE_OUTPUT)/.config_tmp $(RTE_OUTPUT)/.config ; \
102                         cp $(RTE_OUTPUT)/.config_tmp $(RTE_OUTPUT)/.config.orig ; \
103                 fi ; \
104                 rm -f $(RTE_OUTPUT)/.config_tmp ; \
105         else \
106                 $(MAKE) -rRf $(RTE_SDK)/mk/rte.sdkconfig.mk notemplate; \
107         fi
108 endif
109
110 # generate a Makefile for this build directory
111 # use a relative path so it will continue to work even if we move the directory
112 SDK_RELPATH=$(shell $(RTE_SDK)/buildtools/relpath.sh $(abspath $(RTE_SRCDIR)) \
113                                 $(abspath $(RTE_OUTPUT)))
114 OUTPUT_RELPATH=$(shell $(RTE_SDK)/buildtools/relpath.sh $(abspath $(RTE_OUTPUT)) \
115                                 $(abspath $(RTE_SRCDIR)))
116 $(RTE_OUTPUT)/Makefile: | $(RTE_OUTPUT)
117         $(Q)$(RTE_SDK)/buildtools/gen-build-mk.sh $(SDK_RELPATH) $(OUTPUT_RELPATH) \
118                 > $(RTE_OUTPUT)/Makefile
119
120 # clean installed files, and generate a new config header file
121 # if NODOTCONF variable is defined, don't try to rebuild .config
122 $(RTE_OUTPUT)/include/rte_config.h: $(RTE_OUTPUT)/.config
123         $(Q)rm -rf $(RTE_OUTPUT)/include $(RTE_OUTPUT)/app \
124                 $(RTE_OUTPUT)/lib \
125                 $(RTE_OUTPUT)/hostlib $(RTE_OUTPUT)/kmod $(RTE_OUTPUT)/build
126         $(Q)mkdir -p $(RTE_OUTPUT)/include
127         $(Q)$(RTE_SDK)/buildtools/gen-config-h.sh $(RTE_OUTPUT)/.config \
128                 > $(RTE_OUTPUT)/include/rte_config.h
129
130 # generate the rte_config.h
131 .PHONY: headerconfig
132 headerconfig: $(RTE_OUTPUT)/include/rte_config.h
133         @true
134
135 # check that .config is present, and if yes, check that rte_config.h
136 # is up to date
137 .PHONY: checkconfig
138 checkconfig:
139         @if [ ! -f $(RTE_OUTPUT)/.config ]; then \
140                 echo "No .config in build directory"; \
141                 exit 1; \
142         fi
143         $(Q)$(MAKE) -f $(RTE_SDK)/mk/rte.sdkconfig.mk \
144                 headerconfig NODOTCONF=1
145
146 .PHONY: FORCE
147 FORCE: