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