add toolchain/download target
[openwrt.git] / toolchain / sed / Makefile
1 include $(TOPDIR)/rules.mk
2
3 #############################################################
4 #
5 # sed
6 #
7 #############################################################
8 SED_VER:=4.1.2
9 SED_SOURCE:=sed-$(SED_VER).tar.gz
10 SED_SITE:=ftp://ftp.gnu.org/gnu/sed
11 SED_CAT:=zcat
12 SED_DIR1:=$(TOOL_BUILD_DIR)/sed-$(SED_VER)
13 SED_DIR2:=$(BUILD_DIR)/sed-$(SED_VER)
14 SED_BINARY:=sed/sed
15 SED_TARGET_BINARY:=bin/sed
16 SED_MD5SUM:=928f0e06422f414091917401f1a834d0
17 ifeq ($(strip $(BUILD_WITH_LARGEFILE)),true)
18 SED_CPPFLAGS=-D_FILE_OFFSET_BITS=64
19 endif
20 HOST_SED_TARGET=$(shell ./sedcheck.sh)
21 DOWNLOAD_TARGET=$(shell ./sedcheck.sh)
22
23 $(DL_DIR)/$(SED_SOURCE):
24         mkdir -p $(DL_DIR)
25         $(SCRIPT_DIR)/download.pl $(DL_DIR) $(SED_SOURCE) $(SED_MD5SUM) $(SED_SITE)
26
27 #############################################################
28 #
29 # build sed for use on the host system
30 #
31 #############################################################
32
33 $(SED_DIR1)/.unpacked: $(DL_DIR)/$(SED_SOURCE)
34         mkdir -p $(TOOL_BUILD_DIR)
35         mkdir -p $(STAGING_DIR)/bin;
36         $(SED_CAT) $(DL_DIR)/$(SED_SOURCE) | tar -C $(TOOL_BUILD_DIR) $(TAR_OPTIONS) -
37         touch $(SED_DIR1)/.unpacked
38
39 $(SED_DIR1)/.configured: $(SED_DIR1)/.unpacked
40         (cd $(SED_DIR1); rm -rf config.cache; \
41                 ./configure \
42                 --prefix=$(STAGING_DIR) \
43                 --prefix=/usr \
44         );
45         touch  $(SED_DIR1)/.configured
46
47 $(SED_DIR1)/$(SED_BINARY): $(SED_DIR1)/.configured
48         $(MAKE) -C $(SED_DIR1)
49
50 # This stuff is needed to work around GNU make deficiencies
51 build-sed-host-binary: $(SED_DIR1)/$(SED_BINARY) FORCE
52         @if [ -L $(STAGING_DIR)/$(SED_TARGET_BINARY) ] ; then \
53                 rm -f $(STAGING_DIR)/$(SED_TARGET_BINARY); fi;
54         @if [ ! -f $(STAGING_DIR)/$(SED_TARGET_BINARY) -o $(STAGING_DIR)/$(SED_TARGET_BINARY) \
55         -ot $(SED_DIR1)/$(SED_BINARY) ] ; then \
56             set -x; \
57             mkdir -p $(STAGING_DIR)/bin; \
58             $(MAKE) DESTDIR=$(STAGING_DIR) -C $(SED_DIR1) install; \
59             mv $(STAGING_DIR)/usr/bin/sed $(STAGING_DIR)/bin/; \
60             rm -rf $(STAGING_DIR)/share/locale $(STAGING_DIR)/usr/info \
61                     $(STAGING_DIR)/usr/man $(STAGING_DIR)/usr/share/doc; fi
62
63 use-sed-host-binary: FORCE
64         @if [ -x /usr/bin/sed ]; then SED="/usr/bin/sed"; else \
65             if [ -x /bin/sed ]; then SED="/bin/sed"; fi; fi; \
66             mkdir -p $(STAGING_DIR)/bin; \
67             rm -f $(STAGING_DIR)/$(SED_TARGET_BINARY); \
68             ln -s $$SED $(STAGING_DIR)/$(SED_TARGET_BINARY)
69
70 download-sed-binary: sed-$(SED_VER).tar.gz
71
72 source: $(DOWNLOAD_TARGET)
73 prepare: 
74 compile: 
75 install: $(HOST_SED_TARGET)
76 clean: FORCE
77         rm -rf $(SED_DIR1)
78         rm -f $(STAGING_DIR)/$(SED_TARGET_BINARY)
79