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