[AD] Magic main UNIX, final (?) take

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Tha attached patch is a modified version of my last one on the subject.
Magic main is disabled on UNIX systems by default, but can still be 
re-enabled using configure if needed.
The default setting is disabled, since on all UNIX systems I've tested this 
on, with the current implementation of get_executable_name, a magic main 
is not needed.

Evert
Index: configure.in
===================================================================
RCS file: /cvsroot/alleg/allegro/configure.in,v
retrieving revision 1.82
diff -u -r1.82 configure.in
--- configure.in	17 Aug 2004 19:39:42 -0000	1.82
+++ configure.in	25 Aug 2004 08:29:20 -0000
@@ -118,6 +118,11 @@
    _warnmode="Ignoring compiler warnings."
 fi
 
+dnl Enable magic main (default: no).
+AC_ARG_ENABLE(magicmain,
+[  --enable-magicmain[=x]  enable magic main [default=no]],
+test "X$enableval" == "Xyes" && AC_DEFINE(ALLEGRO_WITH_MAGIC_MAIN,1,[Define if you need to use a magic main.]))
+
 dnl Check that $prefix is set (needed for ALLEGRO_ACTEST_GCC_INCLUDE_PREFIX)
 test "$prefix" = NONE && prefix=/usr/local
 
Index: include/allegro/platform/alunix.h
===================================================================
RCS file: /cvsroot/alleg/allegro/include/allegro/platform/alunix.h,v
retrieving revision 1.12
diff -u -r1.12 alunix.h
--- include/allegro/platform/alunix.h	9 Apr 2004 10:37:45 -0000	1.12
+++ include/allegro/platform/alunix.h	25 Aug 2004 08:29:21 -0000
@@ -21,6 +21,9 @@
 #endif
 
 
+#undef END_OF_MAIN
+#ifdef ALLEGRO_WITH_MAGIC_MAIN
+
 /* magic to capture name of executable file */
 extern int    __crt0_argc;
 extern char **__crt0_argv;
@@ -28,13 +31,13 @@
 #ifndef ALLEGRO_NO_MAGIC_MAIN
    #define ALLEGRO_MAGIC_MAIN
    #define main _mangled_main
-   #undef END_OF_MAIN
    #define END_OF_MAIN() void *_mangled_main_address = (void*) _mangled_main;
 #else
-   #undef END_OF_MAIN
    #define END_OF_MAIN() void *_mangled_main_address;
 #endif
 
+#endif
+
 
 
 /**************************************/
Index: src/unix/udjgpp.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/unix/udjgpp.c,v
retrieving revision 1.2
diff -u -r1.2 udjgpp.c
--- src/unix/udjgpp.c	6 Nov 2001 15:30:47 -0000	1.2
+++ src/unix/udjgpp.c	25 Aug 2004 08:29:22 -0000
@@ -18,10 +18,11 @@
 
 #include "allegro/internal/alconfig.h"
 
-
+#ifdef ALLEGRO_WITH_MAGIC_MAIN
 
 static char *_allegro_program_arguments[] = { "./unknown", 0 };
 
 int    __crt0_argc = 1;
 char **__crt0_argv = _allegro_program_arguments;
 
+#endif
Index: src/unix/umain.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/unix/umain.c,v
retrieving revision 1.2
diff -u -r1.2 umain.c
--- src/unix/umain.c	6 Nov 2001 15:30:47 -0000	1.2
+++ src/unix/umain.c	25 Aug 2004 08:29:22 -0000
@@ -17,6 +17,9 @@
 
 
 #include "allegro/internal/alconfig.h"
+
+#ifdef ALLEGRO_WITH_MAGIC_MAIN
+
 #undef main
 
 
@@ -39,3 +42,4 @@
    return (*real_main)(argc, argv);
 }
 
+#endif
Index: src/unix/usystem.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/unix/usystem.c,v
retrieving revision 1.31
diff -u -r1.31 usystem.c
--- src/unix/usystem.c	17 Aug 2004 19:39:43 -0000	1.31
+++ src/unix/usystem.c	25 Aug 2004 08:29:22 -0000
@@ -410,9 +410,11 @@
       return;
    }
 
+#ifdef ALLEGRO_WITH_MAGIC_MAIN
    /* Try the captured argv[0] */   
    if (_find_executable_file(__crt0_argv[0], output, size))
       return;
+#endif
 
    /* Give up; return empty string */
    do_uconvert ("", U_ASCII, output, U_CURRENT, size);


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/