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