From 6809ee4b8eb48911f946bad77458fbf1a47f45be Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 3 Jan 2000 13:45:00 +0000 Subject: [PATCH] makegen program for makefile generation for the samples git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5196 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- utils/makegen/Makefile.in | 13 ++ utils/makegen/makefile.b32 | 10 ++ utils/makegen/makefile.bcc | 14 ++ utils/makegen/makefile.dos | 10 ++ utils/makegen/makefile.g95 | 10 ++ utils/makegen/makefile.sc | 37 ++++++ utils/makegen/makefile.sl | 14 ++ utils/makegen/makefile.twn | 35 +++++ utils/makegen/makefile.unx | 23 ++++ utils/makegen/makefile.vc | 11 ++ utils/makegen/makefile.wat | 11 ++ utils/makegen/makegen.cpp | 183 +++++++++++++++++++++++++++ utils/makegen/templates/Makefile.in | 13 ++ utils/makegen/templates/makefile.b32 | 10 ++ utils/makegen/templates/makefile.bcc | 14 ++ utils/makegen/templates/makefile.dos | 10 ++ utils/makegen/templates/makefile.g95 | 10 ++ utils/makegen/templates/makefile.sc | 37 ++++++ utils/makegen/templates/makefile.sl | 14 ++ utils/makegen/templates/makefile.twn | 35 +++++ utils/makegen/templates/makefile.unx | 23 ++++ utils/makegen/templates/makefile.vc | 11 ++ utils/makegen/templates/makefile.wat | 11 ++ 23 files changed, 559 insertions(+) create mode 100644 utils/makegen/Makefile.in create mode 100644 utils/makegen/makefile.b32 create mode 100644 utils/makegen/makefile.bcc create mode 100644 utils/makegen/makefile.dos create mode 100644 utils/makegen/makefile.g95 create mode 100644 utils/makegen/makefile.sc create mode 100644 utils/makegen/makefile.sl create mode 100644 utils/makegen/makefile.twn create mode 100644 utils/makegen/makefile.unx create mode 100644 utils/makegen/makefile.vc create mode 100644 utils/makegen/makefile.wat create mode 100644 utils/makegen/makegen.cpp create mode 100644 utils/makegen/templates/Makefile.in create mode 100644 utils/makegen/templates/makefile.b32 create mode 100644 utils/makegen/templates/makefile.bcc create mode 100644 utils/makegen/templates/makefile.dos create mode 100644 utils/makegen/templates/makefile.g95 create mode 100644 utils/makegen/templates/makefile.sc create mode 100644 utils/makegen/templates/makefile.sl create mode 100644 utils/makegen/templates/makefile.twn create mode 100644 utils/makegen/templates/makefile.unx create mode 100644 utils/makegen/templates/makefile.vc create mode 100644 utils/makegen/templates/makefile.wat diff --git a/utils/makegen/Makefile.in b/utils/makegen/Makefile.in new file mode 100644 index 0000000000..dff61a10a6 --- /dev/null +++ b/utils/makegen/Makefile.in @@ -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 index 0000000000..ff83c3af27 --- /dev/null +++ b/utils/makegen/makefile.b32 @@ -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 index 0000000000..9d63ff45b1 --- /dev/null +++ b/utils/makegen/makefile.bcc @@ -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 index 0000000000..f5ecad62fd --- /dev/null +++ b/utils/makegen/makefile.dos @@ -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 index 0000000000..ed4db1b1c3 --- /dev/null +++ b/utils/makegen/makefile.g95 @@ -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 index 0000000000..46ba9df0d6 --- /dev/null +++ b/utils/makegen/makefile.sc @@ -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 index 0000000000..dac25e37e7 --- /dev/null +++ b/utils/makegen/makefile.sl @@ -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 index 0000000000..6e4c8a2a5a --- /dev/null +++ b/utils/makegen/makefile.twn @@ -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 index 0000000000..dd1b7c5d1a --- /dev/null +++ b/utils/makegen/makefile.unx @@ -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 index 0000000000..26bb9ba186 --- /dev/null +++ b/utils/makegen/makefile.vc @@ -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 index 0000000000..af964802ee --- /dev/null +++ b/utils/makegen/makefile.wat @@ -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 index 0000000000..6a49d4e5cc --- /dev/null +++ b/utils/makegen/makegen.cpp @@ -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 +// Licence: wxWindows license +///////////////////////////////////////////////////////////////////////////// + +// ============================================================================ +// declarations +// ============================================================================ + +#if wxUSE_GUI + #error "This is a console mode program and must be linked with wxBase." +#endif + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +#include +#include +#include +#include +#include +#include +#include +#include + +// ---------------------------------------------------------------------------- +// 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 index 0000000000..409d0eda73 --- /dev/null +++ b/utils/makegen/templates/Makefile.in @@ -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 index 0000000000..17b836469c --- /dev/null +++ b/utils/makegen/templates/makefile.b32 @@ -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 index 0000000000..36c2c67f36 --- /dev/null +++ b/utils/makegen/templates/makefile.bcc @@ -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 index 0000000000..5f602282a7 --- /dev/null +++ b/utils/makegen/templates/makefile.dos @@ -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 index 0000000000..41e1be06fd --- /dev/null +++ b/utils/makegen/templates/makefile.g95 @@ -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 index 0000000000..550a189653 --- /dev/null +++ b/utils/makegen/templates/makefile.sc @@ -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 index 0000000000..6074588ee2 --- /dev/null +++ b/utils/makegen/templates/makefile.sl @@ -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 index 0000000000..12282064a5 --- /dev/null +++ b/utils/makegen/templates/makefile.twn @@ -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 index 0000000000..000f6c3d95 --- /dev/null +++ b/utils/makegen/templates/makefile.unx @@ -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 index 0000000000..cfb4e28556 --- /dev/null +++ b/utils/makegen/templates/makefile.vc @@ -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 index 0000000000..cabb5193e6 --- /dev/null +++ b/utils/makegen/templates/makefile.wat @@ -0,0 +1,11 @@ +# Purpose: makefile for #NAME example (Watcom) +# Created: #DATE + +WXDIR = $(%WXWIN) + +PROGRAM = #NAME +OBJECTS = $(PROGRAM).obj + +!include $(WXDIR)\src\makeprog.wat + + -- 2.45.2