File: Kbuild.install

package info (click to toggle)
klibc 2.0.4-9
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 5,512 kB
  • sloc: ansic: 48,305; asm: 2,578; perl: 797; makefile: 200; sh: 191
file content (118 lines) | stat: -rw-r--r-- 3,806 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#
# Install klibc
#
# File is logically seperated in two pieces.
# First piece is used when during a recursive descend of the klibc tree
# and second piece is used to do the final steps in the install
# If KLIBC_INSTALL is defined it tells us we are descending and we
# use first piece of the file.

# This indicates the location of the final version of the shared library.
# THIS MUST BE AN ABSOLUTE PATH WITH NO FINAL SLASH.
# Leave this empty to make it the root.
#
SHLIBDIR = /lib

# First rule
.PHONY: __install install-rule
__install:

# Install commands
install-data := install -m 644
install-lib  := install -m 755
install-bin  := install -m 755

# Install command
quiet_cmd_install = INSTALL $(install-y)
      cmd_install = $(install-bin) $(install-y) \
                                   $(INSTALLROOT)$(INSTALLDIR)/$(KLIBCCROSS)bin

ifeq ($(KLIBC_INSTALL),1)
# First part - we are descending..

# Reset variables (to get right type of assingment)
subdir- :=

# Include Kbuild file
include $(srctree)/scripts/Kbuild.include
include $(srctree)/$(obj)/Kbuild

# Directories to visit
# First find directories specified in lib-?, static-y and shared-y
find-dir = $(patsubst %/,%,$(filter %/, $(1)))

__subdir := $(call find-dir, $(lib-))
__subdir += $(call find-dir, $(lib-y))

__subdir += $(foreach e, $(static-y), $(call find-dir, $(e)))
__subdir += $(foreach e, $(shared-y), $(call find-dir, $(e)))

# Use subdir- in Kbuild file to tell kbuild to visit a specific dir
subdir-  += $(__subdir)

# Remove duplicates and add prefix
subdir- := $(addprefix $(obj)/,$(sort $(subdir-)))

# Files to install
install-y := $(strip $(addprefix $(obj)/, $(install-y)))

__install: $(subdir-) install-rule
ifneq ($(install-y),)
	$(call cmd,install)
else
	@:
endif

# Descending
.PHONY: $(subdir-)
$(subdir-):
	$(Q)$(MAKE) KLIBC_INSTALL=1 \
	            -f $(srctree)/scripts/Kbuild.install obj=$@

# If quiet is set, only print short version of command
cmd = @$(if $($(quiet)cmd_$(1)),echo '  $($(quiet)cmd_$(1))' &&) $(cmd_$(1))


else
##########################################################################
# This is the first time this file is invoked, so kick off the
# install process.
# First we descend all sub-directories to let them do their install.
# Second we do the final install steps.

# Do actual install as a three steps approach
# 1) Create directories, install headers and man pages
# 2) Tell that we now install binaries
# 3) Install binaries by descending
.PHONY: header footer descend
header:
	$(Q)echo "  INSTALL headers + man pages to $(INSTALLROOT)$(INSTALLDIR)"
	$(Q)mkdir -p $(INSTALLROOT)$(bindir)
	$(Q)mkdir -p $(INSTALLROOT)$(mandir)/man1
	$(Q)mkdir -p $(INSTALLROOT)$(SHLIBDIR)
	$(Q)mkdir -p $(INSTALLROOT)$(INSTALLDIR)
	$(Q)-rm -rf $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include
	$(Q)mkdir -p $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include
	$(Q)mkdir -p $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)lib
	$(Q)mkdir -p $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)bin
	$(Q)for x in /usr/include/linux /usr/include/asm*; do \
		ln -s $${x} $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include/ || exit; \
	done
	$(Q)if [ -n "$(DEB_HOST_MULTIARCH)" ]; then \
		ln -sf /usr/include/$(DEB_HOST_MULTIARCH)/asm $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include/ || exit; \
	fi
	$(Q)cp -rf usr/include/. $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include/.
	$(Q)chmod -R a+rX,go-w $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include
	$(Q)$(install-data) $(srctree)/klcc/klcc.1 $(INSTALLROOT)$(mandir)/man1/$(KCROSS)klcc.1
	$(Q)$(install-bin) $(objtree)/klcc/$(KCROSS)klcc $(INSTALLROOT)$(bindir)

footer: header
	$(Q)echo "  INSTALL binaries to $(INSTALLROOT)$(INSTALLDIR)/$(KLIBCCROSS)bin"

descend: footer
	$(Q)$(MAKE) KLIBC_INSTALL=1 \
	            -f $(srctree)/scripts/Kbuild.install obj=$(obj)

__install: descend
	@:
endif