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