]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - win/configure.cpp
Header update: 2007 -> 2008
[user/henk/code/inspircd.git] / win / configure.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #define _CRT_SECURE_NO_DEPRECATE
15
16 #define WIN32_LEAN_AND_MEAN
17 #include <windows.h>
18 #include <stdio.h>
19 #include <string>
20 #include <time.h>
21 #include "inspircd_win32wrapper.h"
22 #include "colours.h"
23
24 using namespace std;
25 void Run();
26 void Banner();
27 void WriteCompileModules();
28 void WriteCompileCommands();
29
30 /* detects if we are running windows xp or higher (5.1) */
31 bool iswinxp()
32 {
33         OSVERSIONINFO vi;
34         vi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
35         GetVersionEx(&vi);
36         if(vi.dwMajorVersion >= 5)
37                 return true;
38         
39         return false;
40 }
41
42 int get_int_option(const char * text, int def)
43 {
44         static char buffer[500];
45         int ret;
46         printf_c("%s\n[\033[1;32m%u\033[0m] -> ", text, def);
47         fgets(buffer, 500, stdin);
48         if(sscanf(buffer, "%u", &ret) != 1)
49                 ret = def;
50
51         printf("\n");
52         return ret;
53 }
54
55 bool get_bool_option(const char * text, bool def)
56 {
57         static char buffer[500];
58         char ret[100];
59         printf_c("%s [\033[1;32m%c\033[0m] -> ", text, def ? 'y' : 'n');
60         fgets(buffer, 500, stdin);
61         if(sscanf(buffer, "%s", ret) != 1)
62                 strcpy(ret, def ? "y" : "n");
63
64         printf("\n");
65         return !strncmp(ret, "y", 1);
66 }
67
68 void get_string_option(const char * text, char * def, char * buf)
69 {
70         static char buffer[500];
71         printf_c("%s\n[\033[1;32m%s\033[0m] -> ", text, def);
72         fgets(buffer, 500, stdin);
73         if(sscanf(buffer, "%s", buf) != 1)
74                 strcpy(buf, def);
75
76         printf("\n");
77 }
78
79 // escapes a string for use in a c++ file
80 bool escape_string(char * str, size_t size)
81 {
82         size_t len = strlen(str);
83         char * d_str = (char*)malloc(len * 2);
84     
85         size_t i = 0;
86         size_t j = 0;
87
88         for(; i < len; ++i)
89         {
90                 if(str[i] == '\\')
91                 {
92                         d_str[j++] = '\\';
93                         d_str[j++] = '\\';
94                 }
95                 else
96                 {
97                         d_str[j++] = str[i];
98                 }
99         }
100
101         d_str[j++] = 0;
102
103     if(j > size)
104         {
105                 free(d_str);
106                 return false;
107         }
108
109         strcpy(str, d_str);
110         free(d_str);
111         return true;
112 }
113
114 /* gets the svn revision */
115 int get_svn_revision(char * buffer, size_t len)
116 {
117         /* again.. I am lazy :p cbf to pipe output of svn info to us, so i'll just read the file */
118         /*
119         8
120
121         dir
122         7033
123         */
124         char buf[1000];
125         FILE * f = fopen("..\\.svn\\entries", "r");
126         if(!f) goto bad_rev;
127     
128         if(!fgets(buf, 1000, f)) goto bad_rev;
129         if(!fgets(buf, 1000, f)) goto bad_rev;
130         if(!fgets(buf, 1000, f)) goto bad_rev;
131         if(!fgets(buf, 1000, f)) goto bad_rev;
132         int rev = atoi(buf);
133         if(rev == 0) goto bad_rev;
134         sprintf(buffer, "%u", rev);
135         fclose(f);
136         return rev;
137         
138 bad_rev:
139         strcpy(buffer, "non-svn");
140         if(f) fclose(f);
141         return 0;
142 }
143
144 int __stdcall WinMain(IN HINSTANCE hInstance, IN HINSTANCE hPrevInstance, IN LPSTR lpCmdLine, IN int nShowCmd )
145 {
146         FILE * j = fopen("inspircd_config.h", "r");
147         if (j)
148         {
149                 if (MessageBox(0, "inspircd_config.h already exists. Remove it and build from clean?", "Configure program", MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2) != IDYES)
150                 {
151                         fclose(j);
152                         exit(0);
153                 }
154         }
155
156         AllocConsole();
157
158         // pipe standard handles to this console
159         freopen("CONIN$", "r", stdin);
160         freopen("CONOUT$", "w", stdout);
161         freopen("CONOUT$", "w", stderr);
162
163         Banner();
164         Run();
165         WriteCompileCommands();
166         WriteCompileModules();
167         FreeConsole();
168         return 0;
169 }
170
171 void Banner()
172 {
173         printf_c("\nWelcome to the \033[1mInspIRCd\033[0m Configuration program! (\033[1minteractive mode\033[0m)\n"
174                          "\033[1mPackage maintainers: Type ./configure --help for non-interactive help\033[0m\n\n");
175         printf_c("*** If you are unsure of any of these values, leave it blank for    ***\n"
176                          "*** standard settings that will work, and your server will run      ***\n"
177                          "*** using them. Please consult your IRC network admin if in doubt.  ***\n\n"
178                          "Press \033[1m<RETURN>\033[0m to accept the default for any option, or enter\n"
179                          "a new value. Please note: You will \033[1mHAVE\033[0m to read the docs\n"
180                          "dir, otherwise you won't have a config file!\n\n");
181
182 }
183
184 void Run()
185 {
186         int max_fd = 1024;
187         bool use_iocp = false;
188         bool support_ip6links = false;
189         char mod_path[MAX_PATH];
190         char config_file[MAX_PATH];
191         char library_dir[MAX_PATH];
192         char base_path[MAX_PATH];
193         char bin_dir[MAX_PATH];
194         char revision_text[MAX_PATH];
195
196         int max_clients = 1024;
197         int nicklen = 31;
198         int chanlen = 64;
199         int modechanges = 20;
200         int identlen = 12;
201         int quitlen = 255;
202         int topiclen = 500;
203         int kicklen = 255;
204         int rllen = 128;
205         int awaylen = 200;
206         int revision = get_svn_revision(revision_text, MAX_PATH);
207         char version[514];
208
209         // grab version
210         FILE * fI = fopen("..\\src\\version.sh", "r");
211         if(fI)
212         {
213                 fgets(version, 514, fI);
214                 fgets(version, 514, fI);
215                 char * p2 = version;
216                 while(*p2 != '\"')
217                         ++p2;
218                 ++p2;
219                 strcpy(version, p2);
220                 p2 = version;
221                 while(*p2 != '\"')
222                         ++p2;
223                 *p2 = 0;
224                 fclose(fI);
225         }
226         else
227                 strcpy(version, "InspIRCD-Unknown");
228 #ifdef WIN64
229         printf_c("Your operating system is: \033[1;32mwindows_x64 \033[0m\n");
230 #else
231         printf_c("Your operating system is: \033[1;32mwindows_x32 \033[0m\n");
232 #endif
233         printf_c("InspIRCd revision ID: \033[1;32m%s \033[0m\n\n", revision ? revision_text : "(Non-SVN build)");
234
235         max_fd = get_int_option("What is the maximum file descriptor count you would like to allow?", 1024);
236
237         // detect windows
238         if(iswinxp())
239         {
240                 printf_c("You are running Windows 2000 or above, and IOCP support is most likely available.\n"
241                              "This removes the socket number limitation of select and is much more efficent.\n"
242                                  "If you are unsure, answer yes.\n\n");
243
244                 use_iocp = get_bool_option("Do you want to use the IOCP implementation?", true);
245         }
246
247         support_ip6links = get_bool_option("\nYou have chosen to build an \033[1;32mIPV4-only\033[0m server.\nWould you like to enable support for linking to IPV6-enabled InspIRCd servers?\nIf you are using a recent operating system and are unsure, answer yes.\nIf you answer 'no' here, your InspIRCd server will be unable\nto parse IPV6 addresses (e.g. for CIDR bans)", 
248                 true);
249         
250         printf_c("\033[1mAll paths are relative to the binary directory.\033[0m\n");
251         get_string_option("In what directory do you wish to install the InspIRCd base?", "..", base_path);
252         get_string_option("In what directory are the configuration files?", "../conf", config_file);
253         get_string_option("In what directory are the modules to be compiled to?", "../modules", mod_path);
254         get_string_option("In what directory is the IRCd binary to be placed?", ".", bin_dir);
255         get_string_option("In what directory are the IRCd libraries to be placed?", "../lib", library_dir);
256
257         printf_c("The following questions will ask you for various figures relating\n"
258                 "To your IRCd install. Please note that these should usually be left\n"
259                 "as defaults unless you have a real reason to change them. If they\n"
260                 "changed, then the values must be identical on all servers on your\n"
261                 "network, or malfunctions and/or crashes may occur, with the exception\n"
262                 "of the 'maximum number of clients' setting which may be different on\n"
263                 "different servers on the network.\n\n");
264
265     
266         max_clients = get_int_option("Please enter the maximum number of clients at any one time?", 1024);
267         nicklen = get_int_option("Please enter the maximum length of nicknames?", 31);
268         chanlen = get_int_option("Please enter the maximum length of channel names?", 64);
269         modechanges = get_int_option("Please enter the maximum number of mode changes in one line?", 20);
270         identlen = get_int_option("Please enter the maximum length of an ident (username)?", 12);
271         quitlen = get_int_option("Please enter the maximum length of a quit message?", 255);
272         topiclen = get_int_option("Please enter the maximum length of a channel topic?", 307);
273         kicklen = get_int_option("Please enter the maximum length of a kick message?", 255);
274         rllen = get_int_option("Please enter the maximum length of a GECOS (real name)?", 128);
275         awaylen = get_int_option("Please enter the maximum length of an away message?", 200);
276
277         printf_c("\n\033[1;32mPre-build configuration is complete!\n\n");       sc(TNORMAL);
278
279         // dump all the options back out
280         printf_c("\033[0mBase install path:\033[1;32m        %s\n", base_path);
281         printf_c("\033[0mConfig path:\033[1;32m              %s\n", config_file);
282         printf_c("\033[0mModule path:\033[1;32m              %s\n", mod_path);
283         printf_c("\033[0mLibrary path:\033[1;32m             %s\n", library_dir);
284         printf_c("\033[0mSocket Engine:\033[1;32m            %s\n", use_iocp ? "iocp" : "select");
285         printf_c("\033[0mMax file descriptors:\033[1;32m     %u\n", max_fd);
286         printf_c("\033[0mMax connections:\033[1;32m          %u\n", max_clients);
287         printf_c("\033[0mMax nickname length:\033[1;32m      %u\n", nicklen);
288         printf_c("\033[0mMax channel length:\033[1;32m       %u\n", chanlen);
289         printf_c("\033[0mMax mode length:\033[1;32m          %u\n", modechanges);
290         printf_c("\033[0mMax ident length:\033[1;32m         %u\n", identlen);
291         printf_c("\033[0mMax quit length:\033[1;32m          %u\n", quitlen);
292         printf_c("\033[0mMax topic length:\033[1;32m         %u\n", topiclen);
293         printf_c("\033[0mMax kick length:\033[1;32m          %u\n", kicklen);
294         printf_c("\033[0mMax name length:\033[1;32m          %u\n", rllen);
295         printf_c("\033[0mMax away length:\033[1;32m          %u\n", awaylen);
296         printf("\n"); sc(TNORMAL);
297         if(get_bool_option("Are these settings correct?", true) == false)
298         {
299                 Run();
300                 return;
301         }
302         printf("\n");
303
304         // escape the pathes
305         escape_string(config_file, MAX_PATH);
306         escape_string(mod_path, MAX_PATH);
307         escape_string(library_dir, MAX_PATH);
308
309         printf("\nWriting inspircd_config.h...");
310         FILE * f = fopen("inspircd_config.h", "w");
311         fprintf(f, "/* Auto generated by configure, do not modify! */\n");
312         fprintf(f, "#ifndef __CONFIGURATION_AUTO__\n");
313         fprintf(f, "#define __CONFIGURATION_AUTO__\n\n");
314         if(use_iocp)
315                 fprintf(f, "#define CONFIG_USE_IOCP 1\n\n");
316
317         fprintf(f, "#define CONFIG_FILE \"%s/inspircd.conf\"\n", config_file);
318         fprintf(f, "#define MOD_PATH \"%s\"\n", mod_path);
319         fprintf(f, "#define MAX_DESCRIPTORS %u\n", max_fd);
320         fprintf(f, "#define MAXCLIENTS %u\n", max_clients);
321         fprintf(f, "#define MAXCLIENTS_S \"%u\"\n", max_clients);
322         fprintf(f, "#define SOMAXCONN_S \"128\"\n");
323         fprintf(f, "#define NICKMAX %u\n", nicklen+1);
324         fprintf(f, "#define CHANMAX %u\n", chanlen+1);
325         fprintf(f, "#define MAXMODES %u\n", modechanges);
326         fprintf(f, "#define IDENTMAX %u\n", identlen);
327         fprintf(f, "#define MAXQUIT %u\n", quitlen);
328         fprintf(f, "#define MAXTOPIC %u\n", topiclen);
329         fprintf(f, "#define MAXKICK %u\n", kicklen);
330         fprintf(f, "#define MAXGECOS %u\n", rllen);
331         fprintf(f, "#define MAXAWAY %u\n", awaylen);
332         fprintf(f, "#define LIBRARYDIR \"%s\"\n", library_dir);
333         fprintf(f, "#define VERSION \"%s\"\n", version);
334         fprintf(f, "#define REVISION \"%s\"\n", revision_text);
335         if(support_ip6links)
336                 fprintf(f, "#define SUPPORT_IP6LINKS 1\n");
337
338         OSVERSIONINFO vi;
339         vi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
340         GetVersionEx(&vi);
341 #ifdef WIN64
342         fprintf(f, "#define SYSTEM \"Windows_x64 %u.%u.%u %s\"\n", vi.dwMajorVersion, vi.dwMinorVersion, vi.dwBuildNumber, vi.szCSDVersion);
343 #else
344         fprintf(f, "#define SYSTEM \"Windows_x32 %u.%u.%u %s\"\n", vi.dwMajorVersion, vi.dwMinorVersion, vi.dwBuildNumber, vi.szCSDVersion);
345 #endif
346         fprintf(f, "#define MAXBUF 514\n");
347
348         fprintf(f, "\n#include \"inspircd_win32wrapper.h\"\n\n");
349         fprintf(f, "#endif\n\n");
350         fclose(f);
351
352         sc(TGREEN); printf(" done\n"); sc(TNORMAL);
353         printf("Writing inspircd_se_config.h...");
354
355         f = fopen("inspircd_se_config.h", "w");
356         fprintf(f, "/* Auto generated by configure, do not modify or commit to svn! */\n");
357         fprintf(f, "#ifndef __CONFIGURATION_SOCKETENGINE__\n");
358         fprintf(f, "#define __CONFIGURATION_SOCKETENGINE__\n\n");
359         fprintf(f, "#include \"socketengines/socketengine_%s.h\"\n\n", use_iocp ? "iocp" : "select");
360         fprintf(f, "#endif\n\n");
361         fclose(f);
362
363         sc(TGREEN); printf(" done\n"); sc(TNORMAL);
364         printf("Writing command and module compilation scripts...");
365         WriteCompileCommands();
366         WriteCompileModules();
367         sc(TGREEN); printf(" done\n"); sc(TNORMAL);
368
369         printf("\nconfigure is done.. exiting!\n");
370 }
371
372 void WriteCompileCommands()
373 {
374         char commands[300][100];
375         int command_count = 0;
376         printf("\n  Finding Command Sources...\n");
377         WIN32_FIND_DATA fd;
378         HANDLE fh = FindFirstFile("..\\src\\commands\\cmd_*.cpp", &fd);
379         if(fh == INVALID_HANDLE_VALUE)
380                 printf_c("\033[1;32m  No command sources could be found! This \033[1m*could*\033[1;32m be a bad thing.. :P\033[0m");
381         else
382         {
383                 sc(TGREEN);
384                 do 
385                 {
386                         strcpy(commands[command_count], fd.cFileName);
387                         commands[command_count][strlen(fd.cFileName) - 4] = 0;
388                         printf("    %s\n", commands[command_count]);
389                         ++command_count;
390                 } while(FindNextFile(fh, &fd));
391                 sc(TNORMAL);
392         }
393     
394         // Write our spiffy new makefile :D
395         // I am such a lazy fucker :P
396         FILE * f = fopen("..\\src\\commands\\commands.mak", "w");
397
398         time_t t = time(NULL);
399         fprintf(f, "# Generated at %s\n", ctime(&t));
400         fprintf(f, "all: makedir ");
401
402         // dump modules.. first time :)
403         for(int i = 0; i < command_count; ++i)
404                 fprintf(f, "%s.so ", commands[i]);
405
406         fprintf(f, "\n.cpp.obj:\n");
407 #ifdef WIN64
408         // /MACHINE:X64
409         #ifdef _DEBUG
410                 fprintf(f, "  cl /nologo /LD /Od /I \".\" /I \"../../include\" /I \"../../include/modes\" /I \"../../include/commands\" /I \"../../win\" /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /D \"DLL_BUILD\" /Gm /EHsc /Gm /RTC1 /MTd /Fo\"Debug/\" /Fd\"Debug/vc70.pdb\" /W2 /Wp64 /Zi /TP $*.cpp ..\\..\\win\\inspircd_memory_functions.cpp /link ..\\..\\bin\\debug_x64\\bin\\inspircd.lib /OUT:\"..\\..\\bin\\debug_x64\\lib\\$*.so\" /PDB:\"..\\..\\bin\\debug_x64\\lib\\$*.pdb\" /MACHINE:X64 /IMPLIB:\"..\\..\\bin\\debug_x64\\lib\\$*.lib\"\n\n");
411                 CreateDirectory("..\\src\\debug", NULL);
412                 CreateDirectory("..\\bin\\debug\\bin", NULL);
413                 CreateDirectory("..\\bin\\debug\\lib", NULL);
414                 CreateDirectory("..\\bin\\debug\\modules", NULL);
415         #else
416                 fprintf(f, "  cl /nologo /LD /Od /I \".\" /I \"../../include\" /I \"../../include/modes\" /I \"../../include/commands\" /I \"../../win\" /D \"WIN32\" /D \"_CONSOLE\" /D \"_MBCS\" /D \"DLL_BUILD\" /EHsc /Gm /MT /Fo\"Release/\" /Fd\"Release/vc70.pdb\" /W2 /Wp64 /Zi /TP $*.cpp ..\\..\\win\\inspircd_memory_functions.cpp /link ..\\..\\bin\\release_x64\\bin\\inspircd.lib /OUT:\"..\\..\\bin\\release_x64\\lib\\$*.so\" /PDB:\"..\\..\\bin\\release_x64\\lib\\$*.pdb\" /MACHINE:X64 /IMPLIB:\"..\\..\\bin\\release_x64\\lib\\$*.lib\"\n\n");
417                 CreateDirectory("..\\src\\release", NULL);
418                 CreateDirectory("..\\bin\\release\\bin", NULL);
419                 CreateDirectory("..\\bin\\release\\lib", NULL);
420                 CreateDirectory("..\\bin\\release\\modules", NULL);
421         #endif
422 #else
423         #ifdef _DEBUG
424                 fprintf(f, "  cl /nologo /LD /Od /I \".\" /I \"../../include\" /I \"../../include/modes\" /I \"../../include/commands\" /I \"../../win\" /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /D \"DLL_BUILD\" /Gm /EHsc /Gm /RTC1 /MTd /Fo\"Debug/\" /Fd\"Debug/vc70.pdb\" /W2 /Wp64 /Zi /TP $*.cpp ..\\..\\win\\inspircd_memory_functions.cpp /link ..\\..\\bin\\debug\\bin\\inspircd.lib /OUT:\"..\\..\\bin\\debug\\lib\\$*.so\" /PDB:\"..\\..\\bin\\debug\\lib\\$*.pdb\" /IMPLIB:\"..\\..\\bin\\debug\\lib\\$*.lib\"\n\n");
425                 CreateDirectory("..\\src\\debug", NULL);
426                 CreateDirectory("..\\bin\\debug\\bin", NULL);
427                 CreateDirectory("..\\bin\\debug\\lib", NULL);
428                 CreateDirectory("..\\bin\\debug\\modules", NULL);
429         #else
430                 fprintf(f, "  cl /nologo /LD /Od /I \".\" /I \"../../include\" /I \"../../include/modes\" /I \"../../include/commands\" /I \"../../win\" /D \"WIN32\" /D \"_CONSOLE\" /D \"_MBCS\" /D \"DLL_BUILD\" /EHsc /Gm /MT /Fo\"Release/\" /Fd\"Release/vc70.pdb\" /W2 /Wp64 /Zi /TP $*.cpp ..\\..\\win\\inspircd_memory_functions.cpp /link ..\\..\\bin\\release\\bin\\inspircd.lib /OUT:\"..\\..\\bin\\release\\lib\\$*.so\" /PDB:\"..\\..\\bin\\release\\lib\\$*.pdb\" /IMPLIB:\"..\\..\\bin\\release\\lib\\$*.lib\"\n\n");
431                 CreateDirectory("..\\src\\release", NULL);
432                 CreateDirectory("..\\bin\\release\\bin", NULL);
433                 CreateDirectory("..\\bin\\release\\lib", NULL);
434                 CreateDirectory("..\\bin\\release\\modules", NULL);
435         #endif
436 #endif
437
438         fprintf(f, "makedir:\n  if not exist debug mkdir debug\n  if not exist release mkdir release\n\n");
439         
440         // dump modules.. again the second and last time :)
441         for(int i = 0; i < command_count; ++i)
442                 fprintf(f, "%s.so : %s.obj\n", commands[i], commands[i]);
443
444         fprintf(f, "\n");
445         fclose(f);
446 }
447
448 void WriteCompileModules()
449 {
450         char modules[300][100];
451         int module_count = 0;
452
453         printf("Finding Modules...\n");
454         WIN32_FIND_DATA fd;
455         HANDLE fh = FindFirstFile("..\\src\\modules\\m_*.cpp", &fd);
456         if(fh == INVALID_HANDLE_VALUE)
457                 printf_c("\033[1;32m  No module sources could be found! This \033[1m*could*\033[1;32m be a bad thing.. :P\033[0m");
458         else
459         {
460                 sc(TGREEN);
461                 do 
462                 {
463                         strcpy(modules[module_count], fd.cFileName);
464                         modules[module_count][strlen(fd.cFileName) - 4] = 0;
465                         printf("  %s\n", modules[module_count]);
466                         ++module_count;
467                 } while(FindNextFile(fh, &fd));
468                 sc(TNORMAL);
469         }
470
471         // Write our spiffy new makefile :D
472         // I am such a lazy fucker :P
473         FILE * f = fopen("..\\src\\modules\\modules.mak", "w");
474
475         time_t t = time(NULL);
476         fprintf(f, "# Generated at %s\n", ctime(&t));
477         fprintf(f, "all: makedir ");
478
479         // dump modules.. first time :)
480         for(int i = 0; i < module_count; ++i)
481                 fprintf(f, "%s.so ", modules[i]);
482
483         fprintf(f, "\n.cpp.obj:\n");
484 #ifdef WIN64
485         // /MACHINE:X64
486         #ifdef _DEBUG
487                 fprintf(f, "  cl /nologo /LD /Od /I \".\" /I \"../../include\" /I \"../../include/modes\" /I \"../../include/modules\" /I \"../../win\" /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /D \"DLL_BUILD\" /Gm /EHsc /Gm /RTC1 /MTd /Fo\"Debug/\" /Fd\"Debug/vc70.pdb\" /W2 /Wp64 /Zi /TP $*.cpp ..\\..\\win\\inspircd_memory_functions.cpp /link ..\\..\\bin\\debug_x64\\bin\\inspircd.lib ws2_32.lib /OUT:\"..\\..\\bin\\debug_x64\\modules\\$*.so\" /PDB:\"..\\..\\bin\\debug_x64\\modules\\$*.pdb\" /MACHINE:X64 /IMPLIB:\"..\\..\\bin\\debug_x64\\modules\\$*.lib\"\n\n");
488                 CreateDirectory("..\\src\\modules\\debug_x64", NULL);
489         #else
490                 fprintf(f, "  cl /nologo /LD /Od /I \".\" /I \"../../include\" /I \"../../include/modes\" /I \"../../include/modules\" /I \"../../win\" /D \"WIN32\" /D \"_CONSOLE\" /D \"_MBCS\" /D \"DLL_BUILD\" /EHsc /Gm /MT /Fo\"Release/\" /Fd\"Release/vc70.pdb\" /W2 /Wp64 /Zi /TP $*.cpp ..\\..\\win\\inspircd_memory_functions.cpp /link ..\\..\\bin\\release_x64\\bin\\inspircd.lib ws2_32.lib /OUT:\"..\\..\\bin\\release_x64\\modules\\$*.so\" /PDB:\"..\\..\\bin\\release_x64\\modules\\$*.pdb\" /MACHINE:X64 /IMPLIB:\"..\\..\\bin\\release_x64\\modules\\$*.lib\"\n\n");
491                 CreateDirectory("..\\src\\modules\\release_x64", NULL);
492         #endif
493 #else
494         #ifdef _DEBUG
495                 fprintf(f, "  cl /nologo -Dssize_t=long /LD /Od /I \".\" /I \"../../include\" /I \"../../include/modes\" /I \"../../include/modules\" /I \"../../win\" /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /D \"DLL_BUILD\" /Gm /EHsc /Gm /RTC1 /MTd /Fo\"Debug/\" /Fd\"Debug/vc70.pdb\" /W2 /Wp64 /Zi /TP $*.cpp ..\\..\\win\\inspircd_memory_functions.cpp /link ..\\..\\bin\\debug\\bin\\inspircd.lib ws2_32.lib /OUT:\"..\\..\\bin\\debug\\modules\\$*.so\" /PDB:\"..\\..\\bin\\debug\\modules\\$*.pdb\" /IMPLIB:\"..\\..\\bin\\debug\\modules\\$*.lib\"\n\n");
496                 CreateDirectory("..\\src\\modules\\debug", NULL);
497                 CreateDirectory("..\\src\\modules\\debug\\lib", NULL);
498                 CreateDirectory("..\\src\\modules\\debug\\modules", NULL);
499                 CreateDirectory("..\\src\\modules\\debug\\bin", NULL);
500         #else
501                 fprintf(f, "  cl /nologo -Dssize_t=long /LD /Od /I \".\" /I \"../../include\" /I \"../../include/modes\" /I \"../../include/modules\" /I \"../../win\" /D \"WIN32\" /D \"_CONSOLE\" /D \"_MBCS\" /D \"DLL_BUILD\" /EHsc /Gm /MT /Fo\"Release/\" /Fd\"Release/vc70.pdb\" /W2 /Wp64 /Zi /TP $*.cpp ..\\..\\win\\inspircd_memory_functions.cpp /link ..\\..\\bin\\release\\bin\\inspircd.lib ws2_32.lib /OUT:\"..\\..\\bin\\release\\modules\\$*.so\" /PDB:\"..\\..\\bin\\release\\modules\\$*.pdb\" /IMPLIB:\"..\\..\\bin\\release\\modules\\$*.lib\"\n\n");
502                 CreateDirectory("..\\src\\modules\\release", NULL);
503                 CreateDirectory("..\\src\\modules\\release\\lib", NULL);
504                 CreateDirectory("..\\src\\modules\\release\\modules", NULL);
505                 CreateDirectory("..\\src\\modules\\release\\bin", NULL);
506         #endif
507 #endif
508         
509         fprintf(f, "makedir:\n  if not exist debug mkdir debug\n  if not exist release mkdir release\n\n");
510
511         // dump modules.. again the second and last time :)
512         for(int i = 0; i < module_count; ++i)
513                 fprintf(f, "%s.so : %s.obj\n", modules[i], modules[i]);
514
515         fprintf(f, "\n");
516         fclose(f);
517 }