kexec-tools: update to 2.0.26
[openwrt/openwrt.git] / package / boot / kexec-tools / Makefile
1 #
2 # Copyright (C) 2006-2012 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 include $(TOPDIR)/rules.mk
9
10 PKG_NAME:=kexec-tools
11 PKG_VERSION:=2.0.26
12 PKG_RELEASE:=1
13
14 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
15 PKG_SOURCE_URL:=@KERNEL/linux/utils/kernel/kexec
16 PKG_HASH:=7fe36a064101cd5c515e41b2be393dce3ca88adce59d6ee668e0af7c0c4570cd
17
18 PKG_CONFIG_DEPENDS := CONFIG_KEXEC_ZLIB CONFIG_KEXEC_LZMA
19
20 include $(INCLUDE_DIR)/package.mk
21
22 define Package/kexec-tools/Default
23 SECTION:=utils
24 CATEGORY:=Utilities
25 URL:=http://kernel.org/pub/linux/kernel/people/horms/kexec-tools/
26 endef
27
28 define Package/kexec-tools
29 $(call Package/kexec-tools/Default)
30 TITLE:=kexec-tools transition meta package
31 DEPENDS:=+kexec
32 endef
33
34 define Package/kexec-tools/description
35 kexec is a set of system calls that allows you to load
36 another kernel from the currently executing Linux kernel.
37 The kexec utility allows to load and boot another kernel.
38 endef
39
40 define Package/kexec
41 $(call Package/kexec-tools/Default)
42 TITLE:=Kernel boots kernel
43 DEPENDS:=\
44 @(armeb||arm||i386||x86_64||powerpc64||mipsel||mips) \
45 +KEXEC_ZLIB:zlib +KEXEC_LZMA:liblzma @KERNEL_KEXEC
46 endef
47
48 define Package/kexec/description
49 The kexec utility allows to load and boot another kernel.
50 endef
51
52 define Package/kdump
53 $(call Package/kexec-tools/Default)
54 TITLE:=Kernel crash analysis
55 DEPENDS:=+kexec @(i386||x86_64||arm) @KERNEL_CRASH_DUMP
56 endef
57
58 define Package/kdump/description
59 The kdump package allows to automatically boot into a
60 special kernel for analyzing kernel crashes using kdump.
61 endef
62
63 define Package/kexec/config
64 source "$(SOURCE)/Config.in"
65 endef
66
67 KEXEC_TARGET_NAME:=$(ARCH)-linux-$(TARGET_SUFFIX)
68
69 CONFIGURE_ARGS = \
70 --target=$(KEXEC_TARGET_NAME) \
71 --host=$(REAL_GNU_TARGET_NAME) \
72 --build=$(GNU_HOST_NAME) \
73 --program-prefix="" \
74 --program-suffix="" \
75 --prefix=/usr \
76 --exec-prefix=/usr \
77 --bindir=/usr/bin \
78 --sbindir=/usr/sbin \
79 --libexecdir=/usr/lib \
80 --sysconfdir=/etc \
81 $(if $(CONFIG_KEXEC_ZLIB),--with,--without)-zlib \
82 $(if $(CONFIG_KEXEC_LZMA),--with,--without)-lzma \
83 TARGET_LD="$(TARGET_CROSS)ld"
84
85 TARGET_CFLAGS += -ffunction-sections -fdata-sections
86 TARGET_LDFLAGS += -Wl,--gc-sections
87
88 CONFIGURE_VARS += \
89 BUILD_CC="$(HOSTCC)" \
90 TARGET_CC="$(TARGET_CC)"
91
92 define Build/Compile
93 $(MAKE) -C $(PKG_BUILD_DIR) DESTDIR="$(PKG_INSTALL_DIR)" all install
94 endef
95
96 define Package/kexec-tools/install
97 :
98 endef
99
100 define Package/kexec/install
101 $(INSTALL_DIR) $(1)/usr/sbin
102 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/kexec $(1)/usr/sbin
103
104 # make a link for compatability with other distros
105 $(INSTALL_DIR) $(1)/sbin
106 $(LN) ../usr/sbin/kexec $(1)/sbin/kexec
107 endef
108
109 define Package/kdump/install
110 $(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/init.d $(1)/etc/config $(1)/etc/uci-defaults
111 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/vmcore-dmesg $(1)/usr/sbin
112 $(INSTALL_BIN) ./files/kdump.init $(1)/etc/init.d/kdump
113 $(INSTALL_BIN) ./files/kdump.defaults $(1)/etc/uci-defaults/kdump
114 $(INSTALL_CONF) ./files/kdump.config $(1)/etc/config/kdump
115 endef
116
117 define Package/kdump/prerm
118 #!/bin/sh
119
120 case $$(uname -m) in
121 i?86|x86_64)
122 if grep -q " crashkernel=" /boot/grub/grub.cfg; then
123 mount /boot -o remount,rw
124 sed -i 's/ crashkernel=[^ ]*//' /boot/grub/grub.cfg
125 mount /boot -o remount,ro
126 fi
127 ;;
128 esac
129 endef
130
131 $(eval $(call BuildPackage,kexec-tools))
132 $(eval $(call BuildPackage,kexec))
133 $(eval $(call BuildPackage,kdump))