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