]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - win/configure.cpp
4acd7131b411a69194a9b965aa4111039e82f454
[user/henk/code/inspircd.git] / win / configure.cpp
1 /*         +------------------------------------+
2  *         | Inspire Internet Relay Chat Daemon |
3  *         +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2011 InspIRCd Development Team
6  * See: http://wiki.inspircd.org/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 CONFIGURE_BUILD
17 #define WIN32_LEAN_AND_MEAN
18 #include <windows.h>
19 #include <stdio.h>
20 #include <process.h>
21 #include <iostream>
22 #include <string>
23 #include <vector>
24 #include <time.h>
25 #include "inspircd_win32wrapper.h"
26 #include "colours.h"
27
28 using namespace std;
29 void Run();
30 void Banner();
31 void WriteCompileModules(const vector<string> &, const vector<string> &);
32 void WriteCompileCommands();
33 void Rebase();
34 void CopyExtras();
35
36 /* detects if we are running windows xp or higher (5.1) */
37 bool iswinxp()
38 {
39         OSVERSIONINFO vi;
40         vi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
41         GetVersionEx(&vi);
42         if(vi.dwMajorVersion >= 5)
43                 return true;
44         
45         return false;
46 }
47
48 int get_int_option(const char * text, int def)
49 {
50         static char buffer[500];
51         int ret;
52         printf_c("%s\n[\033[1;32m%u\033[0m] -> ", text, def);
53         fgets(buffer, 500, stdin);
54         if(sscanf(buffer, "%u", &ret) != 1)
55                 ret = def;
56
57         printf("\n");
58         return ret;
59 }
60
61 bool get_bool_option(const char * text, bool def)
62 {
63         static char buffer[500];
64         char ret[100];
65         printf_c("%s [\033[1;32m%c\033[0m] -> ", text, def ? 'y' : 'n');
66         fgets(buffer, 500, stdin);
67         if(sscanf(buffer, "%s", ret) != 1)
68                 strcpy(ret, def ? "y" : "n");
69
70         printf("\n");
71         return !strncmp(ret, "y", 1);
72 }
73
74 string get_string_option(const char * text, char * def)
75 {
76         if (def && *def)
77                 printf_c("%s\n[\033[1;32m%s\033[0m] -> ", text, def);
78         else
79                 printf_c("%s\n[] -> ", text);
80         
81         char buffer[1000], buf[1000];
82         fgets(buffer, sizeof(buffer), stdin);
83         if (sscanf(buffer, "%s", buf) != 1)
84                 strcpy(buf, def);
85         
86         printf("\n");
87         return buf;
88 }
89
90 // escapes a string for use in a c++ file
91 void escape_string(string &str)
92 {
93         string copy = str;
94         str.clear();
95         
96         for (unsigned i = 0; i < copy.size(); ++i)
97         {
98                 str += copy[i];
99                 if (copy[i] == '\\')
100                         str += '\\';
101         }
102 }
103
104 string get_git_commit()
105 {
106         char buf[128];
107         char *ref = NULL, *commit = NULL;
108         FILE *f = fopen("../.git/HEAD", "r");
109         if (f)
110         {
111                 if (fgets(buf, sizeof(buf), f))
112                 {
113                         while (isspace(buf[strlen(buf) - 1]))
114                                 buf[strlen(buf) - 1] = 0;
115                         char *p = strchr(buf, ' ');
116                         if (p)
117                                 ref = ++p;
118                 }
119                 fclose(f);
120         }
121         if (ref == NULL)
122                 return "";
123         string ref_file = string("../.git/") + string(ref);
124         f = fopen(ref_file.c_str(), "r");
125         if (f)
126         {
127                 if (fgets(buf, sizeof(buf), f))
128                 {
129                         while (isspace(buf[strlen(buf) - 1]))
130                                 buf[strlen(buf) - 1] = 0;
131                         commit = buf;
132                 }
133                 fclose(f);
134         }
135
136         return commit != NULL ? commit : "";
137 }
138
139 void get_machine_info(char * buffer, size_t len)
140 {
141         char buf[500];
142         char buf2[500];
143
144         DWORD dwSize = sizeof(buf);
145         if (!GetComputerNameEx((COMPUTER_NAME_FORMAT)ComputerNameDnsFullyQualified, buf, &dwSize))
146                 sprintf(buf, "%s", "unknown");
147
148         FILE * f = fopen("ver.txt.tmp", "r");
149         if (f)
150         {
151                 while (fgets(buf2, 500, f)) { }
152                 fclose(f);
153                 unlink("ver.txt.tmp");
154         }
155         else
156                 sprintf(buf2, "%s", "unknown");
157
158         sprintf(buffer, "%s ", buf);
159         //strip newlines
160         char* b = buffer + strlen(buf)+1;
161         char *b2 = buf2;
162         while (*b2)
163         {
164                 if (*b2 != 10 && *b2 != 13)
165                 {
166                         *b = *b2;
167                         b++;
168                 }
169                 *b2++;
170         }
171         *b = 0;
172 }
173
174 vector<string> get_dir_list(const string &path_list)
175 {
176         char *paths = strdup(path_list.c_str());
177         char *paths_save = paths;
178         char *p = paths;
179         vector<string> paths_return;
180
181         while ((p = strchr(paths, ';')))
182         {
183                 *p++ = 0;
184                 paths_return.push_back(paths);
185                 paths = p;
186         }
187         if (paths != NULL)
188                 paths_return.push_back(paths);
189         free(paths_save);
190         
191         return paths_return;
192 }
193
194 int __stdcall WinMain(IN HINSTANCE hInstance, IN HINSTANCE hPrevInstance, IN LPSTR lpCmdLine, IN int nShowCmd )
195 {
196         if (!strcmp(lpCmdLine, "/rebase"))
197         {
198                 Rebase();
199                 return 0;
200         }
201
202         FILE * j = fopen("inspircd_config.h", "r");
203         if (j)
204         {
205                 if (MessageBox(0, "inspircd_config.h already exists. Remove it and build from clean?", "Configure program", MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2) != IDYES)
206                 {
207                         fclose(j);
208                         exit(0);
209                 }
210         }
211
212         // call before we hook console handles
213         system("ver > ver.txt.tmp");
214
215         AllocConsole();
216
217         // pipe standard handles to this console
218         freopen("CONIN$", "r", stdin);
219         freopen("CONOUT$", "w", stdout);
220         freopen("CONOUT$", "w", stderr);
221
222         Banner();
223         Run();
224         FreeConsole();
225         return 0;
226 }
227
228 void Banner()
229 {
230         printf_c("\nWelcome to the \033[1mInspIRCd\033[0m Configuration program! (\033[1minteractive mode\033[0m)\n"
231                          "\033[1mPackage maintainers: Type ./configure --help for non-interactive help\033[0m\n\n");
232         printf_c("*** If you are unsure of any of these values, leave it blank for      ***\n"
233                          "*** standard settings that will work, and your server will run          ***\n"
234                          "*** using them. Please consult your IRC network admin if in doubt.  ***\n\n"
235                          "Press \033[1m<RETURN>\033[0m to accept the default for any option, or enter\n"
236                          "a new value. Please note: You will \033[1mHAVE\033[0m to read the docs\n"
237                          "dir, otherwise you won't have a config file!\n\n");
238
239 }
240
241 void Run()
242 {
243         vector<string> extra_include_paths, extra_lib_paths;
244         string revision = get_git_commit();
245         char version[514];
246         char machine_text[MAX_PATH];
247         get_machine_info(machine_text, MAX_PATH);
248
249         // grab version
250         FILE * fI = fopen("..\\src\\version.sh", "r");
251         if(fI)
252         {
253                 fgets(version, 514, fI);
254                 fgets(version, 514, fI);
255                 char * p2 = version;
256                 while(*p2 != '\"')
257                         ++p2;
258                 ++p2;
259                 strcpy(version, p2);
260                 p2 = version;
261                 while(*p2 != '\"')
262                         ++p2;
263                 *p2 = 0;
264                 fclose(fI);
265         }
266         else
267                 strcpy(version, "InspIRCD-Unknown");
268 #ifdef WIN64
269         printf_c("Your operating system is: \033[1;32mwindows_x64 \033[0m\n");
270 #else
271         printf_c("Your operating system is: \033[1;32mwindows_x32 \033[0m\n");
272 #endif
273         printf_c("InspIRCd revision ID: \033[1;32m%s \033[0m\n\n", !revision.empty() ? revision.c_str() : "(Non-GIT build)");
274         
275         printf_c("\033[1mExtra modules.\033[0m\n");
276         if (get_bool_option("Do you want to compile any extra non-core modules?", false))
277         {
278                 string extra_i_path = get_string_option("Extra include search paths separate by \";\"", ".");
279                 string extra_l_path = get_string_option("Extra library search paths, separate by \";\"", ".");
280                 
281                 extra_include_paths = get_dir_list(extra_i_path);
282                 extra_lib_paths = get_dir_list(extra_l_path);
283         }
284
285         printf_c("\033[1mAll paths are relative to the binary directory.\033[0m\n");
286         string base_path = get_string_option("In what directory do you wish to install the InspIRCd base?", "..");
287         string config_file = get_string_option("In what directory are the configuration files?", "conf");
288         string mod_path = get_string_option("In what directory are the modules to be compiled to?", "modules");
289         string bin_dir = get_string_option("In what directory is the IRCd binary to be placed?", ".");
290
291         printf_c("\n\033[1;32mPre-build configuration is complete!\n\n");       sc(TNORMAL);
292
293         CopyExtras();
294
295         // dump all the options back out
296         printf_c("\033[0mBase install path:\033[1;32m        %s\n", base_path.c_str());
297         printf_c("\033[0mConfig path:\033[1;32m              %s\n", config_file.c_str());
298         printf_c("\033[0mModule path:\033[1;32m              %s\n", mod_path.c_str());
299         printf_c("\033[0mSocket Engine:\033[1;32m            %s\n", "select");
300
301         printf("\n"); sc(TNORMAL);
302         if(get_bool_option("Are these settings correct?", true) == false)
303         {
304                 Run();
305                 return;
306         }
307         printf("\n");
308
309         // escape the pathes
310         escape_string(config_file);
311         escape_string(mod_path);
312
313         printf("\nWriting inspircd_config.h...");
314         FILE * f = fopen("inspircd_config.h", "w");
315         fprintf(f, "/* Auto generated by configure, do not modify! */\n");
316         fprintf(f, "#ifndef __CONFIGURATION_AUTO__\n");
317         fprintf(f, "#define __CONFIGURATION_AUTO__\n\n");
318
319         fprintf(f, "#define MOD_PATH \"%s\"\n", mod_path.c_str());
320         fprintf(f, "#define SOMAXCONN_S \"128\"\n");
321         fprintf(f, "#define MAXBUF 514\n");
322
323         fprintf(f, "\n#include \"inspircd_win32wrapper.h\"");
324         fprintf(f, "\n#include \"inspircd_namedpipe.h\"");
325         fprintf(f, "\n#include \"threadengines/threadengine_win32.h\"\n\n");
326         fprintf(f, "#endif\n\n");
327         fclose(f);
328
329         sc(TGREEN); printf(" done\n"); sc(TNORMAL);
330         printf("Writing inspircd_se_config.h...");
331
332         f = fopen("inspircd_se_config.h", "w");
333         fprintf(f, "/* Auto generated by configure, do not modify or commit to svn! */\n");
334         fprintf(f, "#ifndef __CONFIGURATION_SOCKETENGINE__\n");
335         fprintf(f, "#define __CONFIGURATION_SOCKETENGINE__\n\n");
336         fprintf(f, "#include \"socketengines/socketengine_%s.h\"\n\n", "select");
337         fprintf(f, "#endif\n\n");
338         fclose(f);
339
340         sc(TGREEN); printf(" done\n"); sc(TNORMAL);
341         printf("Writing inspircd_version.h...");
342         f = fopen("inspircd_version.h", "w");
343         fprintf(f, "#define VERSION \"%s\"\n", version);
344         fprintf(f, "#define REVISION \"%s\"\n", revision.c_str());
345         fprintf(f, "#define SYSTEM \"%s\"\n", machine_text);
346         fclose(f);
347
348         sc(TGREEN); printf(" done\n"); sc(TNORMAL);
349         printf("Writing command and module compilation scripts...");
350         WriteCompileCommands();
351         WriteCompileModules(extra_include_paths, extra_lib_paths);
352         sc(TGREEN); printf(" done\n"); sc(TNORMAL);
353
354         printf("\nconfigure is done.. exiting!\n");
355 }
356
357 /* Keeps files from modules/extra up to date if theyre copied into modules/ */
358 void CopyExtras()
359 {
360         char dest[65535];
361         char src[65535];
362
363         printf("\nUpdating extra modules in src/modules...\n");
364
365         WIN32_FIND_DATA fd;
366         HANDLE fh = FindFirstFile("..\\src\\modules\\extra\\*.*", &fd);
367
368         if(fh == INVALID_HANDLE_VALUE)
369                 return;
370
371         do
372         {
373                 strcpy(dest, "..\\src\\modules\\");
374                 strcat(dest, fd.cFileName);
375                 strcpy(src, "..\\src\\modules\\extra\\");
376                 strcat(src, fd.cFileName);
377                 FILE* x = fopen(dest, "r");
378                 if (x)
379                 {
380                         fclose(x);
381                         CopyFile(src, dest, false);
382                         sc(TGREEN); printf("    %s", fd.cFileName); sc(TNORMAL);
383                         printf("...\n");
384                 }
385         }
386         while (FindNextFile(fh, &fd));
387
388         FindClose(fh);
389
390         printf("\n\n");
391 }
392
393
394 void Rebase()
395 {
396         char dest[65535];
397         char command[65535];
398
399         WIN32_FIND_DATA fd;
400
401 #ifdef _DEBUG
402         HANDLE fh = FindFirstFile("..\\bin\\debug\\modules\\*.so", &fd);
403 #else
404         HANDLE fh = FindFirstFile("..\\bin\\release\\modules\\*.so", &fd);
405 #endif
406         if(fh == INVALID_HANDLE_VALUE)
407                 return;
408
409         *dest = 0;
410
411         do
412         {
413 #ifdef _DEBUG
414                 strcat(dest, " ..\\bin\\debug\\modules\\");
415 #else
416                 strcat(dest, " ..\\bin\\release\\modules\\");
417 #endif
418                 strcat(dest, fd.cFileName);
419         }
420         while (FindNextFile(fh, &fd));
421
422         sprintf(command, "rebase.exe -v -b 11000000 -c baseaddr_modules.txt %s", dest);
423         printf("%s\n", command);
424         system(command);
425
426         FindClose(fh);
427 }
428
429 void WriteCompileCommands()
430 {
431         char commands[300][100];
432         int command_count = 0;
433         printf("\n  Finding Command Sources...\n");
434         WIN32_FIND_DATA fd;
435         HANDLE fh = FindFirstFile("..\\src\\commands\\cmd_*.cpp", &fd);
436         if(fh == INVALID_HANDLE_VALUE)
437                 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");
438         else
439         {
440                 sc(TGREEN);
441                 do 
442                 {
443                         strcpy(commands[command_count], fd.cFileName);
444                         commands[command_count][strlen(fd.cFileName) - 4] = 0;
445                         printf("        %s\n", commands[command_count]);
446                         ++command_count;
447                 } while(FindNextFile(fh, &fd));
448                 sc(TNORMAL);
449         }
450         
451         // Write our spiffy new makefile :D
452         // I am such a lazy fucker :P
453         FILE * f = fopen("..\\src\\commands\\commands.mak", "w");
454
455         time_t t = time(NULL);
456         fprintf(f, "# Generated at %s\n", ctime(&t));
457         fprintf(f, "all: makedir ");
458
459         // dump modules.. first time :)
460         for(int i = 0; i < command_count; ++i)
461                 fprintf(f, "%s.so ", commands[i]);
462
463         fprintf(f, "\n.cpp.obj:\n");
464 #ifdef WIN64
465         // /MACHINE:X64
466         #ifdef _DEBUG
467                 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 /RTC1 /MDd /Fo\"Debug/\" /Fd\"Debug/vc90.pdb\" /W2 /Zi /TP $*.cpp ..\\..\\win\\inspircd_memory_functions.cpp /link ..\\..\\bin\\debug_x64\\inspircd.lib /OUT:\"..\\..\\bin\\debug_x64\\modules\\$*.so\" /PDB:\"..\\..\\bin\\debug_x64\\modules\\$*.pdb\" /MACHINE:X64 /IMPLIB:\"..\\..\\bin\\debug_x64\\modules\\$*.lib\"\n\n");
468                 CreateDirectory("..\\src\\commands\\debug", NULL);
469                 CreateDirectory("..\\bin\\debug\\modules", NULL);
470         #else
471                 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\" /Gm /EHsc /GL /MD /Fo\"Release/\" /Fd\"Release/vc90.pdb\" /W2 /Zi /TP $*.cpp ..\\..\\win\\inspircd_memory_functions.cpp /link ..\\..\\bin\\release_x64\\inspircd.lib /OUT:\"..\\..\\bin\\release_x64\\modules\\$*.so\" /PDB:\"..\\..\\bin\\release_x64\\modules\\$*.pdb\" /MACHINE:X64 /IMPLIB:\"..\\..\\bin\\release_x64\\modules\\$*.lib\"\n\n");
472                 CreateDirectory("..\\src\\commands\\release", NULL);
473                 CreateDirectory("..\\bin\\release\\modules", NULL);
474         #endif
475 #else
476         #ifdef _DEBUG
477                 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 /RTC1 /MDd /Fo\"Debug/\" /Fd\"Debug/vc90.pdb\" /W2 /Zi /TP $*.cpp ..\\..\\win\\inspircd_memory_functions.cpp /link ..\\..\\bin\\debug\\inspircd.lib /OUT:\"..\\..\\bin\\debug\\modules\\$*.so\" /PDB:\"..\\..\\bin\\debug\\modules\\$*.pdb\" /IMPLIB:\"..\\..\\bin\\debug\\modules\\$*.lib\"\n\n");
478                 CreateDirectory("..\\src\\commands\\debug", NULL);
479                 CreateDirectory("..\\bin\\debug\\modules", NULL);
480         #else
481                 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\" /Gm /EHsc /GL /MD /Fo\"Release/\" /Fd\"Release/vc90.pdb\" /W2 /Zi /TP $*.cpp ..\\..\\win\\inspircd_memory_functions.cpp /link ..\\..\\bin\\release\\inspircd.lib /OUT:\"..\\..\\bin\\release\\modules\\$*.so\" /PDB:\"..\\..\\bin\\release\\modules\\$*.pdb\" /IMPLIB:\"..\\..\\bin\\release\\modules\\$*.lib\"\n\n");
482                 CreateDirectory("..\\src\\commands\\release", NULL);
483                 CreateDirectory("..\\bin\\release\\modules", NULL);
484         #endif
485 #endif
486
487         fprintf(f, "makedir:\n");
488 #ifdef _DEBUG
489         fprintf(f, "    if not exist ..\\..\\bin\\debug mkdir ..\\..\\bin\\debug\n");
490         fprintf(f, "    if not exist ..\\..\\bin\\debug\\modules mkdir ..\\..\\bin\\debug\\modules\n");
491         fprintf(f, "    if not exist ..\\..\\bin\\debug\\data mkdir ..\\..\\bin\\debug\\data\n");
492         fprintf(f, "    if not exist ..\\..\\bin\\debug\\logs mkdir ..\\..\\bin\\debug\\logs\n");
493 #else
494         fprintf(f, "    if not exist ..\\..\\bin\\release mkdir ..\\..\\bin\\release\n");
495         fprintf(f, "    if not exist ..\\..\\bin\\release\\modules mkdir ..\\..\\bin\\release\\modules\n");
496         fprintf(f, "    if not exist ..\\..\\bin\\release\\data mkdir ..\\..\\bin\\release\\data\n");
497         fprintf(f, "    if not exist ..\\..\\bin\\release\\logs mkdir ..\\..\\bin\\release\\logs\n");
498 #endif
499         
500         // dump modules.. again the second and last time :)
501         for(int i = 0; i < command_count; ++i)
502                 fprintf(f, "%s.so : %s.obj\n", commands[i], commands[i]);
503
504         fprintf(f, "\n");
505         fclose(f);
506 }
507
508 void WriteCompileModules(const vector<string> &includes, const vector<string> &libs)
509 {
510         char modules[300][100];
511         int module_count = 0;
512
513         printf("Finding Modules...\n");
514         WIN32_FIND_DATA fd;
515         HANDLE fh = FindFirstFile("..\\src\\modules\\m_*.cpp", &fd);
516         if(fh == INVALID_HANDLE_VALUE)
517                 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");
518         else
519         {
520                 sc(TGREEN);
521                 do 
522                 {
523                         strcpy(modules[module_count], fd.cFileName);
524                         modules[module_count][strlen(fd.cFileName) - 4] = 0;
525                         printf("  %s\n", modules[module_count]);
526                         ++module_count;
527                 } while(FindNextFile(fh, &fd));
528                 sc(TNORMAL);
529         }
530         
531         string extra_include, extra_lib;
532         for (unsigned i = 0; i < includes.size(); ++i)
533                 extra_include += " /I \"" + includes[i] + "\" ";
534         for (unsigned i = 0; i < libs.size(); ++i)
535                 extra_lib += " /LIBPATH:\"" + libs[i] + "\" ";
536
537         // Write our spiffy new makefile :D
538         // I am such a lazy fucker :P
539         FILE * f = fopen("..\\src\\modules\\modules.mak", "w");
540
541         time_t t = time(NULL);
542         fprintf(f, "# Generated at %s\n", ctime(&t));
543         fprintf(f, "all: makedir ");
544
545         // dump modules.. first time :)
546         for(int i = 0; i < module_count; ++i)
547                 fprintf(f, "%s.so ", modules[i]);
548
549         fprintf(f, "\n.cpp.obj:\n");
550 #ifdef WIN64
551         // /MACHINE:X64
552         #ifdef _DEBUG
553                 fprintf(f, "  cl /nologo /LD /Od /I \".\" /I \"../../include\" /I \"../../include/modes\" /I \"../../include/modules\" /I \"../../win\" %s /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /D \"DLL_BUILD\" /Gm /EHsc /RTC1 /MDd /Fo\"Debug/\" /Fd\"Debug/vc90.pdb\" /W2 /Zi /TP $*.cpp ..\\..\\win\\inspircd_memory_functions.cpp /link %s ..\\..\\bin\\debug_x64\\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", extra_include.c_str(), extra_lib.c_str());
554                 CreateDirectory("..\\src\\modules\\debug_x64", NULL);
555         #else
556                 fprintf(f, "  cl /nologo /LD /Od /I \".\" /I \"../../include\" /I \"../../include/modes\" /I \"../../include/modules\" /I \"../../win\" %s /D \"WIN32\" /D \"_CONSOLE\" /D \"_MBCS\" /D \"DLL_BUILD\" /Gm /EHsc /GL /MD /Fo\"Release/\" /Fd\"Release/vc90.pdb\" /W2 /Zi /TP $*.cpp ..\\..\\win\\inspircd_memory_functions.cpp /link %s ..\\..\\bin\\release_x64\\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", extra_include.c_str(), extra_lib.c_str());
557                 CreateDirectory("..\\src\\modules\\release_x64", NULL);
558         #endif
559 #else
560         #ifdef _DEBUG
561                 fprintf(f, "  cl /nologo /LD /Od /I \".\" /I \"../../include\" /I \"../../include/modes\" /I \"../../include/modules\" /I \"../../win\" %s /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /D \"DLL_BUILD\" /Gm /EHsc /RTC1 /MDd /Fo\"Debug/\" /Fd\"Debug/vc90.pdb\" /W2 /Zi /TP $*.cpp ..\\..\\win\\inspircd_memory_functions.cpp /link %s ..\\..\\bin\\debug\\inspircd.lib ws2_32.lib /OUT:\"..\\..\\bin\\debug\\modules\\$*.so\" /PDB:\"..\\..\\bin\\debug\\modules\\$*.pdb\" /IMPLIB:\"..\\..\\bin\\debug\\modules\\$*.lib\"\n\n", extra_include.c_str(), extra_lib.c_str());
562                 CreateDirectory("..\\src\\modules\\debug", NULL);
563         #else
564                 fprintf(f, "  cl /nologo /LD /Od /I \".\" /I \"../../include\" /I \"../../include/modes\" /I \"../../include/modules\" /I \"../../win\" %s /D \"WIN32\" /D \"_CONSOLE\" /D \"_MBCS\" /D \"DLL_BUILD\" /Gm /EHsc /GL /MD /Fo\"Release/\" /Fd\"Release/vc90.pdb\" /W2 /Zi /TP $*.cpp ..\\..\\win\\inspircd_memory_functions.cpp /link %s ..\\..\\bin\\release\\inspircd.lib ws2_32.lib /OUT:\"..\\..\\bin\\release\\modules\\$*.so\" /PDB:\"..\\..\\bin\\release\\modules\\$*.pdb\" /IMPLIB:\"..\\..\\bin\\release\\modules\\$*.lib\"\n\n", extra_include.c_str(), extra_lib.c_str());
565                 CreateDirectory("..\\src\\modules\\release", NULL);
566         #endif
567 #endif
568         
569 #ifdef _DEBUG
570         fprintf(f, "makedir:\n  if not exist debug mkdir debug\n\n");
571 #else
572         fprintf(f, "makedir:\n  if not exist release mkdir release\n\n");
573 #endif
574
575         // dump modules.. again the second and last time :)
576         for(int i = 0; i < module_count; ++i)
577                 fprintf(f, "%s.so : %s.obj\n", modules[i], modules[i]);
578
579         fprintf(f, "\n");
580         fclose(f);
581 }