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