summaryrefslogtreecommitdiffstats
path: root/rules/apache2.make
blob: 4bf37d5492382b6d89f4f2117a6db6b84983ed51 (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
# -*-makefile-*-
# $Id: template 2922 2005-07-11 19:17:53Z rsc $
#
# 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.55
APACHE2		= httpd-$(APACHE2_VERSION)
APACHE2_SUFFIX	= tar.bz2
APACHE2_URL	= http://ftp.plusline.de/ftp.apache.org/httpd/$(APACHE2).$(APACHE2_SUFFIX)
APACHE2_SOURCE	= $(SRCDIR)/$(APACHE2).$(APACHE2_SUFFIX)
APACHE2_DIR	= $(BUILDDIR)/$(APACHE2)

-include $(call package_depfile)

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

apache2_get: $(STATEDIR)/apache2.get

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

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

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

apache2_extract: $(STATEDIR)/apache2.extract

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

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

apache2_prepare: $(STATEDIR)/apache2.prepare

APACHE2_PATH	=  PATH=$(CROSS_PATH)
APACHE2_ENV 	=  $(CROSS_ENV)
APACHE2_ENV	+= PKG_CONFIG_PATH=$(CROSS_LIB_DIR)/lib/pkgconfig

# FIXME: find a real patch for these (fix configure script)
APACHE2_ENV	+= ac_cv_sizeof_ssize_t=4
APACHE2_ENV	+= ac_cv_sizeof_size_t=4
APACHE2_ENV	+= apr_cv_process_shared_works=yes
APACHE2_ENV	+= ac_cv_func_setpgrp_void=yes

#
# autoconf
#
APACHE2_AUTOCONF =  $(CROSS_AUTOCONF_USR)

$(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)
	@$(call touch, $@)

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

apache2_targetinstall: $(STATEDIR)/apache2.targetinstall

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

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

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

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

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

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

	# TODO: are the icons needed? (or are all icons required?)

	@$(call install_copy, 12,102,0755,$(PTXCONF_APACHE2_SERVERROOT)/icons)
	@cd $(APACHE2_DIR)/docs/icons; \
	for i in *.gif *.png; do \
		$(call install_copy, 12,102,0644,$$i,$(PTXCONF_APACHE2_SERVERROOT)/icons/$$i,n); \
	done
	@$(call install_copy, 12,102,0755,$(PTXCONF_APACHE2_SERVERROOT)/icons/small)
	@cd $(APACHE2_DIR)/docs/icons/small; \
	for i in *.gif *.png; do \
		$(call install_copy, 12,102,0644,$$i,$(PTXCONF_APACHE2_SERVERROOT)/icons/small/$$i,n); \
	done
	@$(call install_copy, 12, 102, 0644, \
		$(APACHE2_DIR)/docs/conf/mime.types, \
		$(PTXCONF_APACHE2_SERVERROOT)/conf/mime.types,n)
endif

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

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

	@$(call install_copy, 12, 102, 0644, \
		$(APACHE2_DIR)/docs/conf/magic, \
		$(PTXCONF_APACHE2_CONFIGDIR)/magic,n)

ifdef PTXCONF_APACHE2_DEFAULTCONFIG
	cp $(PTXDIST_TOPDIR)/projects/generic/httpd.conf $(APACHE2_DIR)/httpd.conf

	# now replace our own options
	perl -i -p -e "s,\@SERVERROOT@,\"$(PTXCONF_APACHE2_SERVERROOT)\",g" $(APACHE2_DIR)/httpd.conf
	perl -i -p -e "s,\@DOCUMENTROOT@,\"$(PTXCONF_APACHE2_DOCUMENTROOT)\",g" $(APACHE2_DIR)/httpd.conf
	perl -i -p -e "s,\@CONFIGDIR@,\"$(PTXCONF_APACHE2_CONFIGDIR)\",g" $(APACHE2_DIR)/httpd.conf
	perl -i -p -e "s,\@LOGPATH@,$(PTXCONF_APACHE2_LOGDIR),g" $(APACHE2_DIR)/httpd.conf
	perl -i -p -e "s,\@PIDFILE@,/var/run/apache2.pid,g" $(APACHE2_DIR)/httpd.conf
	perl -i -p -e "s,\@LISTEN@,$(PTXCONF_APACHE2_LISTEN),g" $(APACHE2_DIR)/httpd.conf
	perl -i -p -e "s,\@SERVERADMIN@,$(PTXCONF_APACHE2_SERVERADMIN),g" $(APACHE2_DIR)/httpd.conf
	perl -i -p -e "s,\@SERVERNAME@,$(PTXCONF_APACHE2_SERVERNAME),g" $(APACHE2_DIR)/httpd.conf

	@echo "installing default config file..."
	@$(call install_copy, 12, 102, 0644, \
		$(APACHE2_DIR)/httpd.conf, \
		$(PTXCONF_APACHE2_CONFIGDIR)/httpd.conf,n)
else
ifneq ($(PTXCONF_APACHE2_USERCONFIG), "")
	@echo "installing user config file..."
	@$(call install_copy, 12, 102, 0644, \
		$(PTXCONF_APACHE2_USERCONFIG), \
		$(PTXCONF_APACHE2_CONFIGDIR)/httpd.conf,n)
endif
endif
endif

ifneq ($(PTXCONF_APACHE2_LOGDIR),"")
	@$(call install_copy, 12, 102, 0755, $(PTXCONF_APACHE2_LOGDIR))
endif

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

	@$(call install_finish)

	@$(call touch, $@)

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

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

# vim: syntax=make