#!/usr/bin/perl -w # My generic configure script for mod_mp3 # -Brian (brian@tangent.org) use strict; use Getopt::Long; use File::Find; use File::Path; (my $REVERSION) = ' $Revision: 1.43 $ ' =~ /\$Revision:\s+([^\s]+)/; my $VERSION = '0.40'; my @SRC = qw| mod_mp3 directives ice load shout utility ogg common id3 log internal_dispatch encode |; my $DEF = ""; my $INC = ""; my $LIB = '$(ACFLAGS)'; my @path = qw| /usr/bin /usr/sbin /bin /usr/local/apache/bin /usr/local/bin /usr/local/sbin|; print STDERR "ARGS @ARGV \n"; my ($playlist, $with_mysql, $with_pgsql, $with_db, $apxs, $debug, $content_disposition, $perl, $no_select_display, $ghttp, $no_directory); GetOptions( 'with-ghttp:s' => \$ghttp, 'with-mysql:s' => \&with_mysql, 'with-postgres:s' => \&with_pgsql, 'with-playlist' => \$playlist, 'with-db:s' => \&with_db, 'with-perl=s' => \$perl, 'with-debug' => \$debug, 'without-content_disposition' => \$content_disposition, 'with-apxs:s' => \$apxs, 'without-select' => \$no_select_display, 'without-yp' => \$no_directory, 'version' => \&version, 'help' => \&usage ); $DEF .= ' -DDEBUG -Wall ' if $debug; $DEF .= ' -DCONTENT_DISPOSITION ' unless $content_disposition; $DEF .= ' -DSELECT_ENABLED ' unless $no_select_display; unless ($no_directory) { if($ghttp = find_ghttp($ghttp)) { $DEF .= ' -DYP_ENABLED '; push @SRC, 'directory_register'; } } with_db() if $playlist && !$with_db; $perl = find_perl($perl); find_apxs($apxs); find_php($apxs) if $with_mysql; if (!$no_directory && $ghttp) { print "adding directory services support \n"; } if ($debug) { print "adding debug info \n"; } print "adding support for internal dispatch\n"; print "adding support for mysql dispatch\n" if $with_mysql; print "adding support for postgres dispatch\n" if $with_pgsql; if ($playlist) { print "adding support for playlist dispatch\n" if ($with_db == 1); } find_php($apxs) if $with_mysql; print_proto(); print "Writing proto.h\n"; print "Writing Makefile\n"; print "Now type:\n"; print "\tmake clean; make; make install\n"; print "\nThanks for using mod_mp3\n"; print "\t -Brian Aker (brian\@tangent.org)\n\n"; print_makefile(); 1; sub usage { print <; $found = 1 if (-e "$command[0]/libphp4.so"); $found = 1 if (-e "/usr/lib/apache-extramodules/libphp4.so"); if ($found) { print "found\n"; print <src/proto.h") or die "Could not open src/proto.h"; print PROTO <); my ($src, $obj, $compile); for (@SRC) { $compile .= qq|\nsrc/$_.lo : src/$_.c\n|; $compile .= qq|\t\$(CC) \$(CFLAGS_SHLIB) \$(INC) -c src/$_.c \$(DEF) -o src/$_.lo \n|; $src .=" $_.c"; $obj .=" src/$_.lo"; } $data =~ s|%APXS%|$apxs|sg; $data =~ s|%VERSION%|$VERSION|sg; $data =~ s|%SRC_COMPILE%|$compile|sg; $data =~ s|%SRC%|$src|sg; $data =~ s|%OBJ%|$obj|sg; $data =~ s|%PERL%|$perl|sg; $data =~ s|%DEF%|$DEF|sg; $data =~ s|%INC%|$INC|sg; $data =~ s|%LIB%|$LIB|sg; open(MAKE, ">Makefile") or die "Could not open Makefile"; print MAKE $data; close(MAKE); } __DATA__ ## ## Makefile -- Build procedure for mod_mp3 ## # the used tools APXS=%APXS% APACHECTL=apachectl VERSION = %VERSION% DISTNAME = mod_mp3 DISTVNAME = $(DISTNAME)-$(VERSION) SRC = %SRC% OBJ = %OBJ% SHELL = /bin/sh PERL = %PERL% NOOP = $(SHELL) -c true RM_RF = rm -rf SUFFIX = .gz COMPRESS = gzip --best TAR = tar CP = cp TARFLAGS = cvf PREOP = @$(NOOP) POSTOP = @$(NOOP) TO_UNIX = @$(NOOP) AINCLUDEDIR=-I`$(APXS) -q INCLUDEDIR` `$(APXS) -q CFLAGS` ACFLAGS=-I`$(APXS) -q INCLUDEDIR` LD_SHLIB=`$(APXS) -q LDFLAGS_SHLIB` CFLAGS_SHLIB=`$(APXS) -q CFLAGS_SHLIB` CC=`$(APXS) -q CC` LD=`$(APXS) -q LD_SHLIB` CONFDIR=`$(APXS) -q SYSCONFDIR` DEF = %DEF% INC = %INC% $(AINCLUDEDIR) $(DEF) LIB = %LIB% # the default target all: mod_mp3.so # compile the DSO file mod_mp3.so: $(OBJ) Makefile $(APXS) -c $(LIB) $(OBJ) %SRC_COMPILE% # install the DSO file into the Apache installation # and activate it in the Apache configuration install: all $(APXS) -i -a -n 'mp3' src/mod_mp3.so if [ -f $(CONFDIR)/mp3.conf ]; then\ echo "Preserving old mp3.conf"; \ $(CP) support/mp3.conf $(CONFDIR)/mp3.conf.default; \ else \ $(CP) support/mp3.conf $(CONFDIR)/mp3.conf; \ fi @echo "+--------------------------------------------------------+"; \ echo "| All done. |"; \ echo "| If you want to use the default mod_mp3 configure file |"; \ echo "| go add: |"; \ echo "| |"; \ echo "| Include $(CONFDIR)/mp3.conf |"; \ echo "| |"; \ echo "| to your httpd.conf for apache. |"; \ echo "| If not, cat its content into your httpd.conf file. |"; \ echo "| |"; \ echo "| Thanks for installing mod_mp3. |"; \ echo "+--------------------------------------------------------+"; \ # cleanup clean: -rm -f $(OBJ) mod_mp3.so *~~ # simple test test: reload xmms http://127.0.0.1:8000/ & # reload the module by installing and restarting Apache reload: install stop start # the general Apache start/restart/stop procedures start: $(APACHECTL) start restart: $(APACHECTL) restart stop: $(APACHECTL) stop dist: version $(DISTVNAME).tar$(SUFFIX) rpm: #all dist cp $(DISTVNAME).tar$(SUFFIX) /usr/src/redhat/SOURCES rpm -ba $(DISTNAME).spec cp /usr/src/redhat/RPMS/i386/$(DISTVNAME)*.i386.rpm . cp /usr/src/redhat/SRPMS/$(DISTVNAME)*.src.rpm . version: echo $(VERSION) > VERSION echo "#define VERSION \"$(VERSION)\"" > src/version.h cat mod_mp3.spec | $(PERL) -e 'while () { push @file, $$_} open(FILE, ">mod_mp3.spec"); for(@file) { if (/^Version/) { print FILE "Version: ${VERSION}\n" } else { print FILE $$_}}' $(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)');" docs : tpod2html support/faq.pod > faq.html pod2text support/faq.pod > faq push : if [ -F *.gz ] ; then \ rm *.gz; \ fi make dist scp $(DISTVNAME).tar$(SUFFIX) root@www.tangent.org:/usr/local/slash/site/www.tangent.org/htdocs/download scp $(DISTVNAME).tar$(SUFFIX) root@ftp.tangent.org:/var/ftp/pub/apache scp $(DISTVNAME)*.i386.rpm root@www.tangent.org:/usr/local/slash/site/www.tangent.org/htdocs/download scp $(DISTVNAME)*i386.rpm root@ftp.tangent.org:/var/ftp/pub/apache scp faq.html root@www.tangent.org:/usr/local/slash/site/www.tangent.org/htdocs/faqs/mod_mp3.html proto : $(PERL) utils/protobuild.pl > src/proto.h