fix GNU_HOST_NAME for non-linux machines
[openwrt.git] / toolchain / sed / Makefile
1
2 # Copyright (C) 2006 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7 include $(TOPDIR)/rules.mk
8
9 PKG_NAME:=sed
10 PKG_VERSION:=4.1.2
11
12 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
13 PKG_SOURCE_URL:=ftp://ftp.gnu.org/gnu/$(PKG_NAME)
14 PKG_MD5SUM:=928f0e06422f414091917401f1a834d0
15 PKG_CAT:=zcat
16
17 PKG_BUILD_DIR:=$(TOOL_BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
18
19 HOST_SED_TARGET=$(strip $(shell ./sedcheck.sh))
20
21 ifneq ($(HOST_SED_TARGET),build-sed-host-binary)
22   PKG_SOURCE:=
23   PKG_CAT:=
24 endif
25
26 include $(INCLUDE_DIR)/host-build.mk
27
28 ifeq ($(HOST_SED_TARGET),build-sed-host-binary)
29   define Build/Configure
30         (cd $(PKG_BUILD_DIR); rm -rf config.cache; \
31                 ./configure \
32                 --prefix=$(STAGING_DIR) \
33                 --prefix=/usr \
34         );
35   endef
36
37   define Build/Compile
38         $(MAKE) -C $(PKG_BUILD_DIR)
39   endef
40
41   define Build/Install
42         @if [ -L $(STAGING_DIR)/bin/sed ] ; then \
43                 rm -f $(STAGING_DIR)/bin/sed; fi;
44         @if [ ! -f $(STAGING_DIR)/bin/sed -o $(STAGING_DIR)/bin/sed -ot $(PKG_BUILD_DIR)/sed/sed ]; then \
45             set -x; \
46             mkdir -p $(STAGING_DIR)/bin; \
47             $(MAKE) DESTDIR=$(STAGING_DIR) -C $(PKG_BUILD_DIR) install; \
48             mv $(STAGING_DIR)/usr/bin/sed $(STAGING_DIR)/bin/; \
49             rm -rf $(STAGING_DIR)/share/locale $(STAGING_DIR)/usr/info \
50                     $(STAGING_DIR)/usr/man $(STAGING_DIR)/usr/share/doc; \
51         fi
52   endef
53 else
54   define Build/Compile
55   endef
56   define Build/Install
57     rm -rf $(STAGING_DIR)/bin/sed
58         mkdir -p $(STAGING_DIR)/bin
59         ln -s `which sed` $(STAGING_DIR)/bin/sed
60   endef
61 endif
62
63 $(eval $(call HostBuild))