Jelajahi Sumber

* Don't require TCL for compiling

Bryan Drewery 15 tahun lalu
induk
melakukan
336a397859
6 mengubah file dengan 46 tambahan dan 23 penghapusan
  1. 7 9
      autotools/includes/libtcl.m4
  2. 3 0
      config.h.in
  3. 9 9
      configure
  4. 4 0
      src/cmds.c
  5. 20 4
      src/libtcl.c
  6. 3 1
      src/libtcl.h

+ 7 - 9
autotools/includes/libtcl.m4

@@ -388,16 +388,14 @@ configure: error:
 
   Tcl cannot be found on this system.
 
-  Eggdrop requires Tcl to compile. If you already have Tcl installed on
-  this system, and I just wasn't looking in the right place for it, re-run
-  ./configure using the --with-tcllib='/path/to/libtcl.so' and
-  --with-tclinc='/path/to/tcl.h' options.
-
-  See doc/COMPILE-GUIDE's 'Tcl Detection and Installation' section for more
-  information.
+  Tcl is not required. Wraith will be compiled without TCL support. If you
+  already have Tcl installed on this system, and I just wasn't looking in
+  the right place for it, re-run ./configure using the
+  --with-tcllib='/path/to/libtcl.so' and --with-tclinc='/path/to/tcl.h' options.
 
 EOF
-    exit 1
+  else
+    AC_DEFINE(HAVE_LIBTCL, 1, [Define if you have support for libtcl])
   fi
 ])
 
