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