packaged full perl, thanks Peter Colberg (closes #3708)
[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/perl/Default/description
37 Perl rocks
38 endef
39
40 define Package/microperl
41 $(call Package/perl/Default)
42 TITLE+=(minimal version)
43 endef
44
45 define Package/perl/description
46 $(call Package/perl/Default/description)
47 A perl package without operating-specific functions such as readdir.
48 endef
49
50 define Build/Template
51
52 $(STAMP_CONFIGURED)-$(1): $(STAMP_PREPARED)
53 -$(MAKE) -C $(PKG_BUILD_DIR) clean
54 $(call Build/$(1)/Configure)
55 touch $$@
56
57 $(STAMP_BUILT)-$(1): $(STAMP_CONFIGURED)-$(1)
58 $(call Build/$(1)/Compile)
59 touch $$@
60
61 $(STAMP_BUILT): $(STAMP_BUILT)-$(1)
62
63 endef
64
65 define Build/microperl/Configure
66 endef
67
68 define Build/microperl/Compile
69 $(MAKE) -C $(PKG_BUILD_DIR) -f Makefile.micro \
70 CC="$(TARGET_CC)" OPTIMIZE="$(TARGET_CFLAGS)"
71 mkdir -p $(PKG_INSTALL_DIR)/usr/bin/
72 $(CP) $(PKG_BUILD_DIR)/microperl $(PKG_INSTALL_DIR)/usr/bin/
73 endef
74
75 define Package/microperl/install
76 $(INSTALL_DIR) $(1)/usr/bin
77 $(INSTALL_BIN) $(PKG_BUILD_DIR)/microperl $(1)/usr/bin/
78 endef
79
80 include perlmod.mk
81
82 define Package/perl
83 $(call Package/perl/Default)
84 MAINTAINER:=Peter Colberg <peter@petercolberg.org>
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 $(eval $(call BuildPackage,microperl))
183 $(eval $(call BuildPackage,perl))
184
185 -include perlbase.mk