84649b9b186cac33010cbc225dc2fb87e3a61233
[deb_dpdk.git] / mk / target / generic / rte.vars.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 #
33 # This .mk is the generic target rte.var.mk ; it includes .mk for
34 # the specified machine, architecture, toolchain (compiler) and
35 # executive environment.
36 #
37
38 #
39 # machine:
40 #
41 #   - can define ARCH variable (overridden by cmdline value)
42 #   - can define CROSS variable (overridden by cmdline value)
43 #   - define MACHINE_CFLAGS variable (overridden by cmdline value)
44 #   - define MACHINE_LDFLAGS variable (overridden by cmdline value)
45 #   - define MACHINE_ASFLAGS variable (overridden by cmdline value)
46 #   - can define CPU_CFLAGS variable (overridden by cmdline value) that
47 #     overrides the one defined in arch.
48 #   - can define CPU_LDFLAGS variable (overridden by cmdline value) that
49 #     overrides the one defined in arch.
50 #   - can define CPU_ASFLAGS variable (overridden by cmdline value) that
51 #     overrides the one defined in arch.
52 #
53 ifneq ($(wildcard $(RTE_SDK)/mk/machine/$(RTE_MACHINE)/rte.vars.mk),)
54 include $(RTE_SDK)/mk/machine/$(RTE_MACHINE)/rte.vars.mk
55 else
56 MACHINE_CFLAGS := -march=$(RTE_MACHINE)
57 endif
58
59 #
60 # arch:
61 #
62 #   - define ARCH variable (overridden by cmdline or by previous
63 #     optional define in machine .mk)
64 #   - define CROSS variable (overridden by cmdline or previous define
65 #     in machine .mk)
66 #   - define CPU_CFLAGS variable (overridden by cmdline or previous
67 #     define in machine .mk)
68 #   - define CPU_LDFLAGS variable (overridden by cmdline or previous
69 #     define in machine .mk)
70 #   - define CPU_ASFLAGS variable (overridden by cmdline or previous
71 #     define in machine .mk)
72 #   - may override any previously defined variable
73 #
74 include $(RTE_SDK)/mk/arch/$(RTE_ARCH)/rte.vars.mk
75
76 #
77 # toolchain:
78 #
79 #   - define CC, LD, AR, AS, ...
80 #   - define TOOLCHAIN_CFLAGS variable (overridden by cmdline value)
81 #   - define TOOLCHAIN_LDFLAGS variable (overridden by cmdline value)
82 #   - define TOOLCHAIN_ASFLAGS variable (overridden by cmdline value)
83 #   - may override any previously defined variable
84 #
85 include $(RTE_SDK)/mk/toolchain/$(RTE_TOOLCHAIN)/rte.vars.mk
86
87 #
88 # exec-env:
89 #
90 #   - define EXECENV_CFLAGS variable (overridden by cmdline)
91 #   - define EXECENV_LDFLAGS variable (overridden by cmdline)
92 #   - define EXECENV_ASFLAGS variable (overridden by cmdline)
93 #   - may override any previously defined variable
94 #
95 include $(RTE_SDK)/mk/exec-env/$(RTE_EXEC_ENV)/rte.vars.mk
96
97 # Don't set CFLAGS/LDFLAGS flags for kernel module, all flags are
98 # provided by Kbuild framework.
99 ifeq ($(KERNELRELEASE),)
100
101 # now that the environment is mostly set up, including the machine type we will
102 # be passing to the compiler, set up the specific CPU flags based on that info.
103 include $(RTE_SDK)/mk/rte.cpuflags.mk
104
105 # merge all CFLAGS
106 CFLAGS := $(CPU_CFLAGS) $(EXECENV_CFLAGS) $(TOOLCHAIN_CFLAGS) $(MACHINE_CFLAGS)
107 CFLAGS += $(TARGET_CFLAGS)
108
109 # merge all LDFLAGS
110 LDFLAGS := $(CPU_LDFLAGS) $(EXECENV_LDFLAGS) $(TOOLCHAIN_LDFLAGS) $(MACHINE_LDFLAGS)
111 LDFLAGS += $(TARGET_LDFLAGS)
112
113 # merge all ASFLAGS
114 ASFLAGS := $(CPU_ASFLAGS) $(EXECENV_ASFLAGS) $(TOOLCHAIN_ASFLAGS) $(MACHINE_ASFLAGS)
115 ASFLAGS += $(TARGET_ASFLAGS)
116
117 # add default include and lib paths
118 CFLAGS += -I$(RTE_OUTPUT)/include
119 LDFLAGS += -L$(RTE_OUTPUT)/lib
120
121 # always include rte_config.h: the one in $(RTE_OUTPUT)/include is
122 # the configuration of SDK when $(BUILDING_RTE_SDK) is true, or the
123 # configuration of the application if $(BUILDING_RTE_SDK) is not
124 # defined.
125 ifeq ($(BUILDING_RTE_SDK),1)
126 # building sdk
127 CFLAGS += -include $(RTE_OUTPUT)/include/rte_config.h
128 else
129 # if we are building an external application, include SDK's lib and
130 # includes too
131 CFLAGS += -I$(RTE_SDK_BIN)/include
132 ifneq ($(wildcard $(RTE_OUTPUT)/include/rte_config.h),)
133 CFLAGS += -include $(RTE_OUTPUT)/include/rte_config.h
134 endif
135 CFLAGS += -include $(RTE_SDK_BIN)/include/rte_config.h
136 LDFLAGS += -L$(RTE_SDK_BIN)/lib
137 endif
138
139 export CFLAGS
140 export LDFLAGS
141
142 endif