This is the mail archive of the xconq7@sources.redhat.com mailing list for the Xconq project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Please check these instructions for MSC_README


Here's my instructions for creating a MS VC project for Xconq:

***********************************************************************
I'm assuming that you have a properly instally MSVC 5 or 6.
For this example, I have a CVS version of xconq in 
C:\cygwin\home\sutton\xconq.  I also have a copy of Active TCL
in C:\Tcl.

So Create a new Workspace (File->New, select Workspace Tab), and 
Create a workspace "WinXconq" in C:\Cygwin\home\sutton.  It's 
easiest to create in in a directory parallel to xconq, but you can
put it anywhere you want, of course.

Now open the kernel Makefile.in.  (File->Open) (Select All files option,
and go to your xconq/kernel directory).

Now we're going to create a dummy project file, WconqTCL.  Create
a new Win32app (File->New, Project Tab, and select Win32 Application).
Set the radio button to "Add to current workspace", and click on Next.
Select "Create Empty Project" then "Finish".  Click "OK" on the 
confirmation screen.  Select the "File View" tab on the Workspace 
Area.

Now to build the libraries.  Look for OBJS in Makefile.in.  That is the
list
of .c files you will need for the first project (replace the .o with
.c to get the filename).  So Create a project "libconq". (File-New,
Projects 
Tab, "Win32 static library", "libconq" for name of project, 
"Add to workspace", "Depndancy of", "WconqTCL", "Next";  Don't check
any boxes on next screen, "Finish", and "OK" on confirmation screen.

Now we add the files in "OBJS" to the source file list.  I leave them
in the xconq direcotry, for two reasons.  It's easier to maintain 
CVS that way, and I can build both Cygwin and Win32 version off 
the same files.  So right click on the libconq files -> Source files
or Project->Set Active Project -> libconq and 
Project -> Add to Project -> Files.  This will be a file broser window.
Use the control key to select the .c files in the OBJ list. ( Or 
select the C++ Source files on the type list, select all the .c files
and use the Ctrl Key to unselect autotest.c, imf.c, imf2imf.c, lisp.c, 
mac.c skelcomp.c, socket.c, unix.c, util.c, and win32.c).  If you want,
you can test at this point by right clicking on libconq, and select
"Build (selection only)" to build the library.

Now we create another subroject, libconqlow, using the same procedure 
as for libconq, but using the list "LOBJS".  In addition, add socket.c
and win32.c.  After you create it, you'll need to do the 
followinh patches, if they haven't been checked in yet:

Just before the function "xrandom" in util.c, insert the following
lines:

#ifdef _MSC_VER
#define INT64 __int64
#else
#define INT64 long long
#endif

Then replace "long long" with INT64 in the two lines it appears
in in the function xrandom.

	long long bignum;

and
	bignum = m * ((long long) randstate);


You'll also need to modify win32.c.  After the #ifdef __CYGWIN__
block, add:

#ifdef _MSC_VER
#include <io.h>
#include <windows.h>
#endif

Then look for
#ifdef __CYGWIN32__
	mkdir(homedir, 0755);
#else
	mkdir(homedir);
#endif

Add, after the #else:

#ifdef _MSC_VER
    CreateDirectory(homedir,NULL);
#else

Aand add a second #endif after the #endif.  This will wind up
looking like:


#ifdef __CYGWIN32__
	mkdir(homedir, 0755);
#else
#ifdef _MSC_VER
    CreateDirectory(homedir,NULL);
#else
	mkdir(homedir);
#endif
#endif

Now patch socket.c by finding:

#if (defined (UNIX) || defined (MAC))
# include <netinet/tcp.h>
#endif

And insert after it:

#if defined(_MSC_VER)
#include <io.h>
#endif


You can now build libconqlow.


Now we go to the tcltk libraries.  Now we'll be looking at
tcltk\Makefile.in.  We'll create another Win32 static library,
libtkui.lib.  Use the files in OBJS, tkmain.c, tkinit.c,
tkcmd.c, and tkmap.c.  We'll need to go the settings, C/C++ tab,
Preprocessor dropdown. and put 
"..\..\xconq,..\..\xconq\kernel,C:\Tcl\include" in the "Additional
Include Directories" field.  If your Active Tcl is installed 
somewhere else, use your location.  If the path has blanks in it,
don't forget quotes.

Now, if the patch hasn't made it into CVS yet, add the following to
tkmain.c after the line:

#endif /* MAC */

Add the following lines:

#ifdef _MSC_VER

struct timeval {
    time_t tv_sec;
    int tv_usec;
};

#endif

You can compile and build libtkui.lib now.  You'll get over
3700 warnings with the default settings.

Now do the same thing for libtkimf.lib, using tkisamp.c 
and tkimf.c.

Now do the same thing for libtkiapp.lib, using tkiapp.c.

Finally, go back to the WconqTCL project, and add
tcltk/tkwin32.c as the source file.  Add the same Additional 
Include Directories as the previous 3 libraries.
Now go to  tab "Link", dropdown "Input". Add
"libtkui.lib libtkimf.lib libconq.lib libconqlow.lib wsock32.lib "
before
kernel32.lib in the "Object/Library Modules" field.  Then add
"..\libtkui\Debug;..\libtkimf\Debug;..\libconq\debug;..\libconqlow\Debug
;C:\Tcl\lib
to the "Additional Library Path" field.

Now edit tcltk/tkwin32.c and add the following lines after 
the last #include statement:


#ifdef __cplusplus
extern "C" {
#endif
extern int APIENTRY WinMain(HINSTANCE,HINSTANCE,LPSTR,int);

#ifdef __cplusplus
}
#endif

Now go to the end of the file and change:

/* Dummy versions of functions not emulated by Windows tk. */
int XSetTile(Display *dpy, GC gc, Pixmap pm) {}
int XFlush(Display *dpy) {}

/* Probably wrong, but makes cygwin b20 linking happy. */
int (*XSynchronize(Display *dpy, Bool b))(Display *dpy) { return NULL; }

to:

#ifdef _MSC_VER

/* Dummy versions of functions not emulated by Windows tk. */
void XSetTile(Display *dpy, GC gc, Pixmap pm) {}
void XFlush(Display *dpy) {}

#else 

/* Dummy versions of functions not emulated by Windows tk. */
int XSetTile(Display *dpy, GC gc, Pixmap pm) {}
int XFlush(Display *dpy) {}

#endif

Now add win/xconq.RC to the Resource Files and build.  For
Debug runs, add "-L ..\..\xconq\lib -x" to the argument list in
the Debug tab of the settings, or copy the WconqTCL.exe file to
your xconq directory for playing.

***********************************************************************
And here's the file diffs:

Index: kernel/socket.c
===================================================================
RCS file: /cvs/xconq/xconq/kernel/socket.c,v
retrieving revision 1.15
diff -r1.15 socket.c
46a47,50
> 
> #if defined(_MSC_VER)
> #include <io.h>
> #endif
Index: kernel/util.c
===================================================================
RCS file: /cvs/xconq/xconq/kernel/util.c,v
retrieving revision 1.22
diff -r1.22 util.c
145a146,151
> 
> #ifdef _MSC_VER
> #define INT64 __int64
> #else
> #define INT64 long long
> #endif
151,152c157,159
<     int rslt;
<     long long bignum;
---
>     int rslt;
> 
>     INT64 bignum;
161c168
< 	bignum = m * ((long long) randstate);
---
> 	bignum = m * ((INT64) randstate);
Index: kernel/win32.c
===================================================================
RCS file: /cvs/xconq/xconq/kernel/win32.c,v
retrieving revision 1.18
diff -r1.18 win32.c
41a42,46
> #endif
> 
> #ifdef _MSC_VER
> #include <io.h>
> #include <windows.h>
196c201,204
< 	mkdir(homedir, 0755);
---
> 	mkdir(homedir, 0755);
> #else
> #ifdef _MSC_VER
>     CreateDirectory(homedir,NULL);
198a207
> #endif
Index: tcltk/tkconq.h
===================================================================
RCS file: /cvs/xconq/xconq/tcltk/tkconq.h,v
retrieving revision 1.40
diff -r1.40 tkconq.h
20c20
< #endif /* MAC */
---
> #endif /* MAC */
21a22,30
> #ifdef _MSC_VER
> 
> struct timeval {
>     time_t tv_sec;
>     int tv_usec;
> };
> 
> #endif
> 
Index: tcltk/tkwin32.c
===================================================================
RCS file: /cvs/xconq/xconq/tcltk/tkwin32.c,v
retrieving revision 1.5
diff -r1.5 tkwin32.c
1c1,210
< /* The main program of the Win32 tcltk interface to Xconq.
   Copyright (C) 2002 Hans Ronne.

Xconq is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.  See the file COPYING.  */


#include "conq.h"
#include "kpublic.h"
#include "cmdline.h"
#include "tkconq.h"

#include <tk.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#undef WIN32_LEAN_AND_MEAN
#include <malloc.h>
#include <locale.h>

extern int use_stdio;

int blinking_curunit = FALSE;

static void setargv(int *argcPtr, char ***argvPtr);

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
lpszCmdLine, int nCmdShow)
{
    char **argv;
    int argc;
    char buffer[MAX_PATH+1];
    char *p;

    SetMessageQueue(64);
    setlocale(LC_ALL, "C");
    setargv(&argc, &argv);
    GetModuleFileName(NULL, buffer, sizeof(buffer));
    argv[0] = buffer;
    for (p = buffer; *p != '\0'; p++) {
	if (*p == '\\') {
	    *p = '/';
	}
    }

    use_stdio = FALSE;
    /* Tweak behavior of tcl/tk image handling. */
    use_clip_mask = FALSE;
    /* Dummy reference to get libraries pulled in */
    if (argc == -1)
      cmd_error(NULL, NULL);
    /* Shift to being the user that started the game. */
    init_library_path(NULL);
    /* Fiddle with game module structures. */
    clear_game_modules();
    /* Set up empty data structures. */
    init_data_structures();

    if (argc == 1)
      option_popup_new_game_dialog = TRUE;

    parse_command_line(argc, argv, general_options);
    initial_ui_init();

    /* If we're getting a startup dialog sequence, do it instead. */
    if (option_popup_new_game_dialog) {
	popup_game_dialog();
	ui_mainloop();
	/* Note that we never reach here. */
    }
    /* The straight-line setup sequence for a non-networked game set up
       using command-line arguments. */
    load_all_modules();
    check_game_validity();
    parse_command_line(argc, argv, variant_options);
    set_variants_from_options();
    parse_command_line(argc, argv, player_options);
    set_players_from_options();
    make_trial_assignments();
    /* Complain about anything that's left. */
    parse_command_line(argc, argv, leftover_options);
    launch_game();
    /* Go into the main play loop. */
    ui_mainloop();

    return 0;
}

