-
- foreach my $dir (("src","src/commands","src/modes","src/socketengines","src/modules"))
- {
- print "Scanning \e[1;32m$dir\e[0m for core files ";
- opendir(DIRHANDLE, $dir);
- foreach my $name (sort readdir(DIRHANDLE))
- {
- if ($name =~ /\.cpp$/)
- {
- open (CPP, "<$dir/$name") or die("Can't open $dir/$name to scan it! oh bugger");
- print ".";
- while (defined(my $line = <CPP>))
- {
- chomp($line);
- if ($line =~ /\/\* \$Core: (\w+) \*\//i)
- {
- $filelist{$name} = $1;
- }
- elsif ($line =~ /\/\* \$ExtraDeps: (.*?) \*\//i)
- {
- $specialdeps{$name} = $1;
- }
- elsif ($line =~ /\/\* \$ExtraObjects: (.*?) \*\//i)
- {
- $extraobjects{$name} = $1;
- }
- elsif ($line =~ /\/\* \$ExtraBuild: (.*?) \*\//i)
- {
- $extrabuildlines{$name} = $1;
- }
- elsif ($line =~ /\/\* \$ExtraSources: (.*?) \*\//i)
- {
- $extrasources{$name} = $1;
- }
- elsif ($line =~ /\/\* \$If: (\w+) \*\//i)
- {
- if (defined $config{$1})
- {
- if (($config{$1} !~ /y/i) and ($config{$1} ne "1"))
- {
- # Skip to 'endif'
- while (defined($line = <CPP>))
- {
- chomp($line);
- die ("\$If buildsystem instruction within another \$If in file $dir/$name") if ($line =~ /\/\* \$If: (\w+) \*\//i);
- last if ($line =~ /\/\* \$EndIf \*\//i);
- }
- }
- }
- }
- elsif ($line =~ /\/\* \$Install: (.*?) \*\//i)
- {
- if (!exists($existing_install_list{$1}))
- {
- $existing_install_list{$1} = 1;
- my $idir = (split(' ',$1))[1];
- my $ifile = (split(' ',$1))[0];
- $install_list = $install_list . " -install -m \$(INSTMODE) $1\n";
- $ifile =~ s/.*\///g;
- $uninstall_list = $uninstall_list . " -rm $idir/$ifile\n";
- }
- }
- elsif ($line =~ /\/\* \$CopyInstall: (.*?) \*\//i)
- {
- if (!exists($existing_install_list{$1}))
- {
- $existing_install_list{$1} = 1;
- my $idir = (split(' ',$1))[1];
- my $ifile = (split(' ',$1))[0];
- $install_list = $install_list . " -cp $1\n";
- $ifile =~ s/.*\///g;
- $uninstall_list = $uninstall_list . " -rm $idir/$ifile\n";
- }
- }
- }
- close CPP;
- }
- }
- closedir(DIRHANDLE);
- print " done!\n";
- }
-
- my $freebsd4libs = (defined $config{CRAQ} ? $config{CRAQ} : "");
-
- my $all = "all: ";
- my $all_libsonly = "";
-
- my $libraryext = "";
- my $othercrap = "";
- my $RPATH = "";
-
- if ($config{IS_DARWIN} eq "YES")
- {
- $libraryext = "dylib";
- $othercrap = " @../make/run-cc.pl \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspircd.cpp\n ../make/run-cc.pl \$(CC) -pipe -dynamic -bind_at_load -L. -o inspircd \$(LDLIBS) inspircd.o "
- }
- else
- {
- $libraryext = "so";
- $RPATH = "-Wl,--rpath -Wl,$config{LIBRARY_DIR}" unless defined $opt_disablerpath;
- $othercrap = " @../make/run-cc.pl \$(CC) -pipe -I../include $RPATH \$(FLAGS) $freebsd4libs -rdynamic -L. inspircd.cpp -o inspircd \$(LDLIBS) ";
- }
-
- foreach my $cpp (sort keys %filelist)
- {
- $all = $all . $filelist{$cpp} . "." . $libraryext . " ";
- $all_libsonly = $all_libsonly . $filelist{$cpp} . "." . $libraryext . " ";
- $install_list = $install_list . " -install -m \$(INSTMODE) src/" . $filelist{$cpp} . "." . $libraryext . " \$(LIBPATH)\n";
- $uninstall_list = $uninstall_list . " -rm \$(LIBPATH)/" . $filelist{$cpp} . "." . $libraryext . "\n";
- }
- $all = $all . "moo inspircd\n";
-
- $othercrap = $othercrap . " $all_libsonly\n\n";
-
- open(FH,">src/Makefile") or die("Could not write src/Makefile");
- print FH <<EOM;
-
-CC = im a cheezeball
-CXXFLAGS = -I../include \${FLAGS}
-CPPFILES = \$(shell /bin/ls -l modes/ | grep '\\.cpp' | sed 's/^.* //' | grep -v svn)
-RELCPPFILES = \$(shell /bin/ls -l modes/ | grep '\\.cpp' | sed 's/^.* /modes\\//' | grep -v svn)
-
-EOM
-
- print FH "$all\n\n";
-
- my $deps = calcdeps("src/inspircd.cpp");
- print FH "inspircd: inspircd.cpp $deps $all_libsonly\n";
- print FH "$othercrap\n";
-
- foreach my $cpp (sort keys %filelist)
- {
- my $thislib = $filelist{$cpp} . "." . $libraryext;
- my $objs = $cpp;
- my $rawcpp = $cpp;
- my $libcrap = "";
- $objs =~ s/\.cpp$/.o/;
- if (exists($extraobjects{$cpp}))
- {
- $objs = $objs . " " . $extraobjects{$cpp};
- }
- if (exists($extrasources{$cpp}))
- {
- $rawcpp = $rawcpp . " " . $extrasources{$cpp};
- }
- if ($config{IS_DARWIN} eq "YES")
- {
- $libcrap = "-install_name " . $config{LIBRARY_DIR} . "/" . $thislib . " -dynamiclib -twolevel_namespace -undefined dynamic_lookup";
- }
- else
- {
- if (defined $opt_disablerpath)
- {
- $libcrap = " -shared";
- }
- else
- {
- $libcrap = "-Wl,--rpath -Wl," . $config{LIBRARY_DIR} . " -shared";
- }
- }
- $deps = calcdeps("src/$cpp");
- if (exists($extrasources{$cpp}))
- {
- foreach my $seperate (sort split(' ',$extrasources{$cpp}))
- {
- my $d = calcdeps("src/$extrasources{$cpp}") . " ";
- if ($d ne "")
- {
- $deps = $deps . $d . " ";
- }
- }
- }
- print FH $thislib . ": $cpp $deps ". (defined($specialdeps{$cpp}) ? $specialdeps{$cpp} : "") . "\n";
- print FH " @../make/run-cc.pl \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c $rawcpp\n";
- if (exists($extrabuildlines{$cpp}))
- {
- print FH " " . $extrabuildlines{$cpp} . "\n";
- }
- print FH " @../make/run-cc.pl \$(CC) -pipe $libcrap -o " . $thislib . " " . $objs . "\n\n";
- }
-
- print FH "moo:\n \${MAKE} -C \"commands\" DIRNAME=\"src/commands\" CC=\"\$(CC)\" \$(MAKEARGS)\n\n";
-
- # close main makefile
- close(FH);
-
- my $cmdobjs = "";
- # generate a list of .so
- foreach my $cmd (@cmdlist) {
- $cmdobjs = $cmdobjs . "cmd_$cmd.so ";
- }
-
- # and now reopen the commands makefile
- open(FH,">src/commands/Makefile") or die("Could not write src/commands/Makefile");
- print FH <<ITEM;
-CC = i am cornholio
-CXXFLAGS = -I../../include \${FLAGS}
-
-all: $cmdobjs
-
-
-ITEM
-
- # now print the command file details.
- foreach my $cmd (@cmdlist) {
- print FH <<ITEM;
-cmd_$cmd.so: cmd_$cmd.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/globals.h ../../include/inspircd_config.h ../../include/commands/cmd_$cmd.h
- @../../make/run-cc.pl \$(CC) -pipe -I../../include \$(FLAGS) -export-dynamic -c cmd_$cmd.cpp
- @../../make/run-cc.pl \$(CC) -pipe $SHARED -o cmd_$cmd.so cmd_$cmd.o
-
-ITEM
- }
-#try build a .so, no intermediate .o
-# @../../make/run-cc.pl \$(CC) -pipe -I../../include \$(FLAGS) -export-dynamic $SHARED -o cmd_$cmd.so
-
-#this works for sure
-# @../../make/run-cc.pl \$(CC) -pipe -I../../include \$(FLAGS) -export-dynamic -c cmd_$cmd.cpp
-# @../../make/run-cc.pl \$(CC) -pipe $SHARED -o cmd_$cmd.so cmd_$cmd.o