fix microperl
[openwrt/svn-archive/archive.git] / lang / perl / 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 # $Id$
8
9 include $(TOPDIR)/rules.mk
10
11 PKG_NAME:=perl
12 PKG_VERSION:=5.10.0
13 PKG_RELEASE:=1
14 PKG_MD5SUM:=d2c39b002ebfd2c3c5dba589365c5a71
15
16 PKG_SOURCE_URL:=ftp://ftp.cpan.org/pub/CPAN/src/5.0 \
17 ftp://ftp.mpi-sb.mpg.de/pub/perl/CPAN/src/5.0 \
18 ftp://ftp.gmd.de/mirrors/CPAN/src/5.0 \
19 ftp://ftp.funet.fi/pub/languages/perl/CPAN/src/5.0
20 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
21 PKG_CAT:=zcat
22
23 PKG_BUILD_DIR:=$(BUILD_DIR)/perl/$(PKG_NAME)-$(PKG_VERSION)
24 PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
25
26 include $(INCLUDE_DIR)/package.mk
27
28 define Package/perl/Default
29 SUBMENU:=Perl
30 SECTION:=lang
31 CATEGORY:=Languages
32 TITLE:=The Perl intepreter
33 URL:=http://www.perl.com/
34 endef
35
36 define Package/microperl
37 $(call Package/perl/Default)
38 TITLE+=(minimal version)
39 endef
40
41 define Package/microperl/description
42 A perl package without operating-specific functions such as readdir.
43 endef
44
45 define Build/Template
46
47 $(STAMP_CONFIGURED)-$(1): $(STAMP_PREPARED)
48 -$(MAKE) -C $(PKG_BUILD_DIR) clean
49 $(call Build/$(1)/Configure)
50 touch $$@
51
52 $(STAMP_BUILT)-$(1): $(STAMP_CONFIGURED)-$(1)
53 $(call Build/$(1)/Compile)
54 touch $$@
55
56 $(STAMP_BUILT): $(STAMP_BUILT)-$(1)
57
58 endef
59
60 define Build/microperl/Configure
61 endef
62
63 define Build/microperl/Compile
64 $(MAKE) -C $(PKG_BUILD_DIR) -f Makefile.micro \
65 CC="$(TARGET_CC)" OPTIMIZE="$(TARGET_CFLAGS)"
66 mkdir -p $(PKG_INSTALL_DIR)/usr/bin/
67 $(CP) $(PKG_BUILD_DIR)/microperl $(PKG_INSTALL_DIR)/usr/bin/
68 endef
69
70 define Package/microperl/install
71 $(INSTALL_DIR) $(1)/usr/bin
72 $(INSTALL_BIN) $(PKG_BUILD_DIR)/microperl $(1)/usr/bin/
73 endef
74
75 include perlmod.mk
76
77 define Package/perl
78 $(call Package/perl/Default)
79 MAINTAINER:=Peter Colberg <peter@petercolberg.org>
80 endef
81
82 define Package/perl/description
83 Perl is a stable, cross platform programming language.
84 It is used for mission critical projects in the public and private sectors
85 and is widely used to program web applications of all needs.
86 endef
87
88 define Build/perl/Configure
89 @echo
90 @echo "===> Stage 1: Configure host perl"
91 @echo
92 mkdir -p $(PKG_BUILD_DIR)/host-perl
93 (cd $(PKG_BUILD_DIR)/host-perl && sh ../Configure -der -Dmksymlinks -Uusedl)
94
95 @echo
96 @echo "===> Stage 2: Build host perl binary with static extensions"
97 @echo
98 $(MAKE) -C $(PKG_BUILD_DIR)/host-perl
99
100 @echo
101 @echo "===> Stage 3: Configure target perl"
102 @echo
103 -$(MAKE) -C $(PKG_BUILD_DIR) clean
104 sed \
105 -e 's!%%CC%%!$(TARGET_CC)!g' \
106 -e 's!%%CFLAGS%%!$(TARGET_CFLAGS) -DUSE_CROSS_COMPILE -I$(STAGING_DIR)/include -I$(STAGING_DIR)/usr/include!g' \
107 -e 's!%%CPP%%!$(TARGET_CROSS)gcc -E!g' \
108 -e 's!%%AR%%!$(TARGET_CROSS)ar!g' \
109 -e 's!%%LD%%!$(TARGET_CROSS)gcc!g' \
110 -e 's!%%LDFLAGS%%!-rdynamic -L$(STAGING_DIR)/lib -L$(STAGING_DIR)/usr/lib!g' \
111 -e 's!%%LIBDIRS%%!$(STAGING_DIR)/lib $(STAGING_DIR)/usr/lib!g' \
112 -e 's!%%INCDIRS%%!$(STAGING_DIR)/include $(STAGING_DIR)/usr/include!g' \
113 files/config.sh-$(REAL_GNU_TARGET_NAME).in \
114 > $(PKG_BUILD_DIR)/config.sh
115 (cd $(PKG_BUILD_DIR) && ./Configure -S)
116 endef
117
118 define Build/perl/Compile
119 @echo
120 @echo "===> Stage 4: Build target miniperl binary"
121 @echo
122 install -m 0644 $(PKG_BUILD_DIR)/config.h $(PKG_BUILD_DIR)/xconfig.h
123 -rm -f $(PKG_BUILD_DIR)/miniperl
124 $(MAKE) -C $(PKG_BUILD_DIR) miniperl
125 mkdir -p $(PKG_BUILD_DIR)/target-bin
126 install -m 0755 $(PKG_BUILD_DIR)/miniperl $(PKG_BUILD_DIR)/target-bin/
127
128 @echo
129 @echo "===> Stage 5: Build target perl binary"
130 @echo
131 -rm -f $(PKG_BUILD_DIR)/miniperl $(PKG_BUILD_DIR)/perl
132 install -m 0755 $(PKG_BUILD_DIR)/host-perl/miniperl $(PKG_BUILD_DIR)/
133 touch $(PKG_BUILD_DIR)/miniperl
134 $(MAKE) -C $(PKG_BUILD_DIR) perl
135 install -m 0755 $(PKG_BUILD_DIR)/perl $(PKG_BUILD_DIR)/target-bin/
136
137 @echo
138 @echo "===> Stage 6: Build target extensions and utils"
139 @echo
140 -rm -f $(PKG_BUILD_DIR)/miniperl $(PKG_BUILD_DIR)/perl
141 install -m 0755 $(PKG_BUILD_DIR)/host-perl/miniperl $(PKG_BUILD_DIR)/
142 ln -sf miniperl $(PKG_BUILD_DIR)/perl
143 touch $(PKG_BUILD_DIR)/miniperl $(PKG_BUILD_DIR)/perl
144 $(MAKE) -C $(PKG_BUILD_DIR)
145
146 @echo
147 @echo "===> Stage 7: Install Perl into staging dir"
148 @echo
149 -rm -f $(PKG_BUILD_DIR)/perl
150 $(INSTALL_BIN) $(PKG_BUILD_DIR)/host-perl/perl $(PKG_BUILD_DIR)/
151 (cd $(PKG_BUILD_DIR) && ./perl installperl --destdir=$(STAGING_DIR))
152
153 @echo
154 @echo "===> Stage 8: Install Perl into a temporary root"
155 @echo
156 -rm -f $(PKG_BUILD_DIR)/perl
157 $(INSTALL_BIN) $(PKG_BUILD_DIR)/target-bin/perl $(PKG_BUILD_DIR)
158 -rm -rf $(PKG_INSTALL_DIR)
159 mkdir -p $(PKG_INSTALL_DIR)
160 (cd $(PKG_BUILD_DIR) && host-perl/miniperl installperl --destdir=$(PKG_INSTALL_DIR))
161 endef
162
163 define Package/perl/install
164 $(INSTALL_DIR) $(1)/usr/bin
165 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/perl$(PKG_VERSION) $(1)/usr/bin
166 ln -f $(1)/usr/bin/perl$(PKG_VERSION) $(1)/usr/bin/perl
167 endef
168
169 ifneq ($(CONFIG_PACKAGE_microperl),)
170 define Build/microperl
171 $(call Build/Template,microperl)
172 endef
173 endif
174 $(eval $(Build/microperl))
175
176 ifneq ($(CONFIG_PACKAGE_perl),)
177 define Build/perl
178 $(call Build/Template,perl)
179 endef
180 endif
181 $(eval $(Build/perl))
182
183 $(eval $(call BuildPackage,microperl))
184 $(eval $(call BuildPackage,perl))
185
186 -include perlbase.mk