@@ -408,7 +406,7 @@ AC_DEFUN([EGG_TCL_CHECK_PRE70],
 [
   # Is this version of Tcl too old for us to use ?
   TCL_VER_PRE70=`echo $egg_cv_var_tcl_version | $AWK '{split([$]1, i, "."); if (i[[1]] < 7) print "yes"; else print "no"}'`
-  if test "$TCL_VER_PRE70" = yes; then
+  if test "$HAVE_LIBTCL" = 1 -a "$TCL_VER_PRE70" = yes; then
     cat << EOF >&2
 configure: error:
 

+ 3 - 0
config.h.in

@@ -72,6 +72,9 @@
 /* Define to 1 if you have the `socket' library (-lsocket). */
 #undef HAVE_LIBSOCKET
 
+/* Define if you have support for libtcl */
+#undef HAVE_LIBTCL
+
 /* Define to 1 if you have the <limits.h> header file. */
 #undef HAVE_LIMITS_H
 

+ 9 - 9
configure

@@ -5794,22 +5794,22 @@ configure: error:
 
   Tcl cannot be found on this system.
 
-  Eggdrop requires Tcl to compile. If you already have Tcl installed on
-  this system, and I just wasn't looking in the right place for it, re-run
-  ./configure using the --with-tcllib='/path/to/libtcl.so' and
-  --with-tclinc='/path/to/tcl.h' options.
-
-  See doc/COMPILE-GUIDE's 'Tcl Detection and Installation' section for more
-  information.
+  Tcl is not required. Wraith will be compiled without TCL support. If you
+  already have Tcl installed on this system, and I just wasn't looking in
+  the right place for it, re-run ./configure using the
+  --with-tcllib='/path/to/libtcl.so' and --with-tclinc='/path/to/tcl.h' options.
 
 EOF
-    exit 1
+  else
+
+$as_echo "#define HAVE_LIBTCL 1" >>confdefs.h
+
   fi
 
 
   # Is this version of Tcl too old for us to use ?
   TCL_VER_PRE70=`echo $egg_cv_var_tcl_version | $AWK '{split($1, i, "."); if (i[1] < 7) print "yes"; else print "no"}'`
-  if test "$TCL_VER_PRE70" = yes; then
+  if test "$HAVE_LIBTCL" = 1 -a "$TCL_VER_PRE70" = yes; then
     cat << EOF >&2
 configure: error:
 

+ 4 - 0
src/cmds.c

@@ -4528,6 +4528,7 @@ void cmd_test(int idx, char *par)
   putlog(LOG_CMDS, "*", "#%s# test", dcc[idx].nick);
 }
 
+#ifdef HAVE_LIBTCL
 void cmd_tcl(int idx, char *par)
 {
   if (!isowner(dcc[idx].nick)) {
@@ -4543,6 +4544,7 @@ void cmd_tcl(int idx, char *par)
   } else
     dprintf(idx, result.c_str(), DP_SERVER);
 }
+#endif
 
 void cmd_botlink(int idx, char *par)
 {
@@ -4666,7 +4668,9 @@ cmd_t C_dcc[] =
   {"w", 		"n", 	(Function) cmd_w, 		NULL, 0},
   {"channels", 		"", 	(Function) cmd_channels, 	NULL, 0},
   {"test",		"",	(Function) cmd_test,		NULL, 0},
+#ifdef HAVE_LIBTCL
   {"tcl",		"a",	(Function) cmd_tcl,		NULL, AUTH_ALL},
+#endif
   {"botlink",		"a",	(Function) cmd_botlink,		NULL, 0},
   {"randstring", 	"", 	(Function) cmd_randstring, 	NULL, AUTH_ALL},
   {"hash",		"",	(Function) cmd_hash,		NULL, AUTH_ALL},

+ 20 - 4
src/libtcl.c

@@ -28,19 +28,22 @@
 #include "common.h"
 #include "main.h"
 #include "dl.h"
-#include <tcl.h>
 #include <bdlib/src/String.h>
 #include <bdlib/src/Array.h>
 
 #include "libtcl.h"
 
+#ifdef HAVE_LIBTCL
 Tcl_Interp *global_interp = NULL;
+#endif
+
 void *libtcl_handle = NULL;
 static bd::Array<bd::String> my_symbols;
 
 void initialize_binds_tcl();
 
 static int load_symbols(void *handle) {
+#ifdef HAVE_LIBTCL
   const char *dlsym_error = NULL;
 
   DLSYM_GLOBAL(handle, Tcl_Eval);
@@ -51,14 +54,20 @@ static int load_symbols(void *handle) {
   DLSYM_GLOBAL(handle, Tcl_CreateInterp);
   DLSYM_GLOBAL(handle, Tcl_FindExecutable);
   DLSYM_GLOBAL(handle, Tcl_Init);
+#endif
 
   return 0;
 }
 
 int load_libtcl() {
+#ifndef HAVE_LIBTCL
+  sdprintf("Not compiled with TCL support");
+  return 1;
+#else
   if (global_interp) {
     return 0;
   }
+#endif
 
   bd::Array<bd::String> libs_list(bd::String("libtcl.so libtcl83.so libtcl8.3.so libtcl84.so libtcl8.4.so libtcl85.so libtcl8.5.so").split(' '));
 
@@ -74,6 +83,7 @@ int load_libtcl() {
 
   load_symbols(libtcl_handle);
 
+#ifdef HAVE_LIBTCL
   // create interp
   global_interp = Tcl_CreateInterp();
   Tcl_FindExecutable(binname);
@@ -84,10 +94,12 @@ int load_libtcl() {
   }
 
   initialize_binds_tcl();
-
+#endif
   return 0;
 }
 
+#ifdef HAVE_LIBTCL
+
 #include "chanprog.h"
 static int cmd_privmsg STDVAR {
   BADARGS(3, 999, " channel string");
@@ -103,12 +115,16 @@ void initialize_binds_tcl() {
   Tcl_CreateCommand(global_interp, "privmsg", (Tcl_CmdProc*) cmd_privmsg, NULL, NULL);
 }
 
+#endif
+
 int unload_libtcl() {
   if (libtcl_handle) {
+#ifdef HAVE_LIBTCL
     if (global_interp) {
       Tcl_DeleteInterp(global_interp);
       global_interp = NULL;
     }
+#endif
 
     // Cleanup symbol table
     for (size_t i = 0; i < my_symbols.length(); ++i) {
@@ -124,7 +140,7 @@ int unload_libtcl() {
   return 1;
 }
 
-
+#ifdef HAVE_LIBTCL
 bd::String tcl_eval(const bd::String& str) {
   load_libtcl();
   if (!global_interp) return bd::String();
@@ -134,4 +150,4 @@ bd::String tcl_eval(const bd::String& str) {
     return tcl_eval("set errorInfo");
   return bd::String();
 }
-
+#endif

+ 3 - 1
src/libtcl.h

@@ -4,6 +4,7 @@
 #include "common.h"
 #include "dl.h"
 #include <bdlib/src/String.h>
+#ifdef HAVE_LIBTCL
 #include <tcl.h>
 
 typedef int (*Tcl_Eval_t)(Tcl_Interp*, const char*);
@@ -28,10 +29,11 @@ typedef int (*Tcl_Init_t)(Tcl_Interp*);
 } while (0)
 
 extern Tcl_Interp *global_interp;
+bd::String tcl_eval(const bd::String&);
+#endif
 
 int load_libtcl();
 int unload_libtcl();
-bd::String tcl_eval(const bd::String&);
 
 
 #endif /* !_LIBTCL_H */