unify tools naming
[dpdk.git] / mk / rte.sdkinstall.mk
1 #   BSD LICENSE
2 #
3 #   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
4 #   Copyright 2015 6WIND S.A.
5 #   All rights reserved.
6 #
7 #   Redistribution and use in source and binary forms, with or without
8 #   modification, are permitted provided that the following conditions
9 #   are met:
10 #
11 #     * Redistributions of source code must retain the above copyright
12 #       notice, this list of conditions and the following disclaimer.
13 #     * Redistributions in binary form must reproduce the above copyright
14 #       notice, this list of conditions and the following disclaimer in
15 #       the documentation and/or other materials provided with the
16 #       distribution.
17 #     * Neither the name of Intel Corporation nor the names of its
18 #       contributors may be used to endorse or promote products derived
19 #       from this software without specific prior written permission.
20 #
21 #   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 #   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 #   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 #   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 #   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 #   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 #   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 #   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 #   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 #   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 #   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
33 # Configuration, compilation and installation can be done at once
34 # with make install T=<config>
35
36 ifdef T # config, build and install combined
37 # The build directory is T and may be prepended with O
38 O ?= .
39 RTE_OUTPUT := $O/$T
40 else # standard install
41 # Build directory is given with O=
42 O ?= build
43 RTE_OUTPUT := $O
44 endif
45
46 ifneq ($(MAKECMDGOALS),pre_install)
47 include $(RTE_SDK)/mk/rte.vars.mk
48 endif
49
50 ifdef T # defaults with T= will install an almost flat staging tree
51 export prefix ?=
52 kerneldir   ?= $(prefix)/kmod
53 else
54 ifeq ($(RTE_EXEC_ENV),linuxapp)
55 kerneldir   ?= /lib/modules/$(shell uname -r)/extra/dpdk
56 else
57 kerneldir   ?= /boot/modules
58 endif
59 prefix      ?=     /usr/local
60 endif
61 exec_prefix ?=      $(prefix)
62 bindir      ?= $(exec_prefix)/bin
63 sbindir     ?= $(exec_prefix)/sbin
64 libdir      ?= $(exec_prefix)/lib
65 includedir  ?=      $(prefix)/include/dpdk
66 datarootdir ?=      $(prefix)/share
67 docdir      ?=       $(datarootdir)/doc/dpdk
68 datadir     ?=       $(datarootdir)/dpdk
69 sdkdir      ?=                $(datadir)
70 targetdir   ?=                $(datadir)/$(RTE_TARGET)
71
72 # The install directories may be staged in DESTDIR
73
74 # Create the directory $1 if not exists
75 rte_mkdir = test -d $1 || mkdir -p $1
76
77 # Create the relative symbolic link $2 -> $1
78 # May be replaced with --relative option of ln from coreutils-8.16
79 rte_symlink = ln -snf $$($(RTE_SDK)/scripts/relpath.sh $1 $(dir $2)) $2
80
81 .PHONY: pre_install
82 pre_install:
83 ifdef T
84         $(Q)if [ ! -f $(RTE_OUTPUT)/.config ]; then \
85                 $(MAKE) config O=$(RTE_OUTPUT); \
86         elif cmp -s $(RTE_OUTPUT)/.config.orig $(RTE_OUTPUT)/.config; then \
87                 $(MAKE) config O=$(RTE_OUTPUT); \
88         else \
89                 if [ -f $(RTE_OUTPUT)/.config.orig ] ; then \
90                         tmp_build=$(RTE_OUTPUT)/.config.tmp; \
91                         $(MAKE) config O=$$tmp_build; \
92                         if ! cmp -s $(RTE_OUTPUT)/.config.orig $$tmp_build/.config ; then \
93                                 echo "Conflict: local config and template config have both changed"; \
94                                 exit 1; \
95                         fi; \
96                 fi; \
97                 echo "Using local configuration"; \
98         fi
99         $(Q)$(MAKE) all O=$(RTE_OUTPUT)
100 endif
101
102 .PHONY: install
103 install:
104 ifeq ($(DESTDIR)$(if $T,,+),)
105         @echo Installation cannot run with T defined and DESTDIR undefined
106 else
107         @echo ================== Installing $(DESTDIR)$(prefix)/
108         $(Q)$(MAKE) O=$(RTE_OUTPUT) T= install-runtime
109         $(Q)$(MAKE) O=$(RTE_OUTPUT) T= install-kmod
110         $(Q)$(MAKE) O=$(RTE_OUTPUT) T= install-sdk
111         $(Q)$(MAKE) O=$(RTE_OUTPUT) T= install-doc
112         @echo Installation in $(DESTDIR)$(prefix)/ complete
113 endif
114
115 install-runtime:
116         $(Q)$(call rte_mkdir, $(DESTDIR)$(libdir))
117         $(Q)cp -a    $O/lib/* $(DESTDIR)$(libdir)
118         $(Q)$(call rte_mkdir, $(DESTDIR)$(bindir))
119         $(Q)tar -cf -      -C $O --exclude 'app/*.map' \
120                 --exclude app/dpdk-pmdinfogen \
121                 --exclude 'app/cmdline*' --exclude app/test \
122                 --exclude app/testacl --exclude app/testpipeline app | \
123             tar -xf -      -C $(DESTDIR)$(bindir) --strip-components=1 \
124                 --keep-newer-files --warning=no-ignore-newer
125         $(Q)$(call rte_mkdir,      $(DESTDIR)$(datadir))
126         $(Q)cp -a $(RTE_SDK)/tools $(DESTDIR)$(datadir)
127         $(Q)$(call rte_symlink,    $(DESTDIR)$(datadir)/tools/dpdk-setup.sh, \
128                                    $(DESTDIR)$(datadir)/tools/setup.sh)
129         $(Q)$(call rte_symlink,    $(DESTDIR)$(datadir)/tools/dpdk-devbind.py, \
130                                    $(DESTDIR)$(datadir)/tools/dpdk_nic_bind.py)
131         $(Q)$(call rte_mkdir,      $(DESTDIR)$(sbindir))
132         $(Q)$(call rte_symlink,    $(DESTDIR)$(datadir)/tools/dpdk-devbind.py, \
133                                    $(DESTDIR)$(sbindir)/dpdk-devbind)
134         $(Q)$(call rte_symlink,    $(DESTDIR)$(datadir)/tools/dpdk-pmdinfo.py, \
135                                    $(DESTDIR)$(bindir)/dpdk-pmdinfo)
136
137 install-kmod:
138 ifneq ($(wildcard $O/kmod/*),)
139         $(Q)$(call rte_mkdir, $(DESTDIR)$(kerneldir))
140         $(Q)cp -a   $O/kmod/* $(DESTDIR)$(kerneldir)
141 endif
142
143 install-sdk:
144         $(Q)$(call rte_mkdir, $(DESTDIR)$(includedir))
145         $(Q)tar -chf -     -C $O include | \
146             tar -xf -      -C $(DESTDIR)$(includedir) --strip-components=1 \
147                 --keep-newer-files --warning=no-ignore-newer
148         $(Q)$(call rte_mkdir,                            $(DESTDIR)$(sdkdir))
149         $(Q)cp -a               $(RTE_SDK)/mk            $(DESTDIR)$(sdkdir)
150         $(Q)cp -a               $(RTE_SDK)/scripts       $(DESTDIR)$(sdkdir)
151         $(Q)$(call rte_mkdir,                            $(DESTDIR)$(targetdir)/app)
152         $(Q)cp -a               $O/.config               $(DESTDIR)$(targetdir)
153         $(Q)cp -a               $O/app/dpdk-pmdinfogen   $(DESTDIR)$(targetdir)/app
154         $(Q)$(call rte_symlink, $(DESTDIR)$(includedir), $(DESTDIR)$(targetdir)/include)
155         $(Q)$(call rte_symlink, $(DESTDIR)$(libdir),     $(DESTDIR)$(targetdir)/lib)
156
157 install-doc:
158 ifneq ($(wildcard $O/doc),)
159         $(Q)$(call rte_mkdir, $(DESTDIR)$(docdir))
160         $(Q)tar -cf -      -C $O/doc html --exclude 'html/guides/.*' | \
161             tar -xf -      -C $(DESTDIR)$(docdir) --strip-components=1 \
162                 --keep-newer-files --warning=no-ignore-newer
163 endif
164 ifneq ($(wildcard $O/doc/*/*/*pdf),)
165         $(Q)$(call rte_mkdir,     $(DESTDIR)$(docdir)/guides)
166         $(Q)cp -a $O/doc/*/*/*pdf $(DESTDIR)$(docdir)/guides
167 endif
168         $(Q)$(call rte_mkdir,         $(DESTDIR)$(datadir))
169         $(Q)cp -a $(RTE_SDK)/examples $(DESTDIR)$(datadir)