]> git.saurik.com Git - wxWidgets.git/commitdiff
makegen program for makefile generation for the samples
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 3 Jan 2000 13:45:00 +0000 (13:45 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 3 Jan 2000 13:45:00 +0000 (13:45 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5196 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

23 files changed:
utils/makegen/Makefile.in [new file with mode: 0644]
utils/makegen/makefile.b32 [new file with mode: 0644]
utils/makegen/makefile.bcc [new file with mode: 0644]
utils/makegen/makefile.dos [new file with mode: 0644]
utils/makegen/makefile.g95 [new file with mode: 0644]
utils/makegen/makefile.sc [new file with mode: 0644]
utils/makegen/makefile.sl [new file with mode: 0644]
utils/makegen/makefile.twn [new file with mode: 0644]
utils/makegen/makefile.unx [new file with mode: 0644]
utils/makegen/makefile.vc [new file with mode: 0644]
utils/makegen/makefile.wat [new file with mode: 0644]
utils/makegen/makegen.cpp [new file with mode: 0644]
utils/makegen/templates/Makefile.in [new file with mode: 0644]
utils/makegen/templates/makefile.b32 [new file with mode: 0644]
utils/makegen/templates/makefile.bcc [new file with mode: 0644]
utils/makegen/templates/makefile.dos [new file with mode: 0644]
utils/makegen/templates/makefile.g95 [new file with mode: 0644]
utils/makegen/templates/makefile.sc [new file with mode: 0644]
utils/makegen/templates/makefile.sl [new file with mode: 0644]
utils/makegen/templates/makefile.twn [new file with mode: 0644]
utils/makegen/templates/makefile.unx [new file with mode: 0644]
utils/makegen/templates/makefile.vc [new file with mode: 0644]
utils/makegen/templates/makefile.wat [new file with mode: 0644]

diff --git a/utils/makegen/Makefile.in b/utils/makegen/Makefile.in
new file mode 100644 (file)
index 0000000..dff61a1
--- /dev/null
@@ -0,0 +1,13 @@
+# Purpose: makefile for makegen example (UNIX).
+# Created: 2000-01-03
+
+top_srcdir = @top_srcdir@
+top_builddir = ../..
+program_dir = utils/makegen
+
+PROGRAM=makegen
+
+OBJECTS=$(PROGRAM).o
+
+include ../../src/makeprog.env
+
diff --git a/utils/makegen/makefile.b32 b/utils/makegen/makefile.b32
new file mode 100644 (file)
index 0000000..ff83c3a
--- /dev/null
@@ -0,0 +1,10 @@
+# Purpose: makefile for makegen example (BC++ 32bit)
+# Created: 2000-01-03
+
+WXDIR = $(WXWIN)
+
+TARGET=makegen
+OBJECTS = $(TARGET).obj
+
+!include $(WXDIR)\src\makeprog.b32
+
diff --git a/utils/makegen/makefile.bcc b/utils/makegen/makefile.bcc
new file mode 100644 (file)
index 0000000..9d63ff4
--- /dev/null
@@ -0,0 +1,14 @@
+# Purpose: makefile for makegen example (BC++ 16bit)
+# Created: 2000-01-03
+
+!if "$(WXWIN)" == ""
+!error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx
+!endif
+
+WXDIR = $(WXWIN)
+
+TARGET=makegen
+OBJECTS=$(TARGET).obj
+
+!include $(WXDIR)\src\makeprog.bcc
+
diff --git a/utils/makegen/makefile.dos b/utils/makegen/makefile.dos
new file mode 100644 (file)
index 0000000..f5ecad6
--- /dev/null
@@ -0,0 +1,10 @@
+# Purpose: makefile for makegen example (VC++ 1.5x)
+# Created: 2000-01-03
+
+WXDIR = $(WXWIN)
+
+TARGET=makegen
+OBJECTS=$(TARGET).obj
+
+!include $(WXDIR)\src\makeprog.msc
+
diff --git a/utils/makegen/makefile.g95 b/utils/makegen/makefile.g95
new file mode 100644 (file)
index 0000000..ed4db1b
--- /dev/null
@@ -0,0 +1,10 @@
+# Purpose: makefile for makegen example (Cygwin/Mingw32)
+# Created: #03.01.00
+
+WXDIR = ../..
+
+TARGET=makegen
+OBJECTS = $(TARGET).o
+
+include $(WXDIR)\src\makeprog.g95
+
diff --git a/utils/makegen/makefile.sc b/utils/makegen/makefile.sc
new file mode 100644 (file)
index 0000000..46ba9df
--- /dev/null
@@ -0,0 +1,37 @@
+# Purpose: makefile for makegen example (Symantec C++)
+# Created: 2000-01-03
+
+WXDIR = $(WXWIN)
+WXLIB = $(WXDIR)\lib\wx.lib
+INCDIR = $(WXDIR)\include
+INCLUDE=$(INCDIR)
+TARGET=makegen
+
+include $(WXDIR)\src\makesc.env
+
+makegen.exe: makegen.obj $(DEFFILE) makegen.res
+       *$(CC) $(LDFLAGS) -o$@ $** $(LIBS)
+    *$(RC) -k makegen.res
+
+sc32.def:
+     echo EXETYPE NT > sc32.def
+     echo SUBSYSTEM WINDOWS >> sc32.def
+
+sc16.def:
+     echo NAME $(TARGET) > sc16.def
+     echo EXETYPE WINDOWS >> sc16.def
+     echo STUB         'WINSTUB.EXE' >> sc16.def
+     echo CODE         PRELOAD MOVEABLE DISCARDABLE >> sc16.def
+     echo DATA         PRELOAD MOVEABLE MULTIPLE >> sc16.def
+     echo HEAPSIZE     1024 >> sc16.def
+     echo STACKSIZE    8192 >> sc16.def
+
+clean:
+    -del *.obj
+       -del *.exe
+       -del *.res
+       -del *.map
+       -del *.rws
+    -del sc32.def
+    -del sc16.def
+
diff --git a/utils/makegen/makefile.sl b/utils/makegen/makefile.sl
new file mode 100644 (file)
index 0000000..dac25e3
--- /dev/null
@@ -0,0 +1,14 @@
+# Purpose: makefile for makegen example (Salford C++)
+# Created: 2000-01-03
+
+PROGRAM = makegen
+OBJECTS = $(PROGRAM).obj
+
+include ..\..\src\makeprog.sl
+
+all:        wx $(TARGET)
+
+wx:
+    cd $(WXDIR)\src\msw ^ mk32 -f makefile.sl all
+    cd $(WXDIR)\utils\makegen
+
diff --git a/utils/makegen/makefile.twn b/utils/makegen/makefile.twn
new file mode 100644 (file)
index 0000000..6e4c8a2
--- /dev/null
@@ -0,0 +1,35 @@
+# Purpose: makefile for makegen example (TWIN)
+# Created: 2000-01-03
+
+WXDIR = ../..
+
+# All common UNIX compiler flags and options are now in
+# this central makefile.
+include $(WXDIR)/src/maketwin.env
+
+OBJECTS = $(OBJDIR)/makegen.$(OBJSUFF) $(OBJDIR)/makegen.$(OBJSUFF)
+
+all:    $(OBJDIR) makegen$(GUISUFFIX)$(EXESUFF)
+
+wx:
+
+$(OBJDIR):
+       mkdir $(OBJDIR)
+
+makegen$(GUISUFFIX)$(EXESUFF): $(OBJECTS) $(WXLIB)
+       $(CC) $(LDFLAGS) -o makegen$(GUISUFFIX)$(EXESUFF) $(OBJECTS) $(LDLIBS)
+
+$(OBJDIR)/makegen.$(OBJSUFF):  makegen.$(SRCSUFF)
+       $(CC) -c $(CPPFLAGS) -o $@ makegen.$(SRCSUFF)
+
+makegen.c:  makegen.rc
+       $(RESCOMP) $(RCINPUTSWITCH) makegen.rc $(RCOUTPUTSWITCH) makegen.c $(RESFLAGS)
+
+$(OBJDIR)/makegen.$(OBJSUFF):  makegen.c
+       $(CC) -c $(CPPFLAGS) -o $@ makegen.c
+
+#$(OBJDIR)/makegen.o:  makegen.rc
+#      $(RESCOMP) $(RCINPUTSWITCH) makegen.rc $(RCOUTPUTSWITCH) $(OBJDIR)/makegen.o $(RESFLAGS)
+
+clean:
+       rm -f $(OBJECTS) makegen$(GUISUFFIX).exe core *.rsc *.res
diff --git a/utils/makegen/makefile.unx b/utils/makegen/makefile.unx
new file mode 100644 (file)
index 0000000..dd1b7c5
--- /dev/null
@@ -0,0 +1,23 @@
+# Purpose: makefile for makegen example (Unix)
+# Created: 2000-01-03
+
+CC = gcc
+
+PROGRAM = makegen
+
+OBJECTS = $(PROGRAM).o
+
+# implementation
+
+.SUFFIXES:     .o .cpp
+
+.cpp.o :
+       $(CC) -c `wx-config --cflags` -o $@ $<
+
+all:    $(PROGRAM)
+
+$(PROGRAM):    $(OBJECTS)
+       $(CC) -o $(PROGRAM) $(OBJECTS) `wx-config --libs`
+
+clean:
+       rm -f *.o $(PROGRAM)
diff --git a/utils/makegen/makefile.vc b/utils/makegen/makefile.vc
new file mode 100644 (file)
index 0000000..26bb9ba
--- /dev/null
@@ -0,0 +1,11 @@
+# Purpose: makefile for makegen example (VC++ 32bit)
+# Created: 2000-01-03
+
+# Set WXDIR for your system
+WXDIR = $(WXWIN)
+
+PROGRAM=makegen
+OBJECTS = $(PROGRAM).obj
+
+!include $(WXDIR)\src\makeprog.vc
+
diff --git a/utils/makegen/makefile.wat b/utils/makegen/makefile.wat
new file mode 100644 (file)
index 0000000..af96480
--- /dev/null
@@ -0,0 +1,11 @@
+# Purpose: makefile for makegen example (Watcom)
+# Created: 2000-01-03
+
+WXDIR = $(%WXWIN)
+
+PROGRAM = makegen
+OBJECTS = $(PROGRAM).obj
+
+!include $(WXDIR)\src\makeprog.wat
+
+
diff --git a/utils/makegen/makegen.cpp b/utils/makegen/makegen.cpp
new file mode 100644 (file)
index 0000000..6a49d4e
--- /dev/null
@@ -0,0 +1,183 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        utils/makegen/makegen.cpp
+// Purpose:     a tool to generate the makefiles for samples
+// Author:      Vadim Zeitlin
+// Modified by:
+// Created:     03.01.00
+// RCS-ID:      $Id$
+// Copyright:   (c) 2000 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
+// Licence:     wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+// ============================================================================
+// declarations
+// ============================================================================
+
+#if wxUSE_GUI
+    #error "This is a console mode program and must be linked with wxBase."
+#endif
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+#include <wx/string.h>
+#include <wx/file.h>
+#include <wx/ffile.h>
+#include <wx/app.h>
+#include <wx/log.h>
+#include <wx/dir.h>
+#include <wx/textfile.h>
+#include <wx/datetime.h>
+
+// ----------------------------------------------------------------------------
+// the application class
+// ----------------------------------------------------------------------------
+
+class MakeGenApp : public wxApp
+{
+public:
+    virtual bool OnInit();
+
+    virtual int OnRun();
+
+private:
+    void Usage();               // give the usage message
+
+    bool GenerateMakefile(const wxString& filename);
+
+    wxString m_sampleName,      // the name of the sample
+             m_dirname,         // directory with the template files
+             m_outputDir;       // directory to output files to
+};
+
+IMPLEMENT_APP(MakeGenApp);
+
+// ============================================================================
+// implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// MakeGenApp
+// ----------------------------------------------------------------------------
+
+void MakeGenApp::Usage()
+{
+    wxLogError(_T("Usage: %s [-o output_dir] sample_name"), argv[0]);
+}
+
+bool MakeGenApp::GenerateMakefile(const wxString& filename)
+{
+    wxTextFile fileIn(m_dirname + filename);
+    if ( !fileIn.Open() )
+    {
+        wxLogError(_T("Makefile '%s' couldn't be generated."), filename.c_str());
+
+        return FALSE;
+    }
+
+    wxFFile fileOut(m_outputDir + filename, "w");
+    if ( !fileOut.IsOpened() )
+    {
+        wxLogError(_T("Makefile '%s' couldn't be generated."), filename.c_str());
+
+        return FALSE;
+    }
+
+    size_t count = fileIn.GetLineCount();
+    for ( size_t n = 0; n < count; n++ )
+    {
+        wxString line = fileIn[n];
+
+        line.Replace(_T("#DATE"), wxDateTime::Now().FormatISODate());
+        line.Replace(_T("#NAME"), m_sampleName);
+
+        fileOut.Write(line + _T('\n'));
+    }
+
+    return TRUE;
+}
+
+bool MakeGenApp::OnInit()
+{
+    // parse the cmd line
+    if ( (argc == 1) || (argc == 3) ||
+         (argv[1][0] == _T('-') && argv[1][1] != _T('o')) ||
+         (argc == 2 && argv[1][0] == _T('-')) )
+    {
+        Usage();
+
+        return FALSE;
+    }
+
+    m_sampleName = argv[1];
+    if ( m_sampleName[0u] == _T('-') )
+    {
+        m_outputDir = argv[2];
+        if ( !wxEndsWithPathSeparator(m_outputDir) )
+        {
+            m_outputDir += _T('/');
+        }
+
+        m_sampleName = argv[3];
+    }
+
+    return TRUE;
+}
+
+int MakeGenApp::OnRun()
+{
+    m_dirname = wxGetenv(_T("MAKEGEN_PATH"));
+    if ( !m_dirname )
+    {
+        m_dirname = wxGetCwd();
+    }
+
+    if ( !wxEndsWithPathSeparator(m_dirname) )
+    {
+        m_dirname += _T('/');
+    }
+
+    m_dirname += _T("templates");
+
+    wxDir dir(m_dirname);
+
+    m_dirname += _T('/');
+
+    if ( !dir.IsOpened() )
+    {
+        wxLogError(_T("Aborting generating the makefiles."));
+
+        return 1;
+    }
+
+    wxString filename;
+    size_t n = 0;
+    bool cont = dir.GetFirst(&filename, _T("?akefile.*"), wxDIR_FILES);
+    while ( cont )
+    {
+        n++;
+
+        if ( !GenerateMakefile(filename) )
+        {
+            wxLogError(_T("Error during makefile generation, aborting."));
+
+            return 2;
+        }
+
+        cont = dir.GetNext(&filename);
+    }
+
+    if ( n )
+    {
+        wxLogVerbose(_T("Successfully generated %u makefiles in '%s'."),
+                     n, m_outputDir.c_str());
+    }
+    else
+    {
+        wxLogWarning(_T("No makefiles found: either set MAKEGEN_PATH variable "
+                        "or run the program from its directory"));
+    }
+
+    return 0;
+}
diff --git a/utils/makegen/templates/Makefile.in b/utils/makegen/templates/Makefile.in
new file mode 100644 (file)
index 0000000..409d0ed
--- /dev/null
@@ -0,0 +1,13 @@
+# Purpose: makefile for #NAME example (UNIX).
+# Created: #DATE
+
+top_srcdir = @top_srcdir@
+top_builddir = ../..
+program_dir = samples/#NAME
+
+PROGRAM=#NAME
+
+OBJECTS=$(PROGRAM).o
+
+include ../../src/makeprog.env
+
diff --git a/utils/makegen/templates/makefile.b32 b/utils/makegen/templates/makefile.b32
new file mode 100644 (file)
index 0000000..17b8364
--- /dev/null
@@ -0,0 +1,10 @@
+# Purpose: makefile for #NAME example (BC++ 32bit)
+# Created: #DATE
+
+WXDIR = $(WXWIN)
+
+TARGET=#NAME
+OBJECTS = $(TARGET).obj
+
+!include $(WXDIR)\src\makeprog.b32
+
diff --git a/utils/makegen/templates/makefile.bcc b/utils/makegen/templates/makefile.bcc
new file mode 100644 (file)
index 0000000..36c2c67
--- /dev/null
@@ -0,0 +1,14 @@
+# Purpose: makefile for #NAME example (BC++ 16bit)
+# Created: #DATE
+
+!if "$(WXWIN)" == ""
+!error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx
+!endif
+
+WXDIR = $(WXWIN)
+
+TARGET=#NAME
+OBJECTS=$(TARGET).obj
+
+!include $(WXDIR)\src\makeprog.bcc
+
diff --git a/utils/makegen/templates/makefile.dos b/utils/makegen/templates/makefile.dos
new file mode 100644 (file)
index 0000000..5f60228
--- /dev/null
@@ -0,0 +1,10 @@
+# Purpose: makefile for #NAME example (VC++ 1.5x)
+# Created: #DATE
+
+WXDIR = $(WXWIN)
+
+TARGET=#NAME
+OBJECTS=$(TARGET).obj
+
+!include $(WXDIR)\src\makeprog.msc
+
diff --git a/utils/makegen/templates/makefile.g95 b/utils/makegen/templates/makefile.g95
new file mode 100644 (file)
index 0000000..41e1be0
--- /dev/null
@@ -0,0 +1,10 @@
+# Purpose: makefile for #NAME example (Cygwin/Mingw32)
+# Created: #03.01.00
+
+WXDIR = ../..
+
+TARGET=#NAME
+OBJECTS = $(TARGET).o
+
+include $(WXDIR)\src\makeprog.g95
+
diff --git a/utils/makegen/templates/makefile.sc b/utils/makegen/templates/makefile.sc
new file mode 100644 (file)
index 0000000..550a189
--- /dev/null
@@ -0,0 +1,37 @@
+# Purpose: makefile for #NAME example (Symantec C++)
+# Created: #DATE
+
+WXDIR = $(WXWIN)
+WXLIB = $(WXDIR)\lib\wx.lib
+INCDIR = $(WXDIR)\include
+INCLUDE=$(INCDIR)
+TARGET=#NAME
+
+include $(WXDIR)\src\makesc.env
+
+#NAME.exe: #NAME.obj $(DEFFILE) #NAME.res
+       *$(CC) $(LDFLAGS) -o$@ $** $(LIBS)
+    *$(RC) -k #NAME.res
+
+sc32.def:
+     echo EXETYPE NT > sc32.def
+     echo SUBSYSTEM WINDOWS >> sc32.def
+
+sc16.def:
+     echo NAME $(TARGET) > sc16.def
+     echo EXETYPE WINDOWS >> sc16.def
+     echo STUB         'WINSTUB.EXE' >> sc16.def
+     echo CODE         PRELOAD MOVEABLE DISCARDABLE >> sc16.def
+     echo DATA         PRELOAD MOVEABLE MULTIPLE >> sc16.def
+     echo HEAPSIZE     1024 >> sc16.def
+     echo STACKSIZE    8192 >> sc16.def
+
+clean:
+    -del *.obj
+       -del *.exe
+       -del *.res
+       -del *.map
+       -del *.rws
+    -del sc32.def
+    -del sc16.def
+
diff --git a/utils/makegen/templates/makefile.sl b/utils/makegen/templates/makefile.sl
new file mode 100644 (file)
index 0000000..6074588
--- /dev/null
@@ -0,0 +1,14 @@
+# Purpose: makefile for #NAME example (Salford C++)
+# Created: #DATE
+
+PROGRAM = #NAME
+OBJECTS = $(PROGRAM).obj
+
+include ..\..\src\makeprog.sl
+
+all:        wx $(TARGET)
+
+wx:
+    cd $(WXDIR)\src\msw ^ mk32 -f makefile.sl all
+    cd $(WXDIR)\samples\#NAME
+
diff --git a/utils/makegen/templates/makefile.twn b/utils/makegen/templates/makefile.twn
new file mode 100644 (file)
index 0000000..1228206
--- /dev/null
@@ -0,0 +1,35 @@
+# Purpose: makefile for #NAME example (TWIN)
+# Created: #DATE
+
+WXDIR = ../..
+
+# All common UNIX compiler flags and options are now in
+# this central makefile.
+include $(WXDIR)/src/maketwin.env
+
+OBJECTS = $(OBJDIR)/#NAME.$(OBJSUFF) $(OBJDIR)/#NAME.$(OBJSUFF)
+
+all:    $(OBJDIR) #NAME$(GUISUFFIX)$(EXESUFF)
+
+wx:
+
+$(OBJDIR):
+       mkdir $(OBJDIR)
+
+#NAME$(GUISUFFIX)$(EXESUFF):   $(OBJECTS) $(WXLIB)
+       $(CC) $(LDFLAGS) -o #NAME$(GUISUFFIX)$(EXESUFF) $(OBJECTS) $(LDLIBS)
+
+$(OBJDIR)/#NAME.$(OBJSUFF):    #NAME.$(SRCSUFF)
+       $(CC) -c $(CPPFLAGS) -o $@ #NAME.$(SRCSUFF)
+
+#NAME.c:  #NAME.rc
+       $(RESCOMP) $(RCINPUTSWITCH) #NAME.rc $(RCOUTPUTSWITCH) #NAME.c $(RESFLAGS)
+
+$(OBJDIR)/#NAME.$(OBJSUFF):    #NAME.c
+       $(CC) -c $(CPPFLAGS) -o $@ #NAME.c
+
+#$(OBJDIR)/#NAME.o:  #NAME.rc
+#      $(RESCOMP) $(RCINPUTSWITCH) #NAME.rc $(RCOUTPUTSWITCH) $(OBJDIR)/#NAME.o $(RESFLAGS)
+
+clean:
+       rm -f $(OBJECTS) #NAME$(GUISUFFIX).exe core *.rsc *.res
diff --git a/utils/makegen/templates/makefile.unx b/utils/makegen/templates/makefile.unx
new file mode 100644 (file)
index 0000000..000f6c3
--- /dev/null
@@ -0,0 +1,23 @@
+# Purpose: makefile for #NAME example (Unix)
+# Created: #DATE
+
+CC = gcc
+
+PROGRAM = #NAME
+
+OBJECTS = $(PROGRAM).o
+
+# implementation
+
+.SUFFIXES:     .o .cpp
+
+.cpp.o :
+       $(CC) -c `wx-config --cflags` -o $@ $<
+
+all:    $(PROGRAM)
+
+$(PROGRAM):    $(OBJECTS)
+       $(CC) -o $(PROGRAM) $(OBJECTS) `wx-config --libs`
+
+clean:
+       rm -f *.o $(PROGRAM)
diff --git a/utils/makegen/templates/makefile.vc b/utils/makegen/templates/makefile.vc
new file mode 100644 (file)
index 0000000..cfb4e28
--- /dev/null
@@ -0,0 +1,11 @@
+# Purpose: makefile for #NAME example (VC++ 32bit)
+# Created: #DATE
+
+# Set WXDIR for your system
+WXDIR = $(WXWIN)
+
+PROGRAM=#NAME
+OBJECTS = $(PROGRAM).obj
+
+!include $(WXDIR)\src\makeprog.vc
+
diff --git a/utils/makegen/templates/makefile.wat b/utils/makegen/templates/makefile.wat
new file mode 100644 (file)
index 0000000..cabb519
--- /dev/null
@@ -0,0 +1,11 @@
+# Purpose: makefile for #NAME example (Watcom)
+# Created: #DATE
+
+WXDIR = $(%WXWIN)
+
+PROGRAM = #NAME
+OBJECTS = $(PROGRAM).obj
+
+!include $(WXDIR)\src\makeprog.wat
+
+