File: Makefile

package info (click to toggle)
slash 2.2.6-8etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 3,672 kB
  • ctags: 1,915
  • sloc: perl: 23,113; sql: 1,878; sh: 433; makefile: 233
file content (240 lines) | stat: -rw-r--r-- 8,672 bytes parent folder | download | duplicates (3)
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
# This code is a part of Slash, and is released under the GPL.
# Copyright 1997-2001 by Open Source Development Network. See README
# and COPYING for more information, or see http://slashcode.com/.
# $Id: Makefile,v 1.2.2.26 2002/07/03 17:06:09 pudge Exp $
# Adapted to Debian by Eric Van Buggenhaut <ericvb@debian.org>

##
##  Makefile -- Current one for Slash
##

#   the used tools
VERSION = 2.2.6
DISTNAME = slash
DISTVNAME = $(DISTNAME)-$(VERSION)

SHELL = /bin/sh
PERL = perl
NOOP = $(SHELL) -c true
RM_RF = rm -rf
RM = rm -f
SUFFIX = .gz
COMPRESS = gzip --best
TAR  = tar
TARFLAGS = cvf
PREOP = @$(NOOP)
POSTOP = @$(NOOP)
TO_UNIX = @$(NOOP)
SLASH_PREFIX = $(CURDIR)/debian/tmp
# If this isn't used anymore, can we remove it?
INIT = /etc/init.d
USER = nobody
GROUP = nogroup
CP = cp
INSTALL = install

# Plugins (any directory in plugins/)
PLUGINS = `find . -name CVS -prune -o -type d -name [a-zA-Z]\* -maxdepth 1 -print`

# Perl scripts, grouped by directory.
BINFILES = `find bin -name CVS -prune -o -name [a-zA-Z]\* -type f -print`
SBINFILES = `find sbin -name CVS -prune -o -name [a-zA-Z]\* -type f -print`
#THEMEFILES = `find themes -name CVS -prune -o -name [a-zA-z]\*.pl -print`
THEMEFILES = `find themes -name CVS -prune -o -name [0-9a-zA-Z]\* -print`
#PLUGINFILES = `find plugins -name CVS -prune -o -name [a-zA-Z]\*.pl -print`
PLUGINFILES = `find plugins -name CVS -prune -o -name [a-zA-Z]\* -print`

# What do we use to invoke perl?
REPLACEWITH = `$(PERL) -MConfig -e 'print $$Config{startperl}' | sed 's/@/\\@/g'`

# Scripts that need special treatment for $(SLASH_PREFIX)
PREFIX_REPLACE_FILES = utils/slash httpd/slash.conf bin/runtask

# Used by the RPM build.
BUILDROOT=/var/tmp/slash-buildroot
INSTALLSITEARCH=`$(PERL) -MConfig -e 'print "$(BUILDROOT)/$$Config{installsitearch}"'`
INSTALLSITELIB=`$(PERL) -MConfig -e 'print "$(BUILDROOT)/$$Config{installsitelib}"'`
INSTALLMAN3DIR=`$(PERL) -MConfig -e 'print "$(BUILDROOT)/$$Config{installman3dir}"'`

.PHONY : all plugins slash install

#   install the shared object file into Apache 
# We should run a script on the binaries to get the right
# version of perl. 
# I should also grab an install-sh instead of using $(CP)
slash:
	@echo "=== INSTALLING SLASH MODULES ==="
	@if [ ! "$(RPM)" ] ; then \
		( cd Slash; $(PERL) Makefile.PL INSTALLDIRS=vendor); \
	else \
		echo " - Performing an RPM build"; \
		(cd Slash; $(PERL) Makefile.PL INSTALLSITEARCH=$(INSTALLSITEARCH) INSTALLSITELIB=$(INSTALLSITELIB) INSTALLMAN3DIR=$(INSTALLMAN3DIR); make install UNINST=1); \
	fi

plugins: 
	@echo "=== INSTALLING SLASH PLUGINS ==="
	@(cd plugins; \
	 for a in $(PLUGINS); do \
	 	(cd $$a; \
		 echo == $$PWD; \
		 if [ -f Makefile.PL ]; then \
		 	if [ ! "$(RPM)" ] ; then \
				$(PERL) Makefile.PL INSTALLDIRS=vendor; \
			else \
				echo " - Performing an RPM build."; \
				$(PERL) Makefile.PL INSTALLSITEARCH=$(INSTALLSITEARCH) INSTALLSITELIB=$(INSTALLSITELIB) INSTALLMAN3DIR=$(INSTALLMAN3DIR); \
				make install UNINST=1; \
			fi; \
		 fi); \
	done)

all: install

#install: slash plugins
install:

	# Create all necessary directories.
	#$(INSTALL) -d $(SLASH_PREFIX)/bin/ $(SLASH_PREFIX)/sbin \
	#	$(SLASH_PREFIX)/sql/ $(SLASH_PREFIX)/sql/mysql/ $(SLASH_PREFIX)/sql/oracle/ $(SLASH_PREFIX)/sql/postgresql \
	#	$(SLASH_PREFIX)/themes/ $(SLASH_PREFIX)/themes/slashcode/htdocs/ $(SLASH_PREFIX)/themes/slashcode/sql/ \
	#	$(SLASH_PREFIX)/themes/slashcode/sql/mysql $(SLASH_PREFIX)/themes/slashcode/sql/oracle $(SLASH_PREFIX)/themes/slashcode/sql/postgresql \
	#	$(SLASH_PREFIX)/themes/slashcode/backup $(SLASH_PREFIX)/themes/slashcode/logs/ $(SLASH_PREFIX)/plugins/ $(SLASH_PREFIX)/httpd/

	# Quick hack to avoid the need for "cp -ruv" which breaks under FreeBSD
	# is to just copy the directories now. We may end up copying over a file
	# in the next step that we copy now. To fix this, a major portion of this
	# section of the Makefile would need to be rewritten to do this sanely
	# and there just isn't the time for that right now.
	#
	# Install the plugins...(will also install kruft like CVS/ and blib/
	# directories if they are around. Maybe a smarter copying procedure
	# is called for, here?)
	# 
	# Note: Many users of Slash have taken to symlinking the plugins and themes
	# directories into $(SLASH_PREFIX) from their checked-out CVS trees. We
	# should try to check for this in the future and behave accordingly.
	#
	(cd plugins; make clean) 
	
	# Insure we use the proper Perl interpreter and prefix in all scripts that 
	# we install. Note the use of Perl as opposed to dirname(1) and basename(1)
	# which may or may not exist on any given system.
	(replacewith=$(REPLACEWITH); \
	 binfiles=$(BINFILES); \
	 sbinfiles=$(SBINFILES); \
	 themefiles=$(THEMEFILES); \
	 pluginfiles=$(PLUGINFILES); \
	 if [ "$$replacewith" != "#!/usr/bin/perl" ]; then \
	 	replace=1; \
		replacestr='(using $(PERL))'; \
	 else \
	 	replace=0; \
	 fi; \
	 for f in $$binfiles $$sbinfiles; do \
	 	if [ $$replace ]; then \
			b=`echo $$f | $(PERL) -MFile::Basename -e 'print basename(<STDIN>)'`; \
			d=`echo $$f | $(PERL) -MFile::Basename -e 'print dirname(<STDIN>)'`; \
			$(PERL) -i.bak -pe "s@#!/usr/bin/perl@$$replacewith@ if $$. == 1" $$f; \
		fi; \
		echo "Installing '$$f' in $(SLASH_PREFIX)/usr/$$d $$replacestr"; \
		$(INSTALL) -d $(SLASH_PREFIX)/usr/$$d; \
		$(INSTALL) $$f $(SLASH_PREFIX)/usr/$$d/$$b; \
		if [ -f "$$f.bak" ]; then \
			if [ -f $$f ]; then \
				rm $$f; \
			fi; \
			mv $$f.bak $$f; \
		fi; \
	 done; \
	 for f in $$themefiles $$pluginfiles; do \
	 	if [ $$replace ]; then \
			b=`echo $$f | $(PERL) -MFile::Basename -e 'print basename(<STDIN>)'`; \
			d=`echo $$f | $(PERL) -MFile::Basename -e 'print dirname(<STDIN>)'`; \
			$(PERL) -i.bak -pe "s@#!/usr/bin/perl@$$replacewith@ if $$. == 1" $$f; \
		fi; \
		echo "Installing '$$f' in $(SLASH_PREFIX)/usr/share/slash/$$d $$replacestr"; \
		$(INSTALL) -d $(SLASH_PREFIX)/usr/share/slash/$$d; \
		$(INSTALL) $$f $(SLASH_PREFIX)/usr/share/slash/$$d/$$b; \
		if [ -f "$$f.bak" ]; then \
			if [ -f $$f ]; then \
				rm $$f; \
			fi; \
			mv $$f.bak $$f; \
		fi; \
	done)

	$(CP) sql/mysql/slashschema_create.sql $(SLASH_PREFIX)/usr/share/slash/sql/mysql/schema.sql
	$(CP) sql/mysql/defaults.sql $(SLASH_PREFIX)/usr/share/slash/sql/mysql/defaults.sql
	$(CP) sql/oracle/slashschema_create.sql $(SLASH_PREFIX)/usr/share/slash/sql/oracle/schema.sql
	$(CP) sql/postgresql/slashschema_create.sql $(SLASH_PREFIX)/usr/share/slash/sql/postgresql/schema.sql

	# This needs BSD support (and Solaris)...
	# ... and the $(SLASH_PREFIX) section is a really ugly hack, too.
	(if [ "$(SLASH_PREFIX)" != "/usr/local/slash" ]; then			\
		replace=1;							\
	 fi;									\
	 for a in $(PREFIX_REPLACE_FILES); do 					\
	 	if [ $$replace ]; then						\
			perl -i.bak -pe 's{/usr/local/slash}{$(SLASH_PREFIX)}' $$a;	\
		fi;								\
		case "$$a" in							\
		'httpd/slash.conf')						\
			if [ -f $(SLASH_PREFIX)/etc/slash/slash.conf ]; then	\
				echo "Preserving old slash.conf"; 		\
			else 							\
				$(CP) httpd/slash.conf $(SLASH_PREFIX)/etc/slash/apache.conf; \
			fi;							\
			$(CP) httpd/slash.conf $(SLASH_PREFIX)/etc/slash/apache.conf.def; \
			;;							\
		'bin/runtask')						\
			$(CP) bin/runtask $(SLASH_PREFIX)/usr/bin/runtask; \
			;;						\
		esac;								\
		if [ $$replace ]; then						\
	 		mv $$a.bak $$a;	 					\
		fi;								\
	done)
	# Remove any kruft thay may have been copied that shouldn't have been.
	-find $(SLASH_PREFIX) \( -name CVS -type d -o -name \.\#\* -type f \) \
		-printf '(cleaning out %p)\n' -exec rm -rf {} \; 2> /dev/null

	touch $(SLASH_PREFIX)/etc/slash/slash.sites
	#chown $(USER):$(GROUP) $(SLASH_PREFIX)
	#chown -R $(USER):$(GROUP) $(SLASH_PREFIX)/themes
	#chown -R $(USER):$(GROUP) $(SLASH_PREFIX)/sbin
	#chown -R $(USER):$(GROUP) $(SLASH_PREFIX)/bin
	#chown -R $(USER):$(GROUP) $(SLASH_PREFIX)/sql
	#chown -R $(USER):$(GROUP) $(SLASH_PREFIX)/plugins

reload: install
	apachectl stop
	apachectl start
#   cleanup
clean:
	find . \( -name '*.[oas]' -o -name '*.so' -o -name '*.old' \) -type f -print |xargs rm -f
	find . \( -name '*.xs' \) -type f -print |xargs rm -f
	(cd plugins; make clean)
	(cd Slash; make clean)

dist: $(DISTVNAME).tar$(SUFFIX)

$(DISTVNAME).tar$(SUFFIX) : distdir
	$(PREOP)
	$(TO_UNIX)
	$(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME)
	$(RM_RF) $(DISTVNAME)
	$(COMPRESS) $(DISTVNAME).tar
	$(POSTOP)

distdir :
	$(RM_RF) $(DISTVNAME)
	$(PERL) -MExtUtils::Manifest=manicopy,maniread \
	-e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');"

manifest :
	(cd Slash; make distclean)
	$(PERL) -MExtUtils::Manifest -e 'ExtUtils::Manifest::mkmanifest'

rpm :
	rpm -ba slash.spec