mac80211: brcmfmac: update Raspberry Pi patches for linux 4.9
[openwrt/openwrt.git] / include / unpack.mk
1 #
2 # Copyright (C) 2006-2007 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 HOST_TAR:=$(TAR)
9 TAR_CMD=$(HOST_TAR) -C $(1)/.. $(TAR_OPTIONS)
10 UNZIP_CMD=unzip -q -d $(1)/.. $(DL_DIR)/$(PKG_SOURCE)
11
12 ifeq ($(PKG_SOURCE),)
13 PKG_UNPACK ?= true
14 else
15
16 ifeq ($(strip $(UNPACK_CMD)),)
17 ifeq ($(strip $(PKG_CAT)),)
18 # try to autodetect file type
19 EXT:=$(call ext,$(PKG_SOURCE))
20 EXT1:=$(EXT)
21
22 ifeq ($(filter gz tgz,$(EXT)),$(EXT))
23 EXT:=$(call ext,$(PKG_SOURCE:.$(EXT)=))
24 DECOMPRESS_CMD:=gzip -dc $(DL_DIR)/$(PKG_SOURCE) |
25 endif
26 ifeq ($(filter bzip2 bz2 bz tbz2 tbz,$(EXT)),$(EXT))
27 EXT:=$(call ext,$(PKG_SOURCE:.$(EXT)=))
28 DECOMPRESS_CMD:=bzcat $(DL_DIR)/$(PKG_SOURCE) |
29 endif
30 ifeq ($(filter xz txz,$(EXT)),$(EXT))
31 EXT:=$(call ext,$(PKG_SOURCE:.$(EXT)=))
32 DECOMPRESS_CMD:=xzcat $(DL_DIR)/$(PKG_SOURCE) |
33 endif
34 ifeq ($(filter tgz tbz tbz2 txz,$(EXT1)),$(EXT1))
35 EXT:=tar
36 endif
37 DECOMPRESS_CMD ?= cat $(DL_DIR)/$(PKG_SOURCE) |
38 ifeq ($(EXT),tar)
39 UNPACK_CMD=$(DECOMPRESS_CMD) $(TAR_CMD)
40 endif
41 ifeq ($(EXT),cpio)
42 UNPACK_CMD=$(DECOMPRESS_CMD) (cd $(1)/..; cpio -i -d)
43 endif
44 ifeq ($(EXT),zip)
45 UNPACK_CMD=$(UNZIP_CMD)
46 endif
47 endif
48
49 # compatibility code for packages that set PKG_CAT
50 ifeq ($(strip $(UNPACK_CMD)),)
51 # use existing PKG_CAT
52 UNPACK_CMD=$(PKG_CAT) $(DL_DIR)/$(PKG_SOURCE) | $(TAR_CMD)
53 ifeq ($(PKG_CAT),unzip)
54 UNPACK_CMD=$(UNZIP_CMD)
55 endif
56 # replace zcat with $(ZCAT), because some system don't support it properly
57 ifeq ($(PKG_CAT),zcat)
58 UNPACK_CMD=gzip -dc $(DL_DIR)/$(PKG_SOURCE) | $(TAR_CMD)
59 endif
60 endif
61 ifneq ($(strip $(CRLF_WORKAROUND)),)
62 CRLF_CMD := && find $(PKG_BUILD_DIR) -type f -print0 | xargs -0 perl -pi -e 's!\r$$$$!!g'
63 else
64 CRLF_CMD :=
65 endif
66 endif
67
68 ifdef PKG_BUILD_DIR
69 PKG_UNPACK ?= $(SH_FUNC) $(call UNPACK_CMD,$(PKG_BUILD_DIR)) $(call CRLF_CMD,$(PKG_BUILD_DIR))
70 endif
71 ifdef HOST_BUILD_DIR
72 HOST_UNPACK ?= $(SH_FUNC) $(call UNPACK_CMD,$(HOST_BUILD_DIR)) $(call CRLF_CMD,$(HOST_BUILD_DIR))
73 endif
74
75 endif # PKG_SOURCE
76