fix php4 compile on arm, add fpic while we're at it
[packages.git] / lang / php4 / Makefile
1 #
2 # Copyright (C) 2006-2008 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:=php4
12 PKG_VERSION:=4.4.7
13 PKG_RELEASE:=1
14
15 PKG_SOURCE:=php-$(PKG_VERSION).tar.bz2
16 PKG_SOURCE_URL:=http://fr.php.net/distributions/
17 PKG_MD5SUM:=3f21b44d37a57ca3876d3aea713c700d
18 PKG_BUILD_DIR:=$(BUILD_DIR)/php-$(PKG_VERSION)
19
20 include $(INCLUDE_DIR)/package.mk
21
22 define Package/php4/Default
23   SUBMENU:=PHP
24   SECTION:=lang
25   CATEGORY:=Languages
26   TITLE:=PHP4 Hypertext preprocessor
27   DEPENDS:=@!TARGET_ixp4xx
28   URL:=http://www.php.net/
29 endef
30
31 define Package/php4/Default/description
32  PHP is a widely-used general-purpose scripting language that is especially
33  suited for Web development and can be embedded into HTML.
34 endef
35
36 define Package/php4
37   $(call Package/php4/Default)
38   DEPENDS:=+libopenssl +zlib
39 endef
40
41 define Package/php4/description
42 $(call Package/php4/Default/description)
43  This package contains only the PHP config file. You must actually choose
44  your PHP flavour (cli, cgi or fastcgi).
45 endef
46
47 define Package/php4-cli
48   $(call Package/php4/Default)
49   DEPENDS:=php4
50   TITLE+= (CLI)
51 endef
52
53 define Package/php4-cli/description
54 $(call Package/php4/Default/description)
55  This package contains the CLI version of the PHP4 interpreter.
56 endef
57
58 define Package/php4-cgi
59   $(call Package/php4/Default)
60   DEPENDS:=php4
61   TITLE+= (CGI)
62 endef
63
64 define Package/php4-cgi/description
65 $(call Package/php4/Default/description)
66  This package contains the CGI version of the PHP4 interpreter.
67 endef
68
69 define Package/php4-fastcgi
70   $(call Package/php4/Default)
71   DEPENDS:=php4
72   TITLE+= (FastCGI)
73 endef
74
75 define Package/php4-fastcgi/description
76 $(call Package/php4/Default/description)
77  This package contains the FastCGI version of the PHP4 interpreter.
78 endef
79
80 define Package/php4-mod-curl
81   $(call Package/php4/Default)
82   DEPENDS:=php4 +libcurl
83   TITLE:=cURL module
84 endef
85
86 define Package/php4-mod-ftp
87   $(call Package/php4/Default)
88   DEPENDS:=php4
89   TITLE:=FTP module
90 endef
91
92 define Package/php4-mod-gd
93   $(call Package/php4/Default)
94   DEPENDS:=php4 +libgd
95   TITLE:=GD graphics module
96 endef
97
98 define Package/php4-mod-gmp
99   $(call Package/php4/Default)
100   DEPENDS:=php4 +libgmp
101   TITLE:=GMP module
102 endef
103
104 define Package/php4-mod-ldap
105   $(call Package/php4/Default)
106   DEPENDS:=php4 +libopenldap
107   TITLE:=LDAP module
108 endef
109
110 define Package/php4-mod-mysql
111   $(call Package/php4/Default)
112   DEPENDS:=php4 +libmysqlclient
113   TITLE:=MySQL module
114 endef
115
116 define Package/php4-mod-openssl
117   $(call Package/php4/Default)
118   DEPENDS:=php4 +libopenssl
119   TITLE:=OpenSSL module
120 endef
121
122 define Package/php4-mod-pcre
123   $(call Package/php4/Default)
124   DEPENDS:=php4 +libpcre
125   TITLE:=PCRE module
126 endef
127
128 define Package/php4-mod-pgsql
129   $(call Package/php4/Default)
130   DEPENDS:=php4 +libpq
131   TITLE:=PostgreSQL module
132 endef
133
134 define Package/php4-mod-session
135   $(call Package/php4/Default)
136   DEPENDS:=php4
137   TITLE:=Session module
138 endef
139
140 define Package/php4-mod-sockets
141   $(call Package/php4/Default)
142   DEPENDS:=php4
143   TITLE:=Sockets module
144 endef
145
146 define Package/php4-mod-xml
147   $(call Package/php4/Default)
148   DEPENDS:=php4 +libexpat
149   TITLE:=XML module
150 endef
151
152 PKG_CONFIGURE_LIBS:= -lcrypto -lssl
153 PKG_CONFIGURE_OPTS:= \
154         --enable-shared \
155         --disable-static \
156         --disable-rpath \
157         --disable-debug \
158         --without-pear \
159         \
160         --with-config-file-path=/etc \
161         --disable-ipv6 \
162         --enable-magic-quotes \
163         --enable-memory-limit \
164         --disable-overload \
165         --disable-short-tags \
166         \
167         --disable-ctype \
168         --disable-dom \
169         --enable-ftp=shared \
170         --without-gettext \
171         --without-iconv \
172         --disable-mbstring \
173         --disable-mbregex \
174         --with-openssl=shared,"$(STAGING_DIR)/usr" \
175           --with-kerberos=no \
176           --with-openssl-dir="$(STAGING_DIR)/usr" \
177         --enable-session=shared \
178         --enable-sockets=shared \
179         --disable-tokenizer \
180         --with-zlib="$(STAGING_DIR)/usr" \
181           --with-zlib-dir="$(STAGING_DIR)/usr" \
182
183 ifneq ($(SDK),)
184   PKG_BUILD_DEPENDS:=libopenssl zlib libcurl libgd libgmp libopenldap libmysqlclient libpq libexpat
185 # force PKG_CONFIGURE_{LIBS,OPTS} below when built in the SDK
186   CONFIG_PACKAGE_php4-cli:=m
187   CONFIG_PACKAGE_php4-cgi:=m
188   CONFIG_PACKAGE_php4-fastcgi:=m
189   CONFIG_PACKAGE_php4-mod-curl:=m
190   CONFIG_PACKAGE_php4-mod-gd:=m
191   CONFIG_PACKAGE_php4-mod-gmp:=m
192   CONFIG_PACKAGE_php4-mod-ldap:=m
193   CONFIG_PACKAGE_php4-mod-mysql:=m
194   CONFIG_PACKAGE_php4-mod-pcre:=m
195   CONFIG_PACKAGE_php4-mod-pgsql:=m
196   CONFIG_PACKAGE_php4-mod-xml:=m
197 endif
198
199 ifneq ($(CONFIG_PACKAGE_php4-mod-curl),)
200   PKG_CONFIGURE_OPTS+= --with-curl=shared,"$(STAGING_DIR)/usr"
201 else
202   PKG_CONFIGURE_OPTS+= --without-curl
203 endif
204 ifneq ($(CONFIG_PACKAGE_php4-mod-gd),)
205   PKG_CONFIGURE_OPTS+= --with-gd=shared,"$(STAGING_DIR)/usr" \
206         --without-freetype-dir \
207         --with-jpeg-dir="$(STAGING_DIR)/usr" \
208         --with-png-dir="$(STAGING_DIR)/usr" \
209         --without-xpm-dir \
210         --without-ttf \
211         --without-t1lib \
212         --enable-gd-native-ttf \
213         --disable-gd-jis-conv
214 else
215   PKG_CONFIGURE_OPTS+= --without-gd
216 endif
217 ifneq ($(CONFIG_PACKAGE_php4-mod-gmp),)
218   PKG_CONFIGURE_OPTS+= --with-gmp=shared,"$(STAGING_DIR)/usr"
219 else
220   PKG_CONFIGURE_OPTS+= --without-gmp
221 endif
222 ifneq ($(CONFIG_PACKAGE_php4-mod-ldap),)
223   PKG_CONFIGURE_OPTS+= --with-ldap=shared,"$(STAGING_DIR)/usr"
224         --with-ldap-sasl="$(STAGING_DIR)/usr"
225 else
226   PKG_CONFIGURE_OPTS+= --without-ldap
227 endif
228 ifneq ($(CONFIG_PACKAGE_php4-mod-mysql),)
229   PKG_CONFIGURE_OPTS+= --with-mysql=shared,"$(STAGING_DIR)/usr"
230 else
231   PKG_CONFIGURE_OPTS+= --without-mysql
232 endif
233 ifneq ($(CONFIG_PACKAGE_php4-mod-pcre),)
234   PKG_CONFIGURE_OPTS+= --with-pcre-regex=shared,"$(STAGING_DIR)/usr"
235 else
236   PKG_CONFIGURE_OPTS+= --without-pcre-regex
237 endif
238 ifneq ($(CONFIG_PACKAGE_php4-mod-pgsql),)
239   PKG_CONFIGURE_OPTS+= --with-pgsql=shared,"$(STAGING_DIR)/usr"
240 else
241   PKG_CONFIGURE_OPTS+= --without-pgsql
242 endif
243 ifneq ($(CONFIG_PACKAGE_php4-mod-xml),)
244   PKG_CONFIGURE_OPTS+= --enable-xml=shared \
245         --with-expat-dir="$(STAGING_DIR)/usr"
246 else
247   PKG_CONFIGURE_OPTS+= --disable-xml
248 endif
249
250 define Build/Configure
251 endef
252
253 TARGET_CFLAGS += $(if $(CONFIG_BIG_ENDIAN),-DIEEE_BIG_ENDIAN,-DIEEE_LITTLE_ENDIAN) $(FPIC)
254
255 ifneq ($(CONFIG_PACKAGE_php4-cli),)
256   define Build/Compile/php4-cli
257         -$(MAKE) -C $(PKG_BUILD_DIR) clean
258         $(call Build/Configure/Default, \
259                 $(PKG_CONFIGURE_OPTS) \
260                 --enable-cli \
261                 --disable-cgi \
262                 --disable-fastcgi \
263                 --enable-force-cgi-redirect \
264                 --enable-discard-path \
265                 , \
266                 LIBS="$(PKG_CONFIGURE_LIBS)" \
267                 php_cv_cc_rpath="no" \
268         )
269         $(MAKE) -C $(PKG_BUILD_DIR)
270         mv $(PKG_BUILD_DIR)/sapi/cli/php $(PKG_BUILD_DIR)/php-cli
271   endef
272 endif
273
274 ifneq ($(CONFIG_PACKAGE_php4-cgi),)
275   define Build/Compile/php4-cgi
276         -$(MAKE) -C $(PKG_BUILD_DIR) clean
277         $(call Build/Configure/Default, \
278                 $(PKG_CONFIGURE_OPTS) \
279                 --disable-cli \
280                 --enable-cgi \
281                 --disable-fastcgi \
282                 --enable-force-cgi-redirect \
283                 --enable-discard-path \
284                 , \
285                 LIBS="$(PKG_CONFIGURE_LIBS)" \
286                 php_cv_cc_rpath="no" \
287         )
288         $(MAKE) -C $(PKG_BUILD_DIR)
289         mv $(PKG_BUILD_DIR)/sapi/cgi/php $(PKG_BUILD_DIR)/php-cgi
290   endef
291 endif
292
293 ifneq ($(CONFIG_PACKAGE_php4-fastcgi),)
294   define Build/Compile/php4-fastcgi
295         -$(MAKE) -C $(PKG_BUILD_DIR) clean
296         $(call Build/Configure/Default, \
297                 $(PKG_CONFIGURE_OPTS) \
298                 --disable-cli \
299                 --enable-cgi \
300                 --enable-fastcgi \
301                 --enable-force-cgi-redirect \
302                 --enable-discard-path \
303                 , \
304                 LIBS="$(PKG_CONFIGURE_LIBS)" \
305                 php_cv_cc_rpath="no" \
306         )
307         $(MAKE) -C $(PKG_BUILD_DIR)
308         mv $(PKG_BUILD_DIR)/sapi/cgi/php $(PKG_BUILD_DIR)/php-fastcgi
309   endef
310 endif
311
312 define Build/Compile
313         $(call Build/Compile/php4-cli)
314         $(call Build/Compile/php4-cgi)
315         $(call Build/Compile/php4-fastcgi)
316 endef
317
318 define Package/php4/conffiles
319 /etc/php.ini
320 endef
321
322 define Package/php4/install
323         $(INSTALL_DIR) $(1)/etc
324         $(INSTALL_DATA) ./files/php.ini $(1)/etc/
325 endef
326
327 define Package/php4-cli/install
328         $(INSTALL_DIR) $(1)/usr/bin
329         $(CP) $(PKG_BUILD_DIR)/php-cli $(1)/usr/bin/php
330 endef
331
332 define Package/php4-cgi/install
333         $(INSTALL_DIR) $(1)/usr/bin
334         $(CP) $(PKG_BUILD_DIR)/php-cgi $(1)/usr/bin/php
335 endef
336
337 define Package/php4-fastcgi/install
338         $(INSTALL_DIR) $(1)/usr/sbin
339         $(CP) $(PKG_BUILD_DIR)/php-fastcgi $(1)/usr/sbin/php
340         $(INSTALL_DIR) $(1)/etc/init.d
341         $(INSTALL_BIN) ./files/php.init $(1)/etc/init.d/php
342 endef
343
344 define BuildPlugin
345   define Package/$(1)/install
346         [ -z "$(2)" ] || $(INSTALL_DIR) $$(1)/usr/lib/php
347         for m in $(2); do \
348                 $(INSTALL_BIN) $(PKG_BUILD_DIR)/modules/$$$$$$$${m}.so $$(1)/usr/lib/php/ ; \
349         done
350   endef
351
352   $$(eval $$(call BuildPackage,$(1)))
353 endef
354
355 $(eval $(call BuildPackage,php4))
356 $(eval $(call BuildPackage,php4-cli))
357 $(eval $(call BuildPackage,php4-cgi))
358 $(eval $(call BuildPackage,php4-fastcgi))
359 $(eval $(call BuildPlugin,php4-mod-curl,curl))
360 $(eval $(call BuildPlugin,php4-mod-ftp,ftp))
361 $(eval $(call BuildPlugin,php4-mod-gd,gd))
362 $(eval $(call BuildPlugin,php4-mod-gmp,gmp))
363 $(eval $(call BuildPlugin,php4-mod-ldap,ldap))
364 $(eval $(call BuildPlugin,php4-mod-mysql,mysql))
365 $(eval $(call BuildPlugin,php4-mod-openssl,openssl))
366 $(eval $(call BuildPlugin,php4-mod-pcre,pcre))
367 $(eval $(call BuildPlugin,php4-mod-pgsql,pgsql))
368 $(eval $(call BuildPlugin,php4-mod-session,session))
369 $(eval $(call BuildPlugin,php4-mod-sockets,sockets))
370 $(eval $(call BuildPlugin,php4-mod-xml,xml))
371