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