ide_visualc.cxx 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807
  1. //
  2. // "$Id: ide_visualc.cxx 7674 2010-07-10 14:01:22Z AlbrechtS $"
  3. //
  4. // IDE and Build File generation for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 2010 by Matthias Melcher.
  7. //
  8. // This library is free software; you can redistribute it and/or
  9. // modify it under the terms of the GNU Library General Public
  10. // License as published by the Free Software Foundation; either
  11. // version 2 of the License, or (at your option) any later version.
  12. //
  13. // This library is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. // Library General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Library General Public
  19. // License along with this library; if not, write to the Free Software
  20. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  21. // USA.
  22. //
  23. // Please report all bugs and problems on the following page:
  24. //
  25. // http://www.fltk.org/str.php
  26. //
  27. /*
  28. VisualC 6 IDE FILES
  29. This module generates all files needed for a VisualC++ 6.0 description of the
  30. FLTK project. Thanks to the developers of Visual Studion, VC6 files can be read
  31. and converted by all newer versions of VisualC++ as well (tested up to VC2008).
  32. There is no need to write any newer file formats.
  33. The VC6 file formats are very simple. The project is described in a .dsw file
  34. which basically just lists all targets and their interdependencies. The targets
  35. are then described in .dsp files which list the included source files and the
  36. build options.
  37. */
  38. #include "ide_support.h"
  39. #include <FL/filename.H>
  40. #include <FL/fl_ask.H>
  41. #include "../src/flstring.h"
  42. #include "Fl_Type.h"
  43. static void DOSPath(char *s) {
  44. for (;;) {
  45. switch (*s) {
  46. case 0: return;
  47. case '/': *s = '\\';
  48. }
  49. s++;
  50. }
  51. }
  52. /*
  53. * This class creates all VisualC++ 6.0 IDE files.
  54. */
  55. class VisualC6_IDE {
  56. char *rootDir;
  57. char projectName[80];
  58. Fl_Preferences tgtAppsDB;
  59. int nTgtApps;
  60. Fl_Preferences tgtLibsDB;
  61. int nTgtLibs;
  62. Fl_Preferences tgtTestsDB;
  63. int nTgtTests;
  64. Fl_Preferences filesDB;
  65. int nFiles;
  66. Fl_Preferences ideDB;
  67. public:
  68. VisualC6_IDE(Fl_Preferences &db, const char *rootDirA)
  69. : rootDir(strdup(rootDirA)),
  70. tgtAppsDB(db, "targets/apps"),
  71. tgtLibsDB(db, "targets/libs"),
  72. tgtTestsDB(db, "targets/tests"),
  73. filesDB(db, "files"),
  74. ideDB(db, "ide/VisualC")
  75. {
  76. db.get("projectName", projectName, "Unnamed", 80);
  77. nTgtApps = tgtAppsDB.groups();
  78. nTgtLibs = tgtLibsDB.groups();
  79. nTgtTests = tgtTestsDB.groups();
  80. nFiles = filesDB.groups();
  81. }
  82. ~VisualC6_IDE() {
  83. if (rootDir) free(rootDir);
  84. }
  85. /*
  86. * Write a project description
  87. */
  88. int writeProjectSection(FILE *f, Fl_Preferences &targetDB, char dll=0) {
  89. char name[80]; targetDB.get("name", name, "DBERROR", 80);
  90. if (dll) strcat(name, "dll");
  91. fprintf(f, "###############################################################################\r\n");
  92. fprintf(f, "\r\n");
  93. fprintf(f, "Project: \"%s\"=\".\\%s.dsp\" - Package Owner=<4>\r\n", name, name);
  94. fprintf(f, "\r\n");
  95. fprintf(f, "Package=<5>\r\n");
  96. fprintf(f, "{{{\r\n");
  97. fprintf(f, "}}}\r\n");
  98. fprintf(f, "\r\n");
  99. fprintf(f, "Package=<4>\r\n");
  100. fprintf(f, "{{{\r\n");
  101. Fl_Preferences depsDB(targetDB, "deps");
  102. int i, n = depsDB.groups();
  103. for (i=0; i<n; i++) {
  104. Fl_Preferences depDB(depsDB, i);
  105. GET_UUID(refUUID, depDB);
  106. Fl_Preferences *depTgtDBp = 0;
  107. if (tgtAppsDB.groupExists(refUUID))
  108. depTgtDBp = new Fl_Preferences(tgtAppsDB, refUUID);
  109. else if (tgtLibsDB.groupExists(refUUID))
  110. depTgtDBp = new Fl_Preferences(tgtLibsDB, refUUID);
  111. else if (tgtTestsDB.groupExists(refUUID))
  112. depTgtDBp = new Fl_Preferences(tgtTestsDB, refUUID);
  113. if (depTgtDBp) {
  114. char depName[80]; depTgtDBp->get("name", depName, "DBERROR", 80);
  115. fprintf(f, " Begin Project Dependency\r\n");
  116. fprintf(f, " Project_Dep_Name %s\r\n", depName);
  117. fprintf(f, " End Project Dependency\r\n");
  118. }
  119. }
  120. fprintf(f, "}}}\r\n");
  121. fprintf(f, "\r\n");
  122. return 0;
  123. }
  124. /*
  125. * Write the .dsw project file
  126. */
  127. int writeProjectFile(const char *filepath) {
  128. char filename[2048];
  129. fl_snprintf(filename, 2047, "%s/%s.dsw", filepath, "fltk");
  130. FILE *f = fopen(filename, "wb");
  131. if (!f) {
  132. fl_alert("Can't open file:\n%s", filename);
  133. return -1;
  134. }
  135. fprintf(f, "Microsoft Developer Studio Workspace File, Format Version 6.00\r\n");
  136. fprintf(f, "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r\n");
  137. fprintf(f, "\r\n");
  138. int i;
  139. // Applications
  140. for (i=0; i<nTgtApps; i++) {
  141. Fl_Preferences targetDB(tgtAppsDB, i);
  142. writeProjectSection(f, targetDB);
  143. }
  144. // Static Libraries
  145. for (i=0; i<nTgtLibs; i++) {
  146. Fl_Preferences targetDB(tgtLibsDB, i);
  147. writeProjectSection(f, targetDB);
  148. }
  149. // Dynamically Linking Libraries
  150. for (i=0; i<nTgtLibs; i++) {
  151. Fl_Preferences targetDB(tgtLibsDB, i);
  152. writeProjectSection(f, targetDB, 1);
  153. }
  154. // Tests
  155. for (i=0; i<nTgtTests; i++) {
  156. Fl_Preferences targetDB(tgtTestsDB, i);
  157. writeProjectSection(f, targetDB);
  158. }
  159. fprintf(f, "###############################################################################\r\n");
  160. fprintf(f, "\r\n");
  161. fclose(f);
  162. return 0;
  163. }
  164. /*
  165. * Write a source file entry.
  166. */
  167. int writeSourceFile(FILE *f, Fl_File_Prefs &fileDB) {
  168. char pathAndName[1024]; fileDB.get("pathAndName", pathAndName, "DBERROR/DBERROR.DBERR", 1024);
  169. DOSPath(pathAndName);
  170. fprintf(f, "# Begin Source File\r\n");
  171. fprintf(f, "\r\n");
  172. fprintf(f, "SOURCE=..\\..\\%s\r\n", pathAndName);
  173. fprintf(f, "# End Source File\r\n");
  174. return 0;
  175. }
  176. /*
  177. * Write a Fluid file entry.
  178. */
  179. int writeFluidFile(FILE *f, Fl_File_Prefs &fileDB, const char *name) {
  180. char pathAndName[1024]; fileDB.get("pathAndName", pathAndName, "DBERROR/DBERROR.DBERR", 1024);
  181. char cxx_pathname[1024]; strcpy(cxx_pathname, pathAndName);
  182. char path_fl[1024]; strcpy(path_fl, fileDB.filePath());
  183. DOSPath(pathAndName);
  184. fl_filename_setext(cxx_pathname, 1024, ".cxx");
  185. DOSPath(cxx_pathname);
  186. DOSPath(path_fl);
  187. fprintf(f, "# Begin Source File\r\n");
  188. fprintf(f, "\r\n");
  189. fprintf(f, "SOURCE=..\\..\\%s\r\n", cxx_pathname);
  190. fprintf(f, "# End Source File\r\n");
  191. fprintf(f, "# Begin Source File\r\n");
  192. fprintf(f, "\r\n");
  193. fprintf(f, "SOURCE=..\\..\\%s\r\n", pathAndName);
  194. fprintf(f, "\r\n");
  195. fprintf(f, "!IF \"$(CFG)\" == \"%s - Win32 Release\"\r\n", name);
  196. fprintf(f, "\r\n");
  197. fprintf(f, "# Begin Custom Build - Create .cxx and .h file with fluid\r\n");
  198. fprintf(f, "InputPath=..\\..\\%s\r\n", pathAndName);
  199. fprintf(f, "\r\n");
  200. fprintf(f, "\"..\\..\\%s\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\r\n", cxx_pathname);
  201. fprintf(f, "\tpushd ..\\..\\%s \r\n", path_fl);
  202. fprintf(f, "\t..\\fluid\\fluid -c %s\r\n", fileDB.fullName());
  203. fprintf(f, "\tpopd \r\n");
  204. fprintf(f, "\t\r\n");
  205. fprintf(f, "# End Custom Build\r\n");
  206. fprintf(f, "\r\n");
  207. fprintf(f, "!ELSEIF \"$(CFG)\" == \"%s - Win32 Debug\"\r\n", name);
  208. fprintf(f, "\r\n");
  209. fprintf(f, "# Begin Custom Build - Create .cxx and .h file with fluidd\r\n");
  210. fprintf(f, "InputPath=..\\..\\%s\r\n", pathAndName);
  211. fprintf(f, "\r\n");
  212. fprintf(f, "\"..\\..\\%s\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\r\n", cxx_pathname);
  213. fprintf(f, "\tpushd ..\\..\\%s \r\n", path_fl);
  214. fprintf(f, "\t..\\fluid\\fluidd -c %s \r\n", fileDB.fullName());
  215. fprintf(f, "\tpopd \r\n");
  216. fprintf(f, "\t\r\n");
  217. fprintf(f, "# End Custom Build\r\n");
  218. fprintf(f, "\r\n");
  219. fprintf(f, "!ENDIF \r\n");
  220. fprintf(f, "\r\n");
  221. fprintf(f, "# End Source File\r\n");
  222. return 0;
  223. }
  224. /*
  225. * Write a .dsp target file
  226. */
  227. int writeApplicationTarget(const char *filepath, Fl_Preferences &targetDB, const char *dir=0) {
  228. char name[80]; targetDB.get("name", name, "DBERROR", 80);
  229. if (!dir) dir = name;
  230. char filename[2048];
  231. fl_snprintf(filename, 2047, "%s/%s.dsp", filepath, name);
  232. FILE *f = fopen(filename, "wb");
  233. if (!f) {
  234. fl_alert("Can't open file:\n%s", filename);
  235. return -1;
  236. }
  237. fprintf(f, "# Microsoft Developer Studio Project File - Name=\"%s\" - Package Owner=<4>\r\n", name);
  238. fprintf(f, "# Microsoft Developer Studio Generated Build File, Format Version 6.00\r\n");
  239. fprintf(f, "# ** DO NOT EDIT **\r\n");
  240. fprintf(f, "\r\n");
  241. fprintf(f, "# TARGTYPE \"Win32 (x86) Application\" 0x0101\r\n");
  242. fprintf(f, "\r\n");
  243. fprintf(f, "CFG=%s - Win32 Debug\r\n", name);
  244. fprintf(f, "!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r\n");
  245. fprintf(f, "!MESSAGE use the Export Makefile command and run\r\n");
  246. fprintf(f, "!MESSAGE \r\n");
  247. fprintf(f, "!MESSAGE NMAKE /f \"%s.mak\".\r\n", name);
  248. fprintf(f, "!MESSAGE \r\n");
  249. fprintf(f, "!MESSAGE You can specify a configuration when running NMAKE\r\n");
  250. fprintf(f, "!MESSAGE by defining the macro CFG on the command line. For example:\r\n");
  251. fprintf(f, "!MESSAGE \r\n");
  252. fprintf(f, "!MESSAGE NMAKE /f \"%s.mak\" CFG=\"%s - Win32 Debug\"\r\n", name, name);
  253. fprintf(f, "!MESSAGE \r\n");
  254. fprintf(f, "!MESSAGE Possible choices for configuration are:\r\n");
  255. fprintf(f, "!MESSAGE \r\n");
  256. fprintf(f, "!MESSAGE \"%s - Win32 Release\" (based on \"Win32 (x86) Application\")\r\n", name);
  257. fprintf(f, "!MESSAGE \"%s - Win32 Debug\" (based on \"Win32 (x86) Application\")\r\n", name);
  258. fprintf(f, "!MESSAGE \r\n");
  259. fprintf(f, "\r\n");
  260. fprintf(f, "# Begin Project\r\n");
  261. fprintf(f, "# PROP AllowPerConfigDependencies 0\r\n");
  262. fprintf(f, "# PROP Scc_ProjName \"\"\r\n");
  263. fprintf(f, "# PROP Scc_LocalPath \"\"\r\n");
  264. fprintf(f, "CPP=cl.exe\r\n");
  265. fprintf(f, "MTL=midl.exe\r\n");
  266. fprintf(f, "RSC=rc.exe\r\n");
  267. fprintf(f, "\r\n");
  268. fprintf(f, "!IF \"$(CFG)\" == \"%s - Win32 Release\"\r\n", name);
  269. fprintf(f, "\r\n");
  270. fprintf(f, "# PROP BASE Use_MFC 0\r\n");
  271. fprintf(f, "# PROP BASE Use_Debug_Libraries 0\r\n");
  272. fprintf(f, "# PROP BASE Output_Dir \"Release/$(ProjectName)\"\r\n");
  273. fprintf(f, "# PROP BASE Intermediate_Dir \"Release/$(ProjectName)\"\r\n");
  274. fprintf(f, "# PROP BASE Target_Dir \"\"\r\n");
  275. fprintf(f, "# PROP Use_MFC 0\r\n");
  276. fprintf(f, "# PROP Use_Debug_Libraries 0\r\n");
  277. fprintf(f, "# PROP Output_Dir \"Release/$(ProjectName)\"\r\n");
  278. fprintf(f, "# PROP Intermediate_Dir \"Release/$(ProjectName)\"\r\n");
  279. fprintf(f, "# PROP Ignore_Export_Lib 0\r\n");
  280. fprintf(f, "# PROP Target_Dir \"\"\r\n");
  281. fprintf(f, "# ADD BASE CPP /nologo /W3 /GX /O2 /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /YX /FD /c\r\n");
  282. fprintf(f, "# ADD CPP /nologo /MD /GX /Os /Ob2 /I \".\" /I \"../..\" /I \"../../zlib\" /I \"../../png\" /I \"../../jpeg\" /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"WIN32_LEAN_AND_MEAN\" /D \"VC_EXTRA_LEAN\" /D \"WIN32_EXTRA_LEAN\" /YX /FD /c\r\n");
  283. fprintf(f, "# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /o \"NUL\" /win32\r\n");
  284. fprintf(f, "# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /o \"NUL\" /win32\r\n");
  285. fprintf(f, "# ADD BASE RSC /l 0x409 /d \"NDEBUG\"\r\n");
  286. fprintf(f, "# ADD RSC /l 0x409 /d \"NDEBUG\"\r\n");
  287. fprintf(f, "BSC32=bscmake.exe\r\n");
  288. fprintf(f, "# ADD BASE BSC32 /nologo\r\n");
  289. fprintf(f, "# ADD BSC32 /nologo\r\n");
  290. fprintf(f, "LINK32=link.exe\r\n");
  291. fprintf(f, "# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386\r\n");
  292. fprintf(f, "# ADD LINK32 ");
  293. Fl_Preferences libsDB(targetDB, "libs");
  294. int i, n = libsDB.groups();
  295. for (i=0; i<n; i++) {
  296. Fl_Preferences libDB(libsDB, i);
  297. GET_UUID(refUUID, libDB);
  298. Fl_Preferences tgtLibDB(tgtLibsDB, refUUID);
  299. char name[80]; tgtLibDB.get("name", name, "DBERROR", 80);
  300. fprintf(f, "%s.lib ", name);
  301. }
  302. Fl_Preferences extsDB(targetDB, "externals");
  303. n = extsDB.groups();
  304. for (i=0; i<n; i++) {
  305. Fl_Preferences extDB(extsDB, i);
  306. if (with_visualc(extDB.id())) {
  307. GET_UUID(refUUID, extDB);
  308. Fl_File_Prefs fileDB(filesDB, refUUID);
  309. char pathAndName[1024]; fileDB.get("pathAndName", pathAndName, "DBERROR/DBERROR.DBERR", 1024);
  310. fprintf(f, "%s ", pathAndName);
  311. }
  312. }
  313. fprintf(f, "comctl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:\"libcd\" /out:\"../../%s/%s.exe\" /pdbtype:sept /libpath:\"..\\..\\lib\"\r\n", dir, name);
  314. fprintf(f, "# SUBTRACT LINK32 /pdb:none /incremental:yes\r\n");
  315. fprintf(f, "\r\n");
  316. fprintf(f, "!ELSEIF \"$(CFG)\" == \"%s - Win32 Debug\"\r\n", name);
  317. fprintf(f, "\r\n");
  318. fprintf(f, "# PROP BASE Use_MFC 0\r\n");
  319. fprintf(f, "# PROP BASE Use_Debug_Libraries 1\r\n");
  320. fprintf(f, "# PROP BASE Output_Dir \"Debug/$(ProjectName)\"\r\n");
  321. fprintf(f, "# PROP BASE Intermediate_Dir \"Debug/$(ProjectName)\"\r\n");
  322. fprintf(f, "# PROP BASE Target_Dir \"\"\r\n");
  323. fprintf(f, "# PROP Use_MFC 0\r\n");
  324. fprintf(f, "# PROP Use_Debug_Libraries 1\r\n");
  325. fprintf(f, "# PROP Output_Dir \"Debug/$(ProjectName)\"\r\n");
  326. fprintf(f, "# PROP Intermediate_Dir \"Debug/$(ProjectName)\"\r\n");
  327. fprintf(f, "# PROP Ignore_Export_Lib 0\r\n");
  328. fprintf(f, "# PROP Target_Dir \"\"\r\n");
  329. fprintf(f, "# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /YX /FD /c\r\n");
  330. fprintf(f, "# ADD CPP /nologo /MDd /Gm /GX /ZI /Od /I \".\" /I \"../..\" /I \"../../zlib\" /I \"../../png\" /I \"../../jpeg\" /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /D \"WIN32_LEAN_AND_MEAN\" /D \"VC_EXTRA_LEAN\" /D \"WIN32_EXTRA_LEAN\" /YX /FD /c\r\n");
  331. fprintf(f, "# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /o \"NUL\" /win32\r\n");
  332. fprintf(f, "# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /o \"NUL\" /win32\r\n");
  333. fprintf(f, "# ADD BASE RSC /l 0x409 /d \"_DEBUG\"\r\n");
  334. fprintf(f, "# ADD RSC /l 0x409 /d \"_DEBUG\"\r\n");
  335. fprintf(f, "BSC32=bscmake.exe\r\n");
  336. fprintf(f, "# ADD BASE BSC32 /nologo\r\n");
  337. fprintf(f, "# ADD BSC32 /nologo\r\n");
  338. fprintf(f, "LINK32=link.exe\r\n");
  339. fprintf(f, "# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept\r\n");
  340. fprintf(f, "# ADD LINK32 ");
  341. n = libsDB.groups();
  342. for (i=0; i<n; i++) {
  343. Fl_Preferences libDB(libsDB, i);
  344. GET_UUID(refUUID, libDB);
  345. Fl_Preferences tgtLibDB(tgtLibsDB, refUUID);
  346. char name[80]; tgtLibDB.get("name", name, "DBERROR", 80);
  347. fprintf(f, "%sd.lib ", name);
  348. }
  349. n = extsDB.groups();
  350. for (i=0; i<n; i++) {
  351. Fl_Preferences extDB(extsDB, i);
  352. if (with_visualc(extDB.id())) {
  353. GET_UUID(refUUID, extDB);
  354. Fl_File_Prefs fileDB(filesDB, refUUID);
  355. char pathAndName[1024]; fileDB.get("pathAndName", pathAndName, "DBERROR/DBERROR.DBERR", 1024);
  356. fprintf(f, "%s ", pathAndName);
  357. }
  358. }
  359. fprintf(f, "comctl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:\"libcd\" /out:\"../../%s/%sd.exe\" /pdbtype:sept /libpath:\"..\\..\\lib\"\r\n", dir, name);
  360. fprintf(f, "# SUBTRACT LINK32 /pdb:none /incremental:no\r\n");
  361. fprintf(f, "\r\n");
  362. fprintf(f, "!ENDIF \r\n");
  363. fprintf(f, "\r\n");
  364. fprintf(f, "# Begin Target\r\n");
  365. fprintf(f, "\r\n");
  366. fprintf(f, "# Name \"%s - Win32 Release\"\r\n", name);
  367. fprintf(f, "# Name \"%s - Win32 Debug\"\r\n", name);
  368. Fl_Preferences sourcesDB(targetDB, "sources");
  369. n = sourcesDB.groups();
  370. for (i=0; i<n; i++) {
  371. Fl_Preferences sourceDB(sourcesDB, i);
  372. GET_UUID(refUUID, sourceDB);
  373. Fl_File_Prefs fileDB(filesDB, refUUID);
  374. writeSourceFile(f, fileDB);
  375. }
  376. Fl_Preferences flsDB(targetDB, "fl");
  377. n = flsDB.groups();
  378. for (i=0; i<n; i++) {
  379. Fl_Preferences flDB(flsDB, i);
  380. GET_UUID(refUUID, flDB);
  381. Fl_File_Prefs fileDB(filesDB, refUUID);
  382. writeFluidFile(f, fileDB, name);
  383. }
  384. fprintf(f, "# End Target\r\n");
  385. fprintf(f, "# End Project\r\n");
  386. fclose(f);
  387. return 0;
  388. }
  389. /*
  390. * Write a .dsp target file
  391. * FIXME: this is somehow seen as an application, not a static library
  392. * FIXME: the library is written into ide/VisualC6/Debug, and not into lib
  393. */
  394. int writeStaticLibTarget(const char *filepath, Fl_Preferences &targetDB, const char *dir=0) {
  395. char name[80]; targetDB.get("name", name, "DBERROR", 80);
  396. if (!dir) dir = name;
  397. char filename[2048];
  398. fl_snprintf(filename, 2047, "%s/%s.dsp", filepath, name);
  399. FILE *f = fopen(filename, "wb");
  400. if (!f) {
  401. fl_alert("Can't open file:\n%s", filename);
  402. return -1;
  403. }
  404. fprintf(f, "# Microsoft Developer Studio Project File - Name=\"%s\" - Package Owner=<4>\r\n", name);
  405. fprintf(f, "# Microsoft Developer Studio Generated Build File, Format Version 6.00\r\n");
  406. fprintf(f, "# ** DO NOT EDIT **\r\n");
  407. fprintf(f, "\r\n");
  408. fprintf(f, "# TARGTYPE \"Win32 (x86) Static Library\" 0x0104\r\n");
  409. fprintf(f, "\r\n");
  410. fprintf(f, "CFG=%s - Win32 Debug\r\n", name);
  411. fprintf(f, "!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r\n");
  412. fprintf(f, "!MESSAGE use the Export Makefile command and run\r\n");
  413. fprintf(f, "!MESSAGE \r\n");
  414. fprintf(f, "!MESSAGE NMAKE /f \"%s.mak\".\r\n", name);
  415. fprintf(f, "!MESSAGE \r\n");
  416. fprintf(f, "!MESSAGE You can specify a configuration when running NMAKE\r\n");
  417. fprintf(f, "!MESSAGE by defining the macro CFG on the command line. For example:\r\n");
  418. fprintf(f, "!MESSAGE \r\n");
  419. fprintf(f, "!MESSAGE NMAKE /f \"%s.mak\" CFG=\"%s - Win32 Debug\"\r\n", name, name);
  420. fprintf(f, "!MESSAGE \r\n");
  421. fprintf(f, "!MESSAGE Possible choices for configuration are:\r\n");
  422. fprintf(f, "!MESSAGE \r\n");
  423. fprintf(f, "!MESSAGE \"%s - Win32 Release\" (based on \"Win32 (x86) Static Library\")\r\n", name);
  424. fprintf(f, "!MESSAGE \"%s - Win32 Debug\" (based on \"Win32 (x86) Static Library\")\r\n", name);
  425. fprintf(f, "!MESSAGE \r\n");
  426. fprintf(f, "\r\n");
  427. fprintf(f, "# Begin Project\r\n");
  428. fprintf(f, "# PROP AllowPerConfigDependencies 0\r\n");
  429. fprintf(f, "# PROP Scc_ProjName \"\"\r\n");
  430. fprintf(f, "# PROP Scc_LocalPath \"\"\r\n");
  431. fprintf(f, "CPP=cl.exe\r\n");
  432. fprintf(f, "RSC=rc.exe\r\n");
  433. fprintf(f, "\r\n");
  434. fprintf(f, "!IF \"$(CFG)\" == \"%s - Win32 Release\"\r\n", name);
  435. fprintf(f, "\r\n");
  436. fprintf(f, "# PROP BASE Use_MFC 0\r\n");
  437. fprintf(f, "# PROP BASE Use_Debug_Libraries 0\r\n");
  438. fprintf(f, "# PROP BASE Output_Dir \"Release/$(ProjectName)\"\r\n");
  439. fprintf(f, "# PROP BASE Intermediate_Dir \"Release/$(ProjectName)\"\r\n");
  440. fprintf(f, "# PROP BASE Target_Dir \"\"\r\n");
  441. fprintf(f, "# PROP Use_MFC 0\r\n");
  442. fprintf(f, "# PROP Use_Debug_Libraries 0\r\n");
  443. fprintf(f, "# PROP Output_Dir \"Release/$(ProjectName)\"\r\n");
  444. fprintf(f, "# PROP Intermediate_Dir \"Release/$(ProjectName)\"\r\n");
  445. fprintf(f, "# PROP Target_Dir \"\"\r\n");
  446. fprintf(f, "# ADD BASE CPP /nologo /W3 /GX /O2 /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /YX /FD /c\r\n");
  447. fprintf(f, "# ADD CPP /nologo /MD /GX /Ot /Op /Ob2 /I \".\" /I \"../..\" /I \"../../zlib\" /I \"../../png\" /I \"../../jpeg\" /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"WIN32_LEAN_AND_MEAN\" /D \"VC_EXTRA_LEAN\" /D \"WIN32_EXTRA_LEAN\" /YX /FD /c\r\n");
  448. fprintf(f, "# SUBTRACT CPP /Os\r\n");
  449. fprintf(f, "# ADD BASE RSC /l 0x409\r\n");
  450. fprintf(f, "# ADD RSC /l 0x409\r\n");
  451. fprintf(f, "BSC32=bscmake.exe\r\n");
  452. fprintf(f, "# ADD BASE BSC32 /nologo\r\n");
  453. fprintf(f, "# ADD BSC32 /nologo\r\n");
  454. fprintf(f, "LIB32=link.exe -lib\r\n");
  455. fprintf(f, "# ADD BASE LIB32 /nologo\r\n");
  456. fprintf(f, "# ADD LIB32 /nologo /out:\"..\\..\\lib\\%s.lib\"\r\n", name);
  457. fprintf(f, "\r\n");
  458. fprintf(f, "!ELSEIF \"$(CFG)\" == \"%s - Win32 Debug\"\r\n", name);
  459. fprintf(f, "\r\n");
  460. fprintf(f, "# PROP BASE Use_MFC 0\r\n");
  461. fprintf(f, "# PROP BASE Use_Debug_Libraries 1\r\n");
  462. fprintf(f, "# PROP BASE Output_Dir \"Debug/$(ProjectName)\"\r\n");
  463. fprintf(f, "# PROP BASE Intermediate_Dir \"Debug/$(ProjectName)\"\r\n");
  464. fprintf(f, "# PROP BASE Target_Dir \"\"\r\n");
  465. fprintf(f, "# PROP Use_MFC 0\r\n");
  466. fprintf(f, "# PROP Use_Debug_Libraries 1\r\n");
  467. fprintf(f, "# PROP Output_Dir \"Debug/$(ProjectName)\"\r\n");
  468. fprintf(f, "# PROP Intermediate_Dir \"Debug/$(ProjectName)\"\r\n");
  469. fprintf(f, "# PROP Target_Dir \"\"\r\n");
  470. fprintf(f, "# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /YX /FD /c\r\n");
  471. fprintf(f, "# ADD CPP /nologo /MDd /GX /Z7 /Od /I \".\" /I \"../..\" /I \"../../zlib\" /I \"../../png\" /I \"../../jpeg\" /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /D \"WIN32_LEAN_AND_MEAN\" /D \"VC_EXTRA_LEAN\" /D \"WIN32_EXTRA_LEAN\" /FR /YX /FD /c\r\n");
  472. fprintf(f, "# ADD BASE RSC /l 0x409\r\n");
  473. fprintf(f, "# ADD RSC /l 0x409\r\n");
  474. fprintf(f, "BSC32=bscmake.exe\r\n");
  475. fprintf(f, "# ADD BASE BSC32 /nologo\r\n");
  476. fprintf(f, "# ADD BSC32 /nologo\r\n");
  477. fprintf(f, "LIB32=link.exe -lib\r\n");
  478. fprintf(f, "# ADD BASE LIB32 /nologo\r\n");
  479. fprintf(f, "# ADD LIB32 /nologo /out:\"..\\..\\lib\\%sd.lib\"\r\n", name);
  480. fprintf(f, "\r\n");
  481. fprintf(f, "!ENDIF \r\n");
  482. fprintf(f, "\r\n");
  483. fprintf(f, "# Begin Target\r\n");
  484. fprintf(f, "\r\n");
  485. fprintf(f, "# Name \"%s - Win32 Release\"\r\n", name);
  486. fprintf(f, "# Name \"%s - Win32 Debug\"\r\n", name);
  487. Fl_Preferences sourcesDB(targetDB, "sources");
  488. int i, n = sourcesDB.groups();
  489. for (i=0; i<n; i++) {
  490. Fl_Preferences sourceDB(sourcesDB, i);
  491. GET_UUID(refUUID, sourceDB);
  492. Fl_File_Prefs fileDB(filesDB, refUUID);
  493. writeSourceFile(f, fileDB);
  494. }
  495. Fl_Preferences flsDB(targetDB, "fl");
  496. n = flsDB.groups();
  497. for (i=0; i<n; i++) {
  498. Fl_Preferences flDB(flsDB, i);
  499. GET_UUID(refUUID, flDB);
  500. Fl_File_Prefs fileDB(filesDB, refUUID);
  501. writeFluidFile(f, fileDB, name);
  502. }
  503. fprintf(f, "# End Target\r\n");
  504. fprintf(f, "# End Project\r\n");
  505. fclose(f);
  506. return 0;
  507. }
  508. /*
  509. * Write a .dsp target file
  510. */
  511. int writeDynamicLibTarget(const char *filepath, Fl_Preferences &targetDB, const char *dir=0) {
  512. char name[84]; targetDB.get("name", name, "DBERROR", 80); strcat(name, "dll");
  513. if (!dir) dir = name;
  514. char filename[2048];
  515. fl_snprintf(filename, 2047, "%s/%s.dsp", filepath, name);
  516. FILE *f = fopen(filename, "wb");
  517. if (!f) {
  518. fl_alert("Can't open file:\n%s", filename);
  519. return -1;
  520. }
  521. fprintf(f, "# Microsoft Developer Studio Project File - Name=\"%s\" - Package Owner=<4>\r\n", name);
  522. fprintf(f, "# Microsoft Developer Studio Generated Build File, Format Version 6.00\r\n");
  523. fprintf(f, "# ** DO NOT EDIT **\r\n");
  524. fprintf(f, "\r\n");
  525. fprintf(f, "# TARGTYPE \"Win32 (x86) Dynamic-Link Library\" 0x0102\r\n");
  526. fprintf(f, "\r\n");
  527. fprintf(f, "CFG=%s - Win32 Debug\r\n", name);
  528. fprintf(f, "!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r\n");
  529. fprintf(f, "!MESSAGE use the Export Makefile command and run\r\n");
  530. fprintf(f, "!MESSAGE \r\n");
  531. fprintf(f, "!MESSAGE NMAKE /f \"%s.mak\".\r\n", name);
  532. fprintf(f, "!MESSAGE \r\n");
  533. fprintf(f, "!MESSAGE You can specify a configuration when running NMAKE\r\n");
  534. fprintf(f, "!MESSAGE by defining the macro CFG on the command line. For example:\r\n");
  535. fprintf(f, "!MESSAGE \r\n");
  536. fprintf(f, "!MESSAGE NMAKE /f \"%s.mak\" CFG=\"%s - Win32 Debug\"\r\n", name, name);
  537. fprintf(f, "!MESSAGE \r\n");
  538. fprintf(f, "!MESSAGE Possible choices for configuration are:\r\n");
  539. fprintf(f, "!MESSAGE \r\n");
  540. fprintf(f, "!MESSAGE \"%s - Win32 Release\" (based on \"Win32 (x86) Dynamic-Link Library\")\r\n", name);
  541. fprintf(f, "!MESSAGE \"%s - Win32 Debug\" (based on \"Win32 (x86) Dynamic-Link Library\")\r\n", name);
  542. fprintf(f, "!MESSAGE \r\n");
  543. fprintf(f, "\r\n");
  544. fprintf(f, "# Begin Project\r\n");
  545. fprintf(f, "# PROP AllowPerConfigDependencies 0\r\n");
  546. fprintf(f, "# PROP Scc_ProjName \"\"\r\n");
  547. fprintf(f, "# PROP Scc_LocalPath \"\"\r\n");
  548. fprintf(f, "CPP=cl.exe\r\n");
  549. fprintf(f, "MTL=midl.exe\r\n");
  550. fprintf(f, "RSC=rc.exe\r\n");
  551. fprintf(f, "\r\n");
  552. fprintf(f, "!IF \"$(CFG)\" == \"%s - Win32 Release\"\r\n", name);
  553. fprintf(f, "\r\n");
  554. fprintf(f, "# PROP BASE Use_MFC 0\r\n");
  555. fprintf(f, "# PROP BASE Use_Debug_Libraries 0\r\n");
  556. fprintf(f, "# PROP BASE Output_Dir \"Release/$(ProjectName)\"\r\n");
  557. fprintf(f, "# PROP BASE Intermediate_Dir \"Release/$(ProjectName)\"\r\n");
  558. fprintf(f, "# PROP BASE Target_Dir \"\"\r\n");
  559. fprintf(f, "# PROP Use_MFC 0\r\n");
  560. fprintf(f, "# PROP Use_Debug_Libraries 0\r\n");
  561. fprintf(f, "# PROP Output_Dir \"Release/$(ProjectName)\"\r\n");
  562. fprintf(f, "# PROP Intermediate_Dir \"Release/$(ProjectName)\"\r\n");
  563. fprintf(f, "# PROP Ignore_Export_Lib 0\r\n");
  564. fprintf(f, "# PROP Target_Dir \"\"\r\n");
  565. fprintf(f, "# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /YX /FD /c\r\n");
  566. fprintf(f, "# ADD CPP /nologo /MD /W3 /GX /Os /Ob2 /I \"../../zlib\" /I \"../../png\" /I \"../../jpeg\" /I \".\" /I \"../..\" /D \"FL_DLL\" /D \"FL_LIBRARY\" /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"WIN32_LEAN_AND_MEAN\" /D \"VC_EXTRA_LEAN\" /D \"WIN32_EXTRA_LEAN\" /YX /c\r\n");
  567. fprintf(f, "# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /o /win32 \"NUL\"\r\n");
  568. fprintf(f, "# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /o /win32 \"NUL\"\r\n");
  569. fprintf(f, "# ADD BASE RSC /l 0x409 /d \"NDEBUG\"\r\n");
  570. fprintf(f, "# ADD RSC /l 0x409 /d \"NDEBUG\"\r\n");
  571. fprintf(f, "BSC32=bscmake.exe\r\n");
  572. fprintf(f, "# ADD BASE BSC32 /nologo\r\n");
  573. fprintf(f, "# ADD BSC32 /nologo\r\n");
  574. fprintf(f, "LINK32=link.exe\r\n");
  575. fprintf(f, "# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /dll /machine:I386\r\n");
  576. fprintf(f, "# ADD LINK32 opengl32.lib comctl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /version:1.0 /subsystem:windows /dll /pdb:\"%s.pdb\" /machine:I386\r\n", name);
  577. fprintf(f, "# SUBTRACT LINK32 /pdb:none\r\n");
  578. fprintf(f, "\r\n");
  579. fprintf(f, "!ELSEIF \"$(CFG)\" == \"%s - Win32 Debug\"\r\n", name);
  580. fprintf(f, "\r\n");
  581. fprintf(f, "# PROP BASE Use_MFC 0\r\n");
  582. fprintf(f, "# PROP BASE Use_Debug_Libraries 1\r\n");
  583. fprintf(f, "# PROP BASE Output_Dir \"Debug/$(ProjectName)\"\r\n");
  584. fprintf(f, "# PROP BASE Intermediate_Dir \"Debug/$(ProjectName)\"\r\n");
  585. fprintf(f, "# PROP BASE Target_Dir \"\"\r\n");
  586. fprintf(f, "# PROP Use_MFC 0\r\n");
  587. fprintf(f, "# PROP Use_Debug_Libraries 1\r\n");
  588. fprintf(f, "# PROP Output_Dir \"Debug/$(ProjectName)\"\r\n");
  589. fprintf(f, "# PROP Intermediate_Dir \"Debug/$(ProjectName)\"\r\n");
  590. fprintf(f, "# PROP Ignore_Export_Lib 0\r\n");
  591. fprintf(f, "# PROP Target_Dir \"\"\r\n");
  592. fprintf(f, "# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /YX /FD /c\r\n");
  593. fprintf(f, "# ADD CPP /nologo /MDd /GX /ZI /Od /I \".\" /I \"../..\" /I \"..\\..\\zlib\" /I \"..\\..\\png\" /I \"..\\..\\jpeg\" /D \"FL_DLL\" /D \"FL_LIBRARY\" /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /D \"WIN32_LEAN_AND_MEAN\" /D \"VC_EXTRA_LEAN\" /D \"WIN32_EXTRA_LEAN\" /YX /c\r\n");
  594. fprintf(f, "# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /o /win32 \"NUL\"\r\n");
  595. fprintf(f, "# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /o /win32 \"NUL\"\r\n");
  596. fprintf(f, "# ADD BASE RSC /l 0x409 /d \"_DEBUG\"\r\n");
  597. fprintf(f, "# ADD RSC /l 0x409 /d \"_DEBUG\"\r\n");
  598. fprintf(f, "BSC32=bscmake.exe\r\n");
  599. fprintf(f, "# ADD BASE BSC32 /nologo\r\n");
  600. fprintf(f, "# ADD BSC32 /nologo\r\n");
  601. fprintf(f, "LINK32=link.exe\r\n");
  602. fprintf(f, "# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept\r\n");
  603. fprintf(f, "# ADD LINK32 opengl32.lib comctl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /version:1.0 /subsystem:windows /dll /pdb:\"%sd.pdb\" /debug /machine:I386 /out:\"../../test/%sd.dll\" /pdbtype:sept\r\n", name, name);
  604. fprintf(f, "# SUBTRACT LINK32 /pdb:none /incremental:no\r\n");
  605. fprintf(f, "\r\n");
  606. fprintf(f, "!ENDIF \r\n");
  607. fprintf(f, "\r\n");
  608. fprintf(f, "# Begin Target\r\n");
  609. fprintf(f, "\r\n");
  610. fprintf(f, "# Name \"%s - Win32 Release\"\r\n", name);
  611. fprintf(f, "# Name \"%s - Win32 Debug\"\r\n", name);
  612. Fl_Preferences sourcesDB(targetDB, "sources");
  613. int i, n = sourcesDB.groups();
  614. for (i=0; i<n; i++) {
  615. Fl_Preferences sourceDB(sourcesDB, i);
  616. GET_UUID(refUUID, sourceDB);
  617. Fl_File_Prefs fileDB(filesDB, refUUID);
  618. writeSourceFile(f, fileDB);
  619. }
  620. Fl_Preferences flsDB(targetDB, "fl");
  621. n = flsDB.groups();
  622. for (i=0; i<n; i++) {
  623. Fl_Preferences flDB(flsDB, i);
  624. GET_UUID(refUUID, flDB);
  625. Fl_File_Prefs fileDB(filesDB, refUUID);
  626. writeFluidFile(f, fileDB, name);
  627. }
  628. fprintf(f, "# End Target\r\n");
  629. fprintf(f, "# End Project\r\n");
  630. fclose(f);
  631. return 0;
  632. }
  633. /*
  634. * Write the .dsp target files
  635. */
  636. int writeTargetFiles(const char *filepath) {
  637. int i;
  638. for (i=0; i<nTgtApps; i++) {
  639. Fl_Preferences targetDB(tgtAppsDB, i);
  640. writeApplicationTarget(filepath, targetDB);
  641. }
  642. for (i=0; i<nTgtLibs; i++) {
  643. Fl_Preferences targetDB(tgtLibsDB, i);
  644. writeStaticLibTarget(filepath, targetDB, "src");
  645. }
  646. for (i=0; i<nTgtLibs; i++) {
  647. Fl_Preferences targetDB(tgtLibsDB, i);
  648. writeDynamicLibTarget(filepath, targetDB, "src");
  649. }
  650. for (i=0; i<nTgtTests; i++) {
  651. Fl_Preferences targetDB(tgtTestsDB, i);
  652. writeApplicationTarget(filepath, targetDB, "test");
  653. }
  654. return 0;
  655. }
  656. int writeConfigH(const char *filename) {
  657. FILE *f = fopen(filename, "wb");
  658. fputs("/*\n", f);
  659. fputs(" * \"$Id: ide_visualc.cxx 7674 2010-07-10 14:01:22Z AlbrechtS $\"\n", f);
  660. fputs(" */\n", f);
  661. fputs("#define FLTK_DATADIR \"C:/FLTK\"\n", f);
  662. fputs("#define FLTK_DOCDIR \"C:/FLTK/DOC\"\n", f);
  663. fputs("#define BORDER_WIDTH 2\n", f);
  664. fputs("#define HAVE_GL 1\n", f);
  665. fputs("#define HAVE_GL_GLU_H 1\n", f);
  666. fputs("#define USE_COLORMAP 1\n", f);
  667. fputs("#define HAVE_XDBE 0\n", f);
  668. fputs("#define USE_XDBE HAVE_XDBE\n", f);
  669. fputs("#define HAVE_OVERLAY 0\n", f);
  670. fputs("#define HAVE_GL_OVERLAY 1\n", f);
  671. fputs("#define WORDS_BIGENDIAN 0\n", f);
  672. fputs("#define U16 unsigned short\n", f);
  673. fputs("#define U32 unsigned\n", f);
  674. fputs("#undef U64\n", f);
  675. fputs("#define HAVE_VSNPRINTF 0\n", f);
  676. fputs("#define HAVE_SNPRINTF 0\n", f);
  677. fputs("#define HAVE_STRCASECMP 1\n", f);
  678. fputs("#define HAVE_LOCALE_H 1\n", f);
  679. fputs("#define HAVE_LOCALECONV 1\n", f);
  680. fputs("#define HAVE_POLL 0\n", f);
  681. fputs("#define HAVE_LIBPNG\n", f);
  682. fputs("#define HAVE_LIBZ\n", f);
  683. fputs("#define HAVE_LIBJPEG\n", f);
  684. fputs("#define HAVE_PNG_H\n", f);
  685. fputs("#undef HAVE_LIBPNG_PNG_H\n", f);
  686. fputs("#define HAVE_PNG_GET_VALID\n", f);
  687. fputs("#define HAVE_PNG_SET_TRNS_TO_ALPHA\n", f);
  688. fputs("/*\n", f);
  689. fputs(" * End of \"$Id: ide_visualc.cxx 7674 2010-07-10 14:01:22Z AlbrechtS $\".\n", f);
  690. fputs(" */\n", f);
  691. fclose(f);
  692. return 0;
  693. }
  694. /*
  695. * Write the entire system of files.
  696. */
  697. int write() {
  698. char filepath[2048];
  699. // --- create directory structure ide/VisualC6
  700. sprintf(filepath, "%s/ide", rootDir); fl_mkdir(filepath, 0777);
  701. sprintf(filepath, "%s/ide/VisualC6", rootDir); fl_mkdir(filepath, 0777);
  702. // --- create project database (.dsw)
  703. writeProjectFile(filepath);
  704. // --- create all targets (.dsp)
  705. writeTargetFiles(filepath);
  706. // --- create a valid config.h
  707. sprintf(filepath, "%s/ide/VisualC6/config.h", rootDir);
  708. writeConfigH(filepath);
  709. // --- close and finish
  710. return 0;
  711. }
  712. };
  713. // This creates all files needed to compile FLTK using VisualC++ 6.0 and up.
  714. // create directory structure ide/VisualC6
  715. // create .dsw file
  716. // create .dsp files
  717. // create config.h
  718. // create icons
  719. void generate_fltk_VisualC6_support(const char *filename, const char *targetpath)
  720. {
  721. Fl_Preferences *db =
  722. new Fl_Preferences(filename, "fltk.org", 0);
  723. VisualC6_IDE ide(*db, targetpath);
  724. ide.write();
  725. delete db;
  726. return;
  727. }
  728. extern int exit_early;
  729. class Fl_IDE_VisualC_Plugin : public Fl_Commandline_Plugin
  730. {
  731. public:
  732. Fl_IDE_VisualC_Plugin() : Fl_Commandline_Plugin(name()) { }
  733. const char *name() { return "ideVisualC.fluid.fltk.org"; }
  734. const char *help() { return
  735. " --dbvisualc6 <dbname> <targetpath> : create IDE files for MS IDE's able to read VC6 projects"; }
  736. int arg(int argc, char **argv, int &i) {
  737. if (argc>=i+1 && strcmp(argv[i], "--dbvisualc6")==0) {
  738. if (argc>=i+3 && argv[i+1][0]!='-' && argv[i+2][0]!='-') {
  739. fprintf(stderr, "Creating VisualC++ 6.0 IDE from %s in %s\n", argv[i+1], argv[i+2]);
  740. exit_early = 1;
  741. generate_fltk_VisualC6_support(argv[i+1], argv[i+2]);
  742. i = i+3;
  743. return 3;
  744. } else {
  745. fprintf(stderr, "Missing argument: --dbvisualc6 <dbname> <targetpath>\n");
  746. return 1;
  747. }
  748. }
  749. return 0;
  750. }
  751. int test(const char *a1, const char *a2, const char *a3) {
  752. generate_fltk_VisualC6_support(a1, a2);
  753. return 0;
  754. }
  755. };
  756. Fl_IDE_VisualC_Plugin IDE_VisualC_Plugin;
  757. //
  758. // End of "$Id: ide_visualc.cxx 7674 2010-07-10 14:01:22Z AlbrechtS $".
  759. //