igb: rename pmd driver as e1000
[dpdk.git] / mk / rte.app.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 include $(RTE_SDK)/mk/internal/rte.compile-pre.mk
34 include $(RTE_SDK)/mk/internal/rte.install-pre.mk
35 include $(RTE_SDK)/mk/internal/rte.clean-pre.mk
36 include $(RTE_SDK)/mk/internal/rte.build-pre.mk
37 include $(RTE_SDK)/mk/internal/rte.depdirs-pre.mk
38
39 # VPATH contains at least SRCDIR
40 VPATH += $(SRCDIR)
41
42 _BUILD = $(APP)
43 _INSTALL = $(INSTALL-FILES-y) $(SYMLINK-FILES-y)
44 _INSTALL += $(RTE_OUTPUT)/app/$(APP) $(RTE_OUTPUT)/app/$(APP).map
45 POSTINSTALL += target-appinstall
46 _CLEAN = doclean
47 POSTCLEAN += target-appclean
48
49 ifeq ($(NO_LDSCRIPT),)
50 LDSCRIPT = $(RTE_LDSCRIPT)
51 endif
52
53 # default path for libs
54 LDLIBS += -L$(RTE_SDK_BIN)/lib
55
56 #
57 # Include libraries depending on config if NO_AUTOLIBS is not set
58 # Order is important: from higher level to lower level
59 #
60 ifeq ($(NO_AUTOLIBS),)
61
62 ifeq ($(CONFIG_RTE_LIBRTE_KNI),y)
63 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
64 LDLIBS += -lrte_kni
65 endif
66 endif
67
68 ifeq ($(CONFIG_RTE_LIBRTE_E1000_PMD),y)
69 LDLIBS += -lrte_pmd_e1000
70 endif
71
72 ifeq ($(CONFIG_RTE_LIBRTE_IXGBE_PMD),y)
73 LDLIBS += -lrte_pmd_ixgbe
74 endif
75
76 ifeq ($(CONFIG_RTE_LIBRTE_MBUF),y)
77 LDLIBS += -lrte_mbuf
78 endif
79
80 ifeq ($(CONFIG_RTE_LIBRTE_CMDLINE),y)
81 LDLIBS += -lrte_cmdline
82 endif
83
84 ifeq ($(CONFIG_RTE_LIBRTE_TIMER),y)
85 LDLIBS += -lrte_timer
86 endif
87
88 ifeq ($(CONFIG_RTE_LIBRTE_HASH),y)
89 LDLIBS += -lrte_hash
90 endif
91
92 ifeq ($(CONFIG_RTE_LIBRTE_LPM),y)
93 LDLIBS += -lrte_lpm
94 endif
95
96 LDLIBS += --start-group
97
98 ifeq ($(CONFIG_RTE_LIBRTE_ETHER),y)
99 LDLIBS += -lethdev
100 endif
101
102 ifeq ($(CONFIG_RTE_LIBRTE_MALLOC),y)
103 LDLIBS += -lrte_malloc
104 endif
105
106 ifeq ($(CONFIG_RTE_LIBRTE_MEMPOOL),y)
107 LDLIBS += -lrte_mempool
108 endif
109
110 ifeq ($(CONFIG_RTE_LIBRTE_RING),y)
111 LDLIBS += -lrte_ring
112 endif
113
114 ifeq ($(CONFIG_RTE_LIBC),y)
115 LDLIBS += -lc
116 endif
117
118 ifeq ($(CONFIG_RTE_LIBGLOSS),y)
119 LDLIBS += -lgloss
120 endif
121
122 ifeq ($(CONFIG_RTE_LIBRTE_EAL),y)
123 LDLIBS += -lrte_eal
124 endif
125
126 LDLIBS += $(EXECENV_LDLIBS)
127
128 LDLIBS += --end-group
129
130 endif # ifeq ($(NO_AUTOLIBS),)
131
132 LDLIBS += $(CPU_LDLIBS)
133
134 .PHONY: all
135 all: install
136
137 .PHONY: install
138 install: build _postinstall
139
140 _postinstall: build
141
142 .PHONY: build
143 build: _postbuild
144
145 exe2cmd = $(strip $(call dotfile,$(patsubst %,%.cmd,$(1))))
146
147 ifeq ($(LINK_USING_CC),1)
148 comma := ,
149 LDLIBS := $(addprefix -Wl$(comma),$(LDLIBS))
150 LDFLAGS := $(addprefix -Wl$(comma),$(LDFLAGS))
151 EXTRA_LDFLAGS := $(addprefix -Wl$(comma),$(EXTRA_LDFLAGS))
152 O_TO_EXE = $(CC) $(CFLAGS) $(LDFLAGS_$(@)) \
153         -Wl,-Map=$(@).map,--cref -o $@ $(OBJS-y) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDLIBS)
154 else
155 O_TO_EXE = $(LD) $(LDFLAGS) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \
156         -Map=$(@).map --cref -o $@ $(OBJS-y) $(LDLIBS)
157 endif
158 O_TO_EXE_STR = $(subst ','\'',$(O_TO_EXE)) #'# fix syntax highlight
159 O_TO_EXE_DISP = $(if $(V),"$(O_TO_EXE_STR)","  LD $(@)")
160 O_TO_EXE_CMD = "cmd_$@ = $(O_TO_EXE_STR)"
161 O_TO_EXE_DO = @set -e; \
162         echo $(O_TO_EXE_DISP); \
163         $(O_TO_EXE) && \
164         echo $(O_TO_EXE_CMD) > $(call exe2cmd,$(@))
165
166 -include .$(APP).cmd
167
168 # path where libraries are retrieved
169 LDLIBS_PATH := $(subst -Wl$(comma)-L,,$(filter -Wl$(comma)-L%,$(LDLIBS)))
170 LDLIBS_PATH += $(subst -L,,$(filter -L%,$(LDLIBS)))
171
172 # list of .a files that are linked to this application
173 LDLIBS_NAMES := $(patsubst -l%,lib%.a,$(filter -l%,$(LDLIBS)))
174 LDLIBS_NAMES += $(patsubst -Wl$(comma)-l%,lib%.a,$(filter -Wl$(comma)-l%,$(LDLIBS)))
175
176 # list of found libraries files (useful for deps). If not found, the
177 # library is silently ignored and dep won't be checked
178 LDLIBS_FILES := $(wildcard $(foreach dir,$(LDLIBS_PATH),\
179         $(addprefix $(dir)/,$(LDLIBS_NAMES))))
180
181 #
182 # Compile executable file if needed
183 #
184 $(APP): $(OBJS-y) $(LDLIBS_FILES) $(DEP_$(APP)) $(LDSCRIPT) FORCE
185         @[ -d $(dir $@) ] || mkdir -p $(dir $@)
186         $(if $(D),\
187                 @echo -n "$< -> $@ " ; \
188                 echo -n "file_missing=$(call boolean,$(file_missing)) " ; \
189                 echo -n "cmdline_changed=$(call boolean,$(call cmdline_changed,$(O_TO_EXE_STR))) " ; \
190                 echo -n "depfile_missing=$(call boolean,$(depfile_missing)) " ; \
191                 echo "depfile_newer=$(call boolean,$(depfile_newer)) ")
192         $(if $(or \
193                 $(file_missing),\
194                 $(call cmdline_changed,$(O_TO_EXE_STR)),\
195                 $(depfile_missing),\
196                 $(depfile_newer)),\
197                 $(O_TO_EXE_DO))
198
199 #
200 # install app in $(RTE_OUTPUT)/app
201 #
202 $(RTE_OUTPUT)/app/$(APP): $(APP)
203         @echo "  INSTALL-APP $(APP)"
204         @[ -d $(RTE_OUTPUT)/app ] || mkdir -p $(RTE_OUTPUT)/app
205         $(Q)cp -f $(APP) $(RTE_OUTPUT)/app
206
207 #
208 # install app map file in $(RTE_OUTPUT)/app
209 #
210 $(RTE_OUTPUT)/app/$(APP).map: $(APP)
211         @echo "  INSTALL-MAP $(APP).map"
212         @[ -d $(RTE_OUTPUT)/app ] || mkdir -p $(RTE_OUTPUT)/app
213         $(Q)cp -f $(APP).map $(RTE_OUTPUT)/app
214
215 #
216 # Clean all generated files
217 #
218 .PHONY: clean
219 clean: _postclean
220         $(Q)rm -f $(_BUILD_TARGETS) $(_INSTALL_TARGETS) $(_CLEAN_TARGETS)
221
222 .PHONY: doclean
223 doclean:
224         $(Q)rm -rf $(APP) $(OBJS-all) $(DEPS-all) $(DEPSTMP-all) \
225           $(CMDS-all) $(INSTALL-FILES-all) .$(APP).cmd
226
227
228 include $(RTE_SDK)/mk/internal/rte.compile-post.mk
229 include $(RTE_SDK)/mk/internal/rte.install-post.mk
230 include $(RTE_SDK)/mk/internal/rte.clean-post.mk
231 include $(RTE_SDK)/mk/internal/rte.build-post.mk
232 include $(RTE_SDK)/mk/internal/rte.depdirs-post.mk
233
234 ifneq ($(wildcard $(RTE_SDK)/mk/target/$(RTE_TARGET)/rte.app.mk),)
235 include $(RTE_SDK)/mk/target/$(RTE_TARGET)/rte.app.mk
236 else
237 include $(RTE_SDK)/mk/target/generic/rte.app.mk
238 endif
239
240 .PHONY: FORCE
241 FORCE: