summaryrefslogtreecommitdiffstats
path: root/rules/apache2.make
blob: 03efee6d29d1ea81186028d948ea9c4c5d1a905e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
# -*-makefile-*-
# $Id: apache2.make,v 1.10 2006/10/02 08:38:47 michl Exp $
#
# Copyright (C) 2005 by Robert Schwebel
#
# See CREDITS for details about who has contributed to this project.
#
# For further information about the PTXdist project and license conditions
# see the README file.
#

#
# We provide this package
#
PACKAGES-$(PTXCONF_APACHE2) += apache2

#
# Paths and names
#
APACHE2_VERSION	:= 2.0.58
APACHE2		:= httpd-$(APACHE2_VERSION)
APACHE2_SUFFIX	:= tar.bz2
APACHE2_URL	:= http://ftp.uni-erlangen.de/pub/mirrors/apache/httpd/$(APACHE2).$(APACHE2_SUFFIX)
APACHE2_SOURCE	:= $(SRCDIR)/$(APACHE2).$(APACHE2_SUFFIX)
APACHE2_DIR	:= $(BUILDDIR)/$(APACHE2)


# ----------------------------------------------------------------------------
# Get
# ----------------------------------------------------------------------------

apache2_get: $(STATEDIR)/apache2.get

$(STATEDIR)/apache2.get: $(apache2_get_deps_default)
	@$(call targetinfo, $@)
	@$(call touch, $@)

$(APACHE2_SOURCE):
	@$(call targetinfo, $@)
	@$(call get, APACHE2)

# ----------------------------------------------------------------------------
# Extract
# ----------------------------------------------------------------------------

apache2_extract: $(STATEDIR)/apache2.extract

$(STATEDIR)/apache2.extract: $(apache2_extract_deps_default)
	@$(call targetinfo, $@)
	@$(call clean, $(APACHE2_DIR))
	@$(call extract, APACHE2)
	@$(call patchin, APACHE2)
	@$(call touch, $@)

# ----------------------------------------------------------------------------
# Prepare
# ----------------------------------------------------------------------------

apache2_prepare: $(STATEDIR)/apache2.prepare

APACHE2_PATH	:=  PATH=$(CROSS_PATH)
# FIXME: find a real patch for ac_* apr_* (fix configure script)
APACHE2_ENV 	:=  $(CROSS_ENV) \
	ac_cv_sizeof_ssize_t=4 \
	ac_cv_sizeof_size_t=4 \
	apr_cv_process_shared_works=yes \
	apr_cv_mutex_robust_shared=no \
	ac_cv_func_setpgrp_void=yes

#
# autoconf
#
APACHE2_AUTOCONF := \
	$(CROSS_AUTOCONF_USR) \
	--enable-so

ifdef PTXCONF_APACHE2_MPM_PREFORK
APACHE2_AUTOCONF += --with-mpm=prefork
endif
ifdef PTXCONF_APACHE2_MPM_PERCHILD
APACHE2_AUTOCONF += --with-mpm=perchild
endif
ifdef PTXCONF_APACHE2_MPM_WORKER
APACHE2_AUTOCONF += --with-mpm=worker
endif

# FIXME
# --without-apxs $(CROSS_AUTOCONF_USR)
# --with-python \
# --with-python-src=$(PYTHON24_DIR) \

$(STATEDIR)/apache2.prepare: $(apache2_prepare_deps_default)
	@$(call targetinfo, $@)
	@$(call clean, $(APACHE2_DIR)/config.cache)
	cd $(APACHE2_DIR) && \
		$(APACHE2_PATH) $(APACHE2_ENV) \
		./configure $(APACHE2_AUTOCONF)

	#
	# Tweak, Tweak ...
	#
	# The original object files are also used for other binaries, so
	# we generate a dummy dependency here
	#
	perl -i -p -e "s/^gen_test_char_OBJECTS =.*$$/gen_test_char_OBJECTS = dummy.lo/g" $(APACHE2_DIR)/server/Makefile

	@$(call touch, $@)

# ----------------------------------------------------------------------------
# Compile
# ----------------------------------------------------------------------------

apache2_compile: $(STATEDIR)/apache2.compile

$(STATEDIR)/apache2.compile: $(apache2_compile_deps_default)
	@$(call targetinfo, $@)

	#
	# Tweak, tweak...
	#
	# These files are run during compilation, so they have to be
	# compiled for the host, not for the target
	#
	touch $(APACHE2_DIR)/srclib/apr-util/uri/gen_uri_delims.lo
	cp $(HOST_APACHE2_DIR)/srclib/apr-util/uri/gen_uri_delims $(APACHE2_DIR)/srclib/apr-util/uri/gen_uri_delims
	touch $(APACHE2_DIR)/srclib/apr-util/uri/gen_uri_delims

	touch $(APACHE2_DIR)/srclib/pcre/dftables.lo
	cp $(HOST_APACHE2_DIR)/srclib/pcre/dftables $(APACHE2_DIR)/srclib/pcre/dftables
	touch $(APACHE2_DIR)/srclib/pcre/dftables

	touch $(APACHE2_DIR)/server/dummy.lo
	cp $(HOST_APACHE2_DIR)/server/gen_test_char $(APACHE2_DIR)/server/gen_test_char
	touch $(APACHE2_DIR)/server/gen_test_char

	cd $(APACHE2_DIR) && $(APACHE2_ENV) $(APACHE2_PATH) make

	@$(call touch, $@)

# ----------------------------------------------------------------------------
# Install
# ----------------------------------------------------------------------------

apache2_install: $(STATEDIR)/apache2.install

$(STATEDIR)/apache2.install: $(apache2_install_deps_default)
	@$(call targetinfo, $@)
	@$(call install, APACHE2)
	sed -i -e "s~\([ =\"]\)\(/usr\)~\1$(SYSROOT)\2~g" \
		$(SYSROOT)/usr/build/apr_rules.mk \
		$(SYSROOT)/usr/build/config.nice \
		$(SYSROOT)/usr/build/config_vars.mk \
		$(SYSROOT)/usr/bin/apr-config \
		$(SYSROOT)/usr/bin/apu-config \
		$(SYSROOT)/usr/bin/apxs
	@$(call touch, $@)

# ----------------------------------------------------------------------------
# Target-Install
# ----------------------------------------------------------------------------

apache2_targetinstall: $(STATEDIR)/apache2.targetinstall

$(STATEDIR)/apache2.targetinstall: $(apache2_targetinstall_deps_default)
	@$(call targetinfo, $@)

	@$(call install_init, apache2)
	@$(call install_fixup, apache2,PACKAGE,apache2)
	@$(call install_fixup, apache2,PRIORITY,optional)
	@$(call install_fixup, apache2,VERSION,$(APACHE2_VERSION))
	@$(call install_fixup, apache2,SECTION,base)
	@$(call install_fixup, apache2,AUTHOR,"Robert Schwebel <r.schwebel\@pengutronix.de>")
	@$(call install_fixup, apache2,DEPENDS,)
	@$(call install_fixup, apache2,DESCRIPTION,missing)

	# the server binary
	@$(call install_copy, apache2, 0, 0, 0755, $(APACHE2_DIR)/.libs/httpd, /usr/sbin/apache2)

	# and some needed shared libraries
	@$(call install_copy, apache2, 0, 0, 0644, \
		$(APACHE2_DIR)/srclib/apr-util/.libs/libaprutil-0.so.0.9.12, \
		/usr/lib/libaprutil-0.so.0.9.12)
	@$(call install_link, apache2, libaprutil-0.so.0.9.12, /usr/lib/libaprutil-0.so.0.9)
	@$(call install_link, apache2, libaprutil-0.so.0.9.12, /usr/lib/libaprutil-0.so.0)

	@$(call install_copy, apache2, 0, 0, 0644, \
		$(APACHE2_DIR)/srclib/apr/.libs/libapr-0.so.0.9.12, \
		/usr/lib/libapr-0.so.0.9.12)
	@$(call install_link, apache2, libapr-0.so.0.9.12, /usr/lib/libapr-0.so.0.9)
	@$(call install_link, apache2, libapr-0.so.0.9.12, /usr/lib/libapr-0.so.0)

ifneq ($(PTXCONF_APACHE2_SERVERROOT),"")
	@$(call install_copy, apache2, 12,102,0755,$(PTXCONF_APACHE2_SERVERROOT))

ifdef PTXCONF_APACHE2_PUBLICDOMAINICONS
	# TODO: are all icons required?
	@$(call install_copy, apache2, 12,102,0755,$(PTXCONF_APACHE2_SERVERROOT)/icons)
	@cd $(APACHE2_DIR)/docs/icons; \
	for i in *.gif *.png; do \
		$(call install_copy, apache2, 12,102,0644,$$i,$(PTXCONF_APACHE2_SERVERROOT)/icons/$$i,n); \
	done
	@$(call install_copy, apache2, 12,102,0755,$(PTXCONF_APACHE2_SERVERROOT)/icons/small)
	@cd $(APACHE2_DIR)/docs/icons/small; \
	for i in *.gif *.png; do \
		$(call install_copy, apache2, 12,102,0644,$$i,$(PTXCONF_APACHE2_SERVERROOT)/icons/small/$$i,n); \
	done
endif
ifdef PTXCONF_APACHE2_CUSTOMERRORS
	@$(call install_copy, apache2, 12,102,0755,$(PTXCONF_APACHE2_SERVERROOT)/error)
	@cd $(APACHE2_DIR)/docs/error; \
	for i in *.html.var; do \
		$(call install_copy, apache2, 12,102,0644,$$i,$(PTXCONF_APACHE2_SERVERROOT)/error/$$i,n); \
	done
	@$(call install_copy, apache2, 12,102,0755,$(PTXCONF_APACHE2_SERVERROOT)/error/include)
	@cd $(APACHE2_DIR)/docs/error/include; \
	for i in *.html; do \
		$(call install_copy, apache2, 12,102,0644,$$i,$(PTXCONF_APACHE2_SERVERROOT)/error/include/$$i,n); \
	done
endif

#
# install some generic definitions into the directory where
# the server's root is
# -> mime.types: Definition of mime-type, their names and extensions
# -> magic: Definitions to detect the mime-type without extensions
#
	@$(call install_copy, apache2, 12, 102, 0755, $(PTXCONF_APACHE2_SERVERROOT)/conf)
	@$(call install_copy, apache2, 12, 102, 0644, \
		$(APACHE2_DIR)/docs/conf/magic, \
		$(PTXCONF_APACHE2_SERVERROOT)/conf/magic,n)
	@$(call install_copy, apache2, 12, 102, 0644, \
		$(APACHE2_DIR)/docs/conf/mime.types, \
		$(PTXCONF_APACHE2_SERVERROOT)/conf/mime.types,n)

endif

ifneq ($(PTXCONF_APACHE2_DOCUMENTROOT),"")
	@$(call install_copy, apache2, 12, 102, 0755, $(PTXCONF_APACHE2_DOCUMENTROOT))
ifdef PTXCONF_APACHE2_DEFAULT_INDEX
	@$(call install_copy, apache2, 12, 102, 0644, \
		$(PTXDIST_TOPDIR)/generic/index.html, \
		$(PTXCONF_APACHE2_DOCUMENTROOT)/index.html,n)
endif
endif

ifneq ($(PTXCONF_APACHE2_CONFIGDIR),"")
	@$(call install_copy, apache2, 12, 102, 0755, $(PTXCONF_APACHE2_CONFIGDIR))
# ---------------------------
# generate a config file
#
ifdef PTXCONF_APACHE2_INSTALL_CONFIG
ifdef PTXCONF_APACHE2_DEFAULTCONFIG
# use generic one
	@$(call install_copy, apache2, 12, 102, 0644, \
		$(PTXDIST_TOPDIR)/generic/httpd.conf, \
		$(PTXCONF_APACHE2_CONFIGDIR)/httpd.conf, n)
endif
ifdef PTXCONF_APACHE2_USERCONFIG
# users one
	@$(call install_copy, apache2, 12, 102, 0644, \
		$(PTXDIST_WORKSPACE)/projectroot/httpd.conf, \
		$(PTXCONF_APACHE2_CONFIGDIR)/httpd.conf, n)
endif
# modify placeholders with data from configuration
	@$(call install_replace, apache2, $(PTXCONF_APACHE2_CONFIGDIR)/httpd.conf, \
		@SERVERROOT@, $(PTXCONF_APACHE2_SERVERROOT) )
	@$(call install_replace, apache2, $(PTXCONF_APACHE2_CONFIGDIR)/httpd.conf, \
		@DOCUMENTROOT@, $(PTXCONF_APACHE2_DOCUMENTROOT) )
	@$(call install_replace, apache2, $(PTXCONF_APACHE2_CONFIGDIR)/httpd.conf, \
		@CONFIGDIR@, $(PTXCONF_APACHE2_CONFIGDIR) )
	@$(call install_replace, apache2, $(PTXCONF_APACHE2_CONFIGDIR)/httpd.conf, \
		@LOGPATH@, $(PTXCONF_APACHE2_LOGDIR) )
	@$(call install_replace, apache2, $(PTXCONF_APACHE2_CONFIGDIR)/httpd.conf, \
		@PIDFILE@, /var/run/apache2.pid )
	@$(call install_replace, apache2, $(PTXCONF_APACHE2_CONFIGDIR)/httpd.conf, \
		@LISTEN@, $(PTXCONF_APACHE2_LISTEN) )
	@$(call install_replace, apache2, $(PTXCONF_APACHE2_CONFIGDIR)/httpd.conf, \
		@SERVERADMIN@, $(PTXCONF_APACHE2_SERVERADMIN) )
	@$(call install_replace, apache2, $(PTXCONF_APACHE2_CONFIGDIR)/httpd.conf, \
		@SERVERNAME@, $(PTXCONF_APACHE2_SERVERNAME) )
endif
endif


# ---------------------------
# create the log dir if enabled
#
ifneq ($(PTXCONF_APACHE2_LOGDIR),"")
	@$(call install_copy, apache2, 12, 102, 0755, $(PTXCONF_APACHE2_LOGDIR))
endif

# ---------------------------
# install startup script on demand
#
ifdef PTXCONF_ROOTFS_ETC_INITD_HTTPD
ifdef PTXCONF_ROOTFS_ETC_INITD_HTTPD_DEFAULT
# generic script with path modifications
	@$(call install_copy, apache2, 0, 0, 0755, \
		$(PTXDIST_TOPDIR)/generic/etc/init.d/httpd, \
		/etc/init.d/httpd, n)
endif
ifdef PTXCONF_ROOTFS_ETC_INITD_HTTPD_USER
# users one
	@$(call install_copy, apache2, 0, 0, 0755, \
		$(PTXDIST_WORKSPACE)/projectroot/etc/init.d/httpd, \
		/etc/init.d/httpd, n)
endif
# replace some placeholders
	@$(call install_replace, apache2, /etc/init.d/httpd, \
		@APACHECONFIG@,  $(PTXCONF_APACHE2_CONFIGDIR) )
	@$(call install_replace, apache2, /etc/init.d/httpd, \
		@LOGPATH@,  $(PTXCONF_APACHE2_LOGDIR) )
# install link to launch automatically if enabled
ifneq ($(PTXCONF_ROOTFS_ETC_INITD_HTTPD_LINK),"")
	@$(call install_link, apache2, ../init.d/httpd, \
		/etc/rc.d/$(PTXCONF_ROOTFS_ETC_INITD_HTTPD_LINK))
endif
endif

# #
# # create apache's default serverroot
# #
# ifneq ($(PTXCONF_ROOTFS_HTTPD_SERVERROOT),"")
# ifdef PTXCONF_ROOTFS_HTTPD_USER_DOC
# 	@cd $(PTXCONF_ROOTFS_HTTPD_USER_DOC_PATH); \
# 	for i in *.html *.gif *.png; do \
# 		$(call install_copy, apache2, 12,102,0644,$$i,$(PTXCONF_ROOTFS_HTTPD_SERVERROOT)/docroot/$$i,n); \
# 	done
# else
# 	$(call install_copy, apache2, 12,102,0644,$(PTXDIST_TOPDIR)/projetcs-example/generic/index.html,$(PTXCONF_ROOTFS_HTTPD_SERVERROOT)/docroot/index.html,n)
# endif
# 	@$(call install_copy, apache2, 12,102,0755,$(PTXCONF_ROOTFS_HTTPD_SERVERROOT)/cgi-bin)
# 	@$(call install_copy, apache2, 12,102,0644,$(APACHE2_DIR)/doc/cgi-examples/test-cgi,$(PTXCONF_ROOTFS_HTTPD_SERVERROOT)/cgi-bin,n)
# 	@$(call install_copy, apache2, 12,102,0755,$(PTXCONF_ROOTFS_HTTPD_SERVERROOT)/log)

	@$(call install_finish, apache2)

	@$(call touch, $@)

# ----------------------------------------------------------------------------
# Clean
# ----------------------------------------------------------------------------

apache2_clean:
	rm -rf $(STATEDIR)/apache2.*
	rm -rf $(IMAGEDIR)/apache2_*
	rm -rf $(APACHE2_DIR)

# vim: syntax=make