// // "$Id: ide_maketools.cxx 7169 2010-02-27 22:38:25Z matt $" // // IDE and Build FIle generation for the Fast Light Tool Kit (FLTK). // // Copyright 1998-2009 by Bill Spitzak and others. // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU Library General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 // USA. // // Please report all bugs and problems on the following page: // // http://www.fltk.org/str.php // /* MAKETOOLS IDE FILES FLTK builds easily from the command line using the sequence: > autoconfig > ./configure > make > test/Demo > sudo make install This module creates all "Makefile" files that are required to create the project. Other files, for example "config.h.in" or "makeinclude.in", are not created. We expect them to exist already. This may change in later releases and for stand-alone application support. The Makefiles are pretty straight forward. Just read the source code below. There are some exceptions, particularly for handling OpenGL that are hard coded into the sources below. */ #include "ide_support.h" #include #include #include "../src/flstring.h" #include "Fl_Type.h" /* * This class creates all Makefile/autoconf files. */ class Maketools_IDE { char *rootDir; char projectName[80]; Fl_IDE_Prefs tgtAppsDB; int nTgtApps; Fl_IDE_Prefs tgtLibsDB; int nTgtLibs; Fl_IDE_Prefs tgtTestsDB; int nTgtTests; Fl_Preferences filesDB; int nFiles; Fl_Preferences ideDB; public: Maketools_IDE(Fl_Preferences &db, const char *rootDirA) : rootDir(strdup(rootDirA)), tgtAppsDB(db, "targets/apps"), tgtLibsDB(db, "targets/libs"), tgtTestsDB(db, "targets/tests"), filesDB(db, "files"), ideDB(db, "ide/Maketools") { db.get("projectName", projectName, "Unnamed", 80); nTgtApps = tgtAppsDB.groups(); nTgtLibs = tgtLibsDB.groups(); nTgtTests = tgtTestsDB.groups(); nFiles = filesDB.groups(); } ~Maketools_IDE() { if (rootDir) free(rootDir); } int fput_copyright(const char *str, FILE *f) { fputs("#\n", f); fputs("# \"$Id:$\"\n", f); fputs("#\n", f); fprintf(f, "# %s\n", str); fputs("#\n", f); fputs("# Copyright 1998-2010 by Bill Spitzak and others.\n", f); fputs("#\n", f); fputs("# This library is free software; you can redistribute it and/or\n", f); fputs("# modify it under the terms of the GNU Library General Public\n", f); fputs("# License as published by the Free Software Foundation; either\n", f); fputs("# version 2 of the License, or (at your option) any later version.\n", f); fputs("#\n", f); fputs("# This library is distributed in the hope that it will be useful,\n", f); fputs("# but WITHOUT ANY WARRANTY; without even the implied warranty of\n", f); fputs("# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n", f); fputs("# Library General Public License for more details.\n", f); fputs("#\n", f); fputs("# You should have received a copy of the GNU Library General Public\n", f); fputs("# License along with this library; if not, write to the Free Software\n", f); fputs("# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307\n", f); fputs("# USA.\n", f); fputs("#\n", f); fputs("# Please report all bugs and problems on the following page:\n", f); fputs("#\n", f); fputs("# http://www.fltk.org/str.php\n", f); fputs("#\n", f); fputs("\n", f); return 0; } int fput_footer(FILE *f) { fputs("\n", f); fputs("#\n", f); fputs("# End of \"$Id:$\".\n", f); fputs("#\n", f); return 0; } int writeMainMakefile(const char *filepath) { FILE *f = fopen(filepath, "wb"); fput_copyright("Top-level makefile for the Fast Light Tool Kit (FLTK).", f); fputs("include makeinclude\n", f); fputs("\n", f); fputs("DIRS = $(IMAGEDIRS) src $(CAIRODIR) fluid test documentation\n", f); fputs("\n", f); fputs("all: makeinclude fltk-config\n", f); fputs("\tfor dir in $(DIRS); do\\\n", f); fputs("\t\techo \"=== making $$dir ===\";\\\n", f); fputs("\t\t(cd $$dir; $(MAKE) $(MFLAGS)) || exit 1;\\\n", f); fputs("\tdone\n", f); fputs("\n", f); fputs("install: makeinclude\n", f); fputs("\t-mkdir -p $(DESTDIR)$(bindir)\n", f); fputs("\t$(RM) $(DESTDIR)$(bindir)/fltk-config\n", f); fputs("\t$(INSTALL_SCRIPT) fltk-config $(DESTDIR)$(bindir)\n", f); fputs("\tfor dir in FL $(DIRS); do\\\n", f); fputs("\t\techo \"=== installing $$dir ===\";\\\n", f); fputs("\t\t(cd $$dir; $(MAKE) $(MFLAGS) install) || exit 1;\\\n", f); fputs("\tdone\n", f); fputs("\n", f); fputs("install-desktop: makeinclude\n", f); fputs("\tcd documentation; $(MAKE) $(MFLAGS) $(INSTALL_DESKTOP)\n", f); fputs("\tcd fluid; $(MAKE) $(MFLAGS) $(INSTALL_DESKTOP)\n", f); fputs("\tcd test; $(MAKE) $(MFLAGS) $(INSTALL_DESKTOP)\n", f); fputs("\n", f); fputs("uninstall: makeinclude\n", f); fputs("\t$(RM) $(DESTDIR)$(bindir)/fltk-config\n", f); fputs("\tfor dir in FL $(DIRS); do\\\n", f); fputs("\t\techo \"=== uninstalling $$dir ===\";\\\n", f); fputs("\t\t(cd $$dir; $(MAKE) $(MFLAGS) uninstall) || exit 1;\\\n", f); fputs("\tdone\n", f); fputs("\n", f); fputs("uninstall-desktop: makeinclude\n", f); fputs("\tcd documentation; $(MAKE) $(MFLAGS) $(UNINSTALL_DESKTOP)\n", f); fputs("\tcd fluid; $(MAKE) $(MFLAGS) $(UNINSTALL_DESKTOP)\n", f); fputs("\tcd test; $(MAKE) $(MFLAGS) $(UNINSTALL_DESKTOP)\n", f); fputs("\n", f); fputs("depend: makeinclude\n", f); fputs("\tfor dir in $(DIRS); do\\\n", f); fputs("\t\techo \"=== making dependencies in $$dir ===\";\\\n", f); fputs("\t\t(cd $$dir; $(MAKE) $(MFLAGS) depend) || exit 1;\\\n", f); fputs("\tdone\n", f); fputs("\n", f); fputs("clean:\n", f); fputs("\t-$(RM) core *.o\n", f); fputs("\tfor dir in $(DIRS); do\\\n", f); fputs("\t\techo \"=== cleaning $$dir ===\";\\\n", f); fputs("\t\t(cd $$dir; $(MAKE) $(MFLAGS) clean) || exit 1;\\\n", f); fputs("\tdone\n", f); fputs("\n", f); fputs("distclean: clean\n", f); fputs("\t$(RM) config.*\n", f); fputs("\t$(RM) fltk-config fltk.list makeinclude\n", f); fputs("\t$(RM) fltk.spec\n", f); fputs("\t$(RM) FL/Makefile\n", f); fputs("\t$(RM) documentation/*.$(CAT1EXT)\n", f); fputs("\t$(RM) documentation/*.$(CAT3EXT)\n", f); fputs("\t$(RM) documentation/*.$(CAT6EXT)\n", f); fputs("\t$(RM) documentation/fltk.ps\n", f); fputs("\t$(RM) -r documentation/fltk.d\n", f); fputs("\tfor file in test/*.fl; do\\\n", f); fputs("\t\t$(RM) test/`basename $$file .fl`.cxx; \\\n", f); fputs("\t\t$(RM) test/`basename $$file .fl`.h; \\\n", f); fputs("\tdone\n", f); fputs("\n", f); fputs("fltk-config: configure configh.in fltk-config.in\n", f); fputs("\tif test -f config.status; then \\\n", f); fputs("\t\t./config.status --recheck; \\\n", f); fputs("\t\t./config.status; \\\n", f); fputs("\telse \\\n", f); fputs("\t\t./configure; \\\n", f); fputs("\tfi\n", f); fputs("\ttouch config.h\n", f); fputs("\tchmod +x fltk-config\n", f); fputs("\n", f); fputs("makeinclude: configure configh.in makeinclude.in\n", f); fputs("\tif test -f config.status; then \\\n", f); fputs("\t\t./config.status --recheck; \\\n", f); fputs("\t\t./config.status; \\\n", f); fputs("\telse \\\n", f); fputs("\t\t./configure; \\\n", f); fputs("\tfi\n", f); fputs("\ttouch config.h\n", f); fputs("\tchmod +x fltk-config\n", f); fputs("\n", f); fputs("configure: configure.in\n", f); fputs("\tautoconf\n", f); fputs("\n", f); fputs("portable-dist:\n", f); fputs("\tepm -v -s fltk.xpm fltk\n", f); fputs("\n", f); fputs("native-dist:\n", f); fputs("\tepm -v -f native fltk\n", f); fputs("\n", f); fputs("etags:\n", f); fputs("\tetags FL/*.H FL/*.h src/*.cxx src/*.c src/*.h src/xutf8/*.h src/xutf8/*.c cairo/*.cxx fluid/*.h fluid/*.cxx test/*.h test/*.cxx\n", f); fput_footer(f); fclose(f); return 0; } int writeFluidMakefile(const char *filepath) { int i, n; Fl_Preferences::ID fluidID = tgtAppsDB.find_by_key("name", "Fluid"); if (!fluidID) { fprintf(stderr, "Target \"Fluid\" not found!\n"); return -1; } Fl_Target_Prefs fluidDB(fluidID); FILE *f = fopen(filepath, "wb"); fput_copyright("FLUID makefile for the Fast Light Tool Kit (FLTK).", f); fputs("CPPFILES = \\\n", f); Fl_Preferences sourcesDB(fluidDB, "sources"); n = sourcesDB.groups(); for (i=0; i : create all IDE files for a Makefile/autoconf based project\n" " WARNING: --dbmake is not yet implemented completely."; } int arg(int argc, char **argv, int &i) { if (argc>=i+1 && strcmp(argv[i], "--dbxcode3")==0) { if (argc>=i+3 && argv[i+1][0]!='-' && argv[i+2][0]!='-') { fprintf(stderr, "Creating Makefiles from %s in %s\n", argv[i+1], argv[i+2]); exit_early = 1; fprintf(stderr, "WARNING: --dbmake is not yet implemented completely.\n"); generate_fltk_maketools_support(argv[i+1], argv[i+2]); i = i+3; return 3; } else { fprintf(stderr, "Missing argument: --dbmake \n"); return 1; } } return 0; } int test(const char *a1, const char *a2, const char *a3) { generate_fltk_maketools_support(a1, a2); return 0; } }; Fl_IDE_Maketools_Plugin IDE_Maketools_Plugin; // // End of "$Id: ide_maketools.cxx 7169 2010-02-27 22:38:25Z matt $". //