treewide: add support for "gc-sections" in PKG_BUILD_FLAGS
[openwrt/staging/dedeckeh.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 PKG_BUILD_FLAGS:=gc-sections
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 CONFIGURE_VARS += \
88 BUILD_CC="$(HOSTCC)" \
89 TARGET_CC="$(TARGET_CC)"
90
91 define Build/Compile
92 $(MAKE) -C $(PKG_BUILD_DIR) DESTDIR="$(PKG_INSTALL_DIR)" all install
93 endef
94
95 define Package/kexec-tools/install
96 :
97 endef
98
99 define Package/kexec/install
100 $(INSTALL_DIR) $(1)/usr/sbin
101 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/kexec $(1)/usr/sbin
102
103 # make a link for compatability with other distros
104 $(INSTALL_DIR) $(1)/sbin
105 $(LN) ../usr/sbin/kexec $(1)/sbin/kexec
106 endef
107
108 define Package/kdump/install
109 $(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/init.d $(1)/etc/config $(1)/etc/uci-defaults
110 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/vmcore-dmesg $(1)/usr/sbin
111 $(INSTALL_BIN) ./files/kdump.init $(1)/etc/init.d/kdump
112 $(INSTALL_BIN) ./files/kdump.defaults $(1)/etc/uci-defaults/kdump
113 $(INSTALL_CONF) ./files/kdump.config $(1)/etc/config/kdump
114 endef
115
116 define Package/kdump/prerm
117 #!/bin/sh
118
119 case $$(uname -m) in
120 i?86|x86_64)
121 if grep -q " crashkernel=" /boot/grub/grub.cfg; then
122 mount /boot -o remount,rw
123 sed -i 's/ crashkernel=[^ ]*//' /boot/grub/grub.cfg
124 mount /boot -o remount,ro
125 fi
126 ;;
127 esac
128 endef
129
130 $(eval $(call BuildPackage,kexec-tools))
131 $(eval $(call BuildPackage,kexec))
132 $(eval $(call BuildPackage,kdump))