net: add MPLS header structure
[dpdk.git] / mk / rte.hostapp.mk
1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2010-2014 Intel Corporation
3
4 # tell rte.compile-pre.mk to use HOSTCC instead of CC
5 USE_HOST := 1
6 include $(RTE_SDK)/mk/internal/rte.compile-pre.mk
7 include $(RTE_SDK)/mk/internal/rte.install-pre.mk
8 include $(RTE_SDK)/mk/internal/rte.clean-pre.mk
9 include $(RTE_SDK)/mk/internal/rte.build-pre.mk
10
11 # VPATH contains at least SRCDIR
12 VPATH += $(SRCDIR)
13
14 _BUILD = $(HOSTAPP)
15 _INSTALL = $(INSTALL-FILES-y) $(SYMLINK-FILES-y) $(RTE_OUTPUT)/app/$(HOSTAPP)
16 _CLEAN = doclean
17
18 .PHONY: all
19 all: install
20
21 .PHONY: install
22 install: build _postinstall
23
24 _postinstall: build
25
26 .PHONY: build
27 build: _postbuild
28
29 exe2cmd = $(strip $(call dotfile,$(patsubst %,%.cmd,$(1))))
30
31 O_TO_EXE = $(HOSTCC) $(HOST_LDFLAGS) $(LDFLAGS_$(@)) \
32         $(EXTRA_HOST_LDFLAGS) -o $@ $(OBJS-y) $(LDLIBS)
33 O_TO_EXE_STR = $(subst ','\'',$(O_TO_EXE)) #'# fix syntax highlight
34 O_TO_EXE_DISP = $(if $(V),"$(O_TO_EXE_STR)","  HOSTLD $(@)")
35 O_TO_EXE_CMD = "cmd_$@ = $(O_TO_EXE_STR)"
36 O_TO_EXE_DO = @set -e; \
37         echo $(O_TO_EXE_DISP); \
38         $(O_TO_EXE) && \
39         echo $(O_TO_EXE_CMD) > $(call exe2cmd,$(@))
40
41 -include .$(HOSTAPP).cmd
42
43 # list of .a files that are linked to this application
44 LDLIBS_FILES := $(sort $(wildcard \
45         $(addprefix $(RTE_OUTPUT)/lib/, \
46         $(patsubst -l%,lib%.a,$(filter -l%,$(LDLIBS))))))
47
48 #
49 # Compile executable file if needed
50 #
51 $(HOSTAPP): $(OBJS-y) $(LDLIBS_FILES) FORCE
52         @[ -d $(dir $@) ] || mkdir -p $(dir $@)
53         $(if $(D),\
54                 @echo -n "$@ -> $< " ; \
55                 echo -n "file_missing=$(call boolean,$(file_missing)) " ; \
56                 echo -n "cmdline_changed=$(call boolean,$(call cmdline_changed,$(O_TO_EXE_STR))) " ; \
57                 echo -n "depfile_missing=$(call boolean,$(depfile_missing)) " ; \
58                 echo "depfile_newer=$(call boolean,$(depfile_newer)) ")
59         $(if $(or \
60                 $(file_missing),\
61                 $(call cmdline_changed,$(O_TO_EXE_STR)),\
62                 $(depfile_missing),\
63                 $(depfile_newer)),\
64                 $(O_TO_EXE_DO))
65
66 #
67 # install app in $(RTE_OUTPUT)/hostapp
68 #
69 $(RTE_OUTPUT)/app/$(HOSTAPP): $(HOSTAPP)
70         @echo "  INSTALL-HOSTAPP $(HOSTAPP)"
71         @[ -d $(RTE_OUTPUT)/app ] || mkdir -p $(RTE_OUTPUT)/app
72         $(Q)cp -f $(HOSTAPP) $(RTE_OUTPUT)/app
73
74 #
75 # Clean all generated files
76 #
77 .PHONY: clean
78 clean: _postclean
79         $(Q)rm -f $(_BUILD_TARGETS) $(_INSTALL_TARGETS) $(_CLEAN_TARGETS)
80
81 .PHONY: doclean
82 doclean:
83         $(Q)rm -rf $(HOSTAPP) $(OBJS-all) $(DEPS-all) $(DEPSTMP-all) \
84           $(CMDS-all) $(INSTALL-FILES-all) .$(HOSTAPP).cmd
85
86
87 include $(RTE_SDK)/mk/internal/rte.compile-post.mk
88 include $(RTE_SDK)/mk/internal/rte.install-post.mk
89 include $(RTE_SDK)/mk/internal/rte.clean-post.mk
90 include $(RTE_SDK)/mk/internal/rte.build-post.mk
91
92 .PHONY: FORCE
93 FORCE: