- if ($config{STATIC_LINK} eq "yes") {
- print "Writing static-build \033[1;32msrc/Makefile\033[0m\n";
- write_static_makefile();
- write_static_modules_makefile();
- } elsif ($config{OSNAME} =~ /CYGWIN/i) {
- print "Writing cygwin-build \033[1;32msrc/Makefile\033[0m\n";
- write_static_makefile();
- write_dynamic_modules_makefile();
- } else {
- print "Writing dynamic-build \033[1;32msrc/Makefile\033[0m\n";
- write_dynamic_makefile();
- write_dynamic_modules_makefile();
- }
-}
-
-sub write_static_modules_makefile {
- # Modules Makefile..
- print "Writing \033[1;32msrc/modules/Makefile\033[0m\n";
- open(FILEHANDLE, ">src/modules/Makefile");
-
- ###
- # Module Makefile Header
- ###
- print FILEHANDLE <<EOF;
-# (C) ChatSpike development team
-# Makefile by <Craig\@ChatSpike.net>
-# Many Thanks to Andrew Church <achurch\@achurch.org>
-# for assisting with making this work right.
-#
-# Automatically Generated by ./configure to add a modules
-# please run ./configure --update
-
-all: \$(MODULES)
-
-EOF
- ###
- # End Module Makefile Header
- ###
-
- # Create a Modules List..
- my $modules = "";
- my $cmflags = "";
- my $liflags = "";
-
- open(MODLIST,">include/modlist.h");
-
- ###
- # Include File Header
- ###
- print MODLIST <<HEADER;
-// Generated automatically by configure. DO NOT EDIT!
-
-#ifndef __SYMBOLS__H_CONFIGURED__
-#define __SYMBOLS__H_CONFIGURED__
-
-HEADER
- ###
- # End Include File Header
- ###
-
- # Place Module List into Include
- foreach $i (@modlist) {
- if ($i !~ /_static$/) {
- print MODLIST "extern \"C\" void * $i\_init (void);\n";
- }
- }
- print MODLIST "\nstruct {const char *name; initfunc *value; } modsyms[] = {\n";
-
- ###
- # Build Module Crap
- ###
- foreach $i (@modlist)
- {
- if ($i !~ /_static$/) {
- $cmflags = getcompilerflags("src/modules/m_".$i.".cpp");
- $liflags = getlinkerflags("src/modules/m_".$i.".cpp");
- $deps = getdependencies("src/modules/m_".$i.".cpp");
-
- #print "file: $i: cmflags=$cmflags; liflags=$liflags; deps=$deps\n";
-
- ###
- # Write Entry to the Makefile
- ###
- print FILEHANDLE <<EOCHEESE;
-m_$i.o: .m_$i\_static.cpp ../../include/modules.h ../../include/users.h ../../include/channels.h ../../include/base.h $deps
- \$(CC) -pipe -I../../include \$(FLAGS) $flags -export-dynamic -c .m_$i\_static.cpp
- mv .m_$i\_static.o ../m_$i.o
-
-EOCHEESE
- ###
- # End Write Entry to the MakeFile
- ###
- print "Configuring module [\033[1;32mm_$i.so\033[0m] for static linking... ";
- open(MODULE,"<src/modules/m_".$i.".cpp") or die("Could not open m_".$i.".cpp");
- open(MUNGED,">src/modules/.m_".$i."_static.cpp") or die("Could not create .m_".$i."_static.cpp");
- while (chomp($a = <MODULE>)) {
- $a =~ s/init_module/$i\_init/g;
- print MUNGED "$a\n";
- }
- close(MODULE);
- close(MUNGED);
- print MODLIST <<EOENT;
-{"m_$i.so",\&$i\_init},
-EOENT
- print "done\n";
- }
- }
-
- print MODLIST "{0}};\n\n#endif\n";
- close(MODLIST);