devtools: use a common prefix for temporary files
[dpdk.git] / mk / rte.hostlib.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 = $(HOSTLIB)
15 _INSTALL = $(INSTALL-FILES-y) $(SYMLINK-FILES-y) $(RTE_OUTPUT)/hostlib/$(HOSTLIB)
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_A = $(AR) crus $(HOSTLIB) $(OBJS-y)
32 O_TO_A_STR = $(subst ','\'',$(O_TO_A)) #'# fix syntax highlight
33 O_TO_A_DISP = $(if $(V),"$(O_TO_A_STR)","  HOSTAR $(@)")
34 O_TO_A_CMD = "cmd_$@ = $(O_TO_A_STR)"
35 O_TO_A_DO = @set -e; \
36         echo $(O_TO_A_DISP); \
37         $(O_TO_A) && \
38         echo $(O_TO_A_CMD) > $(call exe2cmd,$(@))
39
40 -include .$(HOSTLIB).cmd
41
42 #
43 # Archive objects in .a file if needed
44 #
45 $(HOSTLIB): $(OBJS-y) FORCE
46         @[ -d $(dir $@) ] || mkdir -p $(dir $@)
47         $(if $(D),\
48                 @echo -n "$@ -> $< " ; \
49                 echo -n "file_missing=$(call boolean,$(file_missing)) " ; \
50                 echo -n "cmdline_changed=$(call boolean,$(call cmdline_changed,$(O_TO_A_STR))) " ; \
51                 echo -n "depfile_missing=$(call boolean,$(depfile_missing)) " ; \
52                 echo "depfile_newer=$(call boolean,$(depfile_newer)) ")
53         $(if $(or \
54                 $(file_missing),\
55                 $(call cmdline_changed,$(O_TO_A_STR)),\
56                 $(depfile_missing),\
57                 $(depfile_newer)),\
58                 $(O_TO_A_DO))
59
60 #
61 # install lib in $(RTE_OUTPUT)/hostlib
62 #
63 $(RTE_OUTPUT)/hostlib/$(HOSTLIB): $(HOSTLIB)
64         @echo "  INSTALL-HOSTLIB $(HOSTLIB)"
65         @[ -d $(RTE_OUTPUT)/hostlib ] || mkdir -p $(RTE_OUTPUT)/hostlib
66         $(Q)cp -f $(HOSTLIB) $(RTE_OUTPUT)/hostlib
67
68 #
69 # Clean all generated files
70 #
71 .PHONY: clean
72 clean: _postclean
73
74 .PHONY: doclean
75 doclean:
76         $(Q)rm -rf $(HOSTLIB) $(OBJS-all) $(DEPS-all) $(DEPSTMP-all) \
77           $(CMDS-all) $(INSTALL-FILES-all)
78         $(Q)rm -f $(_BUILD_TARGETS) $(_INSTALL_TARGETS) $(_CLEAN_TARGETS)
79
80 include $(RTE_SDK)/mk/internal/rte.compile-post.mk
81 include $(RTE_SDK)/mk/internal/rte.install-post.mk
82 include $(RTE_SDK)/mk/internal/rte.clean-post.mk
83 include $(RTE_SDK)/mk/internal/rte.build-post.mk
84
85 .PHONY: FORCE
86 FORCE: