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
This commit is contained in:
Vadim Zeitlin 2000-01-03 13:45:00 +00:00
parent 273b7ed9d0
commit 6809ee4b8e
23 changed files with 559 additions and 0 deletions

13
utils/makegen/Makefile.in Normal file
View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

37
utils/makegen/makefile.sc Normal file
View File

@ -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

14
utils/makegen/makefile.sl Normal file
View File

@ -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

View File

@ -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

View File

@ -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)

11
utils/makegen/makefile.vc Normal file
View File

@ -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

View File

@ -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

183
utils/makegen/makegen.cpp Normal file
View File

@ -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;
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -0,0 +1,11 @@
# Purpose: makefile for #NAME example (Watcom)
# Created: #DATE
WXDIR = $(%WXWIN)
PROGRAM = #NAME
OBJECTS = $(PROGRAM).obj
!include $(WXDIR)\src\makeprog.wat