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