1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2010-2014 Intel Corporation
5 # This .mk is the generic target rte.var.mk ; it includes .mk for
6 # the specified machine, architecture, toolchain (compiler) and
7 # executive environment.
13 # - define CC, LD, AR, AS, ...
14 # - define TOOLCHAIN_CFLAGS variable (overridden by cmdline value)
15 # - define TOOLCHAIN_LDFLAGS variable (overridden by cmdline value)
16 # - define TOOLCHAIN_ASFLAGS variable (overridden by cmdline value)
17 # - may override any previously defined variable
19 include $(RTE_SDK)/mk/toolchain/$(RTE_TOOLCHAIN)/rte.vars.mk
24 # - can define ARCH variable (overridden by cmdline value)
25 # - can define CROSS variable (overridden by cmdline value)
26 # - define MACHINE_CFLAGS variable (overridden by cmdline value)
27 # - define MACHINE_LDFLAGS variable (overridden by cmdline value)
28 # - define MACHINE_ASFLAGS variable (overridden by cmdline value)
29 # - can define CPU_CFLAGS variable (overridden by cmdline value) that
30 # overrides the one defined in arch.
31 # - can define CPU_LDFLAGS variable (overridden by cmdline value) that
32 # overrides the one defined in arch.
33 # - can define CPU_ASFLAGS variable (overridden by cmdline value) that
34 # overrides the one defined in arch.
36 ifneq ($(wildcard $(RTE_SDK)/mk/machine/$(RTE_MACHINE)/rte.vars.mk),)
37 include $(RTE_SDK)/mk/machine/$(RTE_MACHINE)/rte.vars.mk
39 MACHINE_CFLAGS := -march=$(RTE_MACHINE)
45 # - define ARCH variable (overridden by cmdline or by previous
46 # optional define in machine .mk)
47 # - define CROSS variable (overridden by cmdline or previous define
49 # - define CPU_CFLAGS variable (overridden by cmdline or previous
50 # define in machine .mk)
51 # - define CPU_LDFLAGS variable (overridden by cmdline or previous
52 # define in machine .mk)
53 # - define CPU_ASFLAGS variable (overridden by cmdline or previous
54 # define in machine .mk)
55 # - may override any previously defined variable
57 include $(RTE_SDK)/mk/arch/$(RTE_ARCH)/rte.vars.mk
62 # - define EXECENV_CFLAGS variable (overridden by cmdline)
63 # - define EXECENV_LDFLAGS variable (overridden by cmdline)
64 # - define EXECENV_ASFLAGS variable (overridden by cmdline)
65 # - may override any previously defined variable
67 include $(RTE_SDK)/mk/exec-env/$(RTE_EXEC_ENV)/rte.vars.mk
69 # Don't set CFLAGS/LDFLAGS flags for kernel module, all flags are
70 # provided by Kbuild framework.
71 ifeq ($(KERNELRELEASE),)
73 # now that the environment is mostly set up, including the machine type we will
74 # be passing to the compiler, set up the specific CPU flags based on that info.
75 include $(RTE_SDK)/mk/rte.cpuflags.mk
78 CFLAGS := $(CPU_CFLAGS) $(EXECENV_CFLAGS) $(TOOLCHAIN_CFLAGS) $(MACHINE_CFLAGS)
79 CFLAGS += $(TARGET_CFLAGS)
82 LDFLAGS := $(CPU_LDFLAGS) $(EXECENV_LDFLAGS) $(TOOLCHAIN_LDFLAGS) $(MACHINE_LDFLAGS)
83 LDFLAGS += $(TARGET_LDFLAGS)
86 ASFLAGS := $(CPU_ASFLAGS) $(EXECENV_ASFLAGS) $(TOOLCHAIN_ASFLAGS) $(MACHINE_ASFLAGS)
87 ASFLAGS += $(TARGET_ASFLAGS)
89 # add default include and lib paths
90 CFLAGS += -I$(RTE_OUTPUT)/include
91 LDFLAGS += -L$(RTE_OUTPUT)/lib
93 # add in flag for supporting function versioning. The define is used in meson
94 # builds to ensure that the user has properly flagged the unit in question as
95 # using function versioning so it can be built twice - once for static lib and
96 # then a second time for the shared lib. Since make only builds one library
97 # type at a time, such precautions aren't necessary, so we can globally define
99 CFLAGS += -DRTE_USE_FUNCTION_VERSIONING
101 # always include rte_config.h: the one in $(RTE_OUTPUT)/include is
102 # the configuration of SDK when $(BUILDING_RTE_SDK) is true, or the
103 # configuration of the application if $(BUILDING_RTE_SDK) is not
105 ifeq ($(BUILDING_RTE_SDK),1)
107 CFLAGS += -include $(RTE_OUTPUT)/include/rte_config.h
109 # if we are building an external application, include SDK's lib and
111 CFLAGS += -I$(RTE_SDK_BIN)/include
112 ifneq ($(wildcard $(RTE_OUTPUT)/include/rte_config.h),)
113 CFLAGS += -include $(RTE_OUTPUT)/include/rte_config.h
115 CFLAGS += -include $(RTE_SDK_BIN)/include/rte_config.h
116 LDFLAGS += -L$(RTE_SDK_BIN)/lib
119 # always define _GNU_SOURCE
120 CFLAGS += -D_GNU_SOURCE
122 # define __BSD_VISIBLE when building for FreeBSD
123 ifeq ($(CONFIG_RTE_EXEC_ENV_FREEBSD),y)
124 CFLAGS += -D__BSD_VISIBLE