/* Parses the command line. From the tcltk 8.3.4 winMain.c file. */

static void setargv(int *argcPtr, char ***argvPtr)
{
    char *cmdLine, *p, *arg, *argSpace;
    char **argv;
    int argc, size, inquote, copy, slashes;
    
    cmdLine = GetCommandLine();

    size = 2;
    for (p = cmdLine; *p != '\0'; p++) {
	if ((*p == ' ') || (*p == '\t')) {
	    size++;
	    while ((*p == ' ') || (*p == '\t')) {
		p++;
	    }
	    if (*p == '\0') {
		break;
	    }
	}
    }
    argSpace = (char *) Tcl_Alloc(
	    (unsigned) (size * sizeof(char *) + strlen(cmdLine) + 1));
    argv = (char **) argSpace;
    argSpace += size * sizeof(char *);
    size--;

    p = cmdLine;
    for (argc = 0; argc < size; argc++) {
	argv[argc] = arg = argSpace;
	while ((*p == ' ') || (*p == '\t')) {
	    p++;
	}
	if (*p == '\0') {
	    break;
	}

	inquote = 0;
	slashes = 0;
	while (1) {
	    copy = 1;
	    while (*p == '\\') {
		slashes++;
		p++;
	    }
	    if (*p == '"') {
		if ((slashes & 1) == 0) {
		    copy = 0;
		    if ((inquote) && (p[1] == '"')) {
			p++;
			copy = 1;
		    } else {
			inquote = !inquote;
		    }
                }
                slashes >>= 1;
            }

            while (slashes) {
		*arg = '\\';
		arg++;
		slashes--;
	    }

	    if ((*p == '\0')
		    || (!inquote && ((*p == ' ') || (*p == '\t')))) {
		break;
	    }
	    if (copy != 0) {
		*arg = *p;
		arg++;
	    }
	    p++;
        }
	*arg = '\0';
	argSpace = arg + 1;
    }
    argv[argc] = NULL;

    *argcPtr = argc;
    *argvPtr = argv;
}

/* The default (human) player is the current user on the current
display. */

Player *
add_default_player(void)
{
    Player *player = add_player();
    
    player->name = getenv("USER");
    player->configname = getenv("XCONQCONFIG");
    player->displayname = "WinTCL";
    return player;
}

void
make_default_player_spec(void)
{
  default_player_spec = "WinTCL";
}

/* Dummy versions of functions not emulated by Windows tk. */

void XSetTile(Display *dpy, GC gc, Pixmap pm) {}
void XFlush(Display *dpy) {}

/* Probably wrong, but makes cygwin b20 linking happy. */
int (*XSynchronize(Display *dpy, Bool b))(void) { return NULL; } \ No
newline at end of file
---
> /* The main program of the Win32 tcltk interface to Xconq.
>    Copyright (C) 2002 Hans Ronne.
> 
> Xconq is free software; you can redistribute it and/or modify
> it under the terms of the GNU General Public License as published by
> the Free Software Foundation; either version 2, or (at your option)
> any later version.  See the file COPYING.  */
> 
> 
> #include "conq.h"
> #include "kpublic.h"
> #include "cmdline.h"
> #include "tkconq.h"
> 
> #include <tk.h>
> #define WIN32_LEAN_AND_MEAN
> #include <windows.h>
> #undef WIN32_LEAN_AND_MEAN
> #include <malloc.h>
> #include <locale.h>
> 
> #ifdef __cplusplus
> extern "C" {
> #endif
> extern int APIENTRY WinMain(HINSTANCE,HINSTANCE,LPSTR,int);
> 
> #ifdef __cplusplus
> }
> #endif
> 
> extern int use_stdio;
> 
> int blinking_curunit = FALSE;
> 
> static void setargv(int *argcPtr, char ***argvPtr);
> 
> int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpszCmdLine, int nCmdShow)
> {
>     char **argv;
>     int argc;
>     char buffer[MAX_PATH+1];
>     char *p;
> 
> #ifndef _MSC_VER
>     SetMessageQueue(64);
> #endif
>     setlocale(LC_ALL, "C");
>     setargv(&argc, &argv);
>     GetModuleFileName(NULL, buffer, sizeof(buffer));
>     argv[0] = buffer;
>     for (p = buffer; *p != '\0'; p++) {
> 	if (*p == '\\') {
> 	    *p = '/';
> 	}
>     }
> 
>     use_stdio = FALSE;
>     /* Tweak behavior of tcl/tk image handling. */
>     use_clip_mask = FALSE;
>     /* Dummy reference to get libraries pulled in */
>     if (argc == -1)
>       cmd_error(NULL, NULL);
>     /* Shift to being the user that started the game. */
>     init_library_path(NULL);
>     /* Fiddle with game module structures. */
>     clear_game_modules();
>     /* Set up empty data structures. */
>     init_data_structures();
> 
>     if (argc == 1)
>       option_popup_new_game_dialog = TRUE;
> 
>     parse_command_line(argc, argv, general_options);
>     initial_ui_init();
> 
>     /* If we're getting a startup dialog sequence, do it instead. */
>     if (option_popup_new_game_dialog) {
> 	popup_game_dialog();
> 	ui_mainloop();
> 	/* Note that we never reach here. */
>     }
>     /* The straight-line setup sequence for a non-networked game set
up
>        using command-line arguments. */
>     load_all_modules();
>     check_game_validity();
>     parse_command_line(argc, argv, variant_options);
>     set_variants_from_options();
>     parse_command_line(argc, argv, player_options);
>     set_players_from_options();
>     make_trial_assignments();
>     /* Complain about anything that's left. */
>     parse_command_line(argc, argv, leftover_options);
>     launch_game();
>     /* Go into the main play loop. */
>     ui_mainloop();
> 
>     return 0;
> }
> 
> /* Parses the command line. From the tcltk 8.3.4 winMain.c file. */
> 
> static void setargv(int *argcPtr, char ***argvPtr)
> {
>     char *cmdLine, *p, *arg, *argSpace;
>     char **argv;
>     int argc, size, inquote, copy, slashes;
>     
>     cmdLine = GetCommandLine();
> 
>     size = 2;
>     for (p = cmdLine; *p != '\0'; p++) {
> 	if ((*p == ' ') || (*p == '\t')) {
> 	    size++;
> 	    while ((*p == ' ') || (*p == '\t')) {
> 		p++;
> 	    }
> 	    if (*p == '\0') {
> 		break;
> 	    }
> 	}
>     }
>     argSpace = (char *) Tcl_Alloc(
> 	    (unsigned) (size * sizeof(char *) + strlen(cmdLine) + 1));
>     argv = (char **) argSpace;
>     argSpace += size * sizeof(char *);
>     size--;
> 
>     p = cmdLine;
>     for (argc = 0; argc < size; argc++) {
> 	argv[argc] = arg = argSpace;
> 	while ((*p == ' ') || (*p == '\t')) {
> 	    p++;
> 	}
> 	if (*p == '\0') {
> 	    break;
> 	}
> 
> 	inquote = 0;
> 	slashes = 0;
> 	while (1) {
> 	    copy = 1;
> 	    while (*p == '\\') {
> 		slashes++;
> 		p++;
> 	    }
> 	    if (*p == '"') {
> 		if ((slashes & 1) == 0) {
> 		    copy = 0;
> 		    if ((inquote) && (p[1] == '"')) {
> 			p++;
> 			copy = 1;
> 		    } else {
> 			inquote = !inquote;
> 		    }
>                 }
>                 slashes >>= 1;
>             }
> 
>             while (slashes) {
> 		*arg = '\\';
> 		arg++;
> 		slashes--;
> 	    }
> 
> 	    if ((*p == '\0')
> 		    || (!inquote && ((*p == ' ') || (*p == '\t')))) {
> 		break;
> 	    }
> 	    if (copy != 0) {
> 		*arg = *p;
> 		arg++;
> 	    }
> 	    p++;
>         }
> 	*arg = '\0';
> 	argSpace = arg + 1;
>     }
>     argv[argc] = NULL;
> 
>     *argcPtr = argc;
>     *argvPtr = argv;
> }
> 
> /* The default (human) player is the current user on the current
display. */
> 
> Player *
> add_default_player(void)
> {
>     Player *player = add_player();
>     
>     player->name = getenv("USER");
>     player->configname = getenv("XCONQCONFIG");
>     player->displayname = "WinTCL";
>     return player;
> }
> 
> void
> make_default_player_spec(void)
> {
>   default_player_spec = "WinTCL";
> }
> 
> /* Dummy versions of functions not emulated by Windows tk. */
> int XSetTile(Display *dpy, GC gc, Pixmap pm) {}
> int XFlush(Display *dpy) {}
> 
> /* Probably wrong, but makes cygwin b20 linking happy. */
> int (*XSynchronize(Display *dpy, Bool b))(Display *dpy) { return NULL;
}
> 
> 
************************************************************************
************

Sorry about tkwin32.c but the line format had to change for me to edit
it.

T-Surf is pleased to announce its name change to Earth Decision Sciences
http://www.earthdecision.com/Events/NameChange.html
 
Stanley M. Sutton                sutton@earthdecision.com
AIM:          StanleyMSutton     Ext: 113
MSNMessenger: sutton@t-surf.com  Yahoo: stanley_sutton
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]