See ChangeLog entry 19990518-23:15 David G. Holm <dholm@jsd-llc.com>

This commit is contained in:
David G. Holm
1999-05-19 04:19:53 +00:00
parent 4807d53a0e
commit ed21ac4d0f
5 changed files with 125 additions and 50 deletions

View File

@@ -1,3 +1,16 @@
19990518-23:15 David G. Holm <dholm@jsd-llc.com>
* makefile.b31
- Put all common BCC options in c_opt macro to make it easy to switch to
C++ by simply adding -P to c_opt and changing -P- on fixflex line to -P+
- I left the makefile creating Harbour using C, because there was no change
in harbour.exe size or behaviour with C++ (Borland C++ 3.1)
* source/compiler/fixflex.c
- Modified to work with both C and C++ versions of Harbour
+ tests/working/bldpexe.bat
- Copy of buildexe.bat with -P option to compile with C++
+ tests/working/hbp.bat
- Copy of hb.bat that calls bldpexe.bat to use C++
19990519-02:45 Ryszard Glab <rglab@imid.med.pl>
* source/compiler/harbour.y

View File

@@ -10,11 +10,14 @@
.path.obj = obj
.path.prg = source\rtl
c_opt = -mh -O2 -I.\include
PROJECT: harbour.lib hbtools.lib terminal.lib libs\win16\terminal.lib harbour.exe
harbour.lib : arrays.obj asort.obj classes.obj codebloc.obj dates.obj \
dynsym.obj environ.obj error.obj \
errorapi.obj errorsys.obj extend.obj files.obj itemapi.obj \
errorapi.obj errorsys.obj extend.obj \
files.obj initsymb.obj itemapi.obj \
math.obj objfunc.obj \
set.obj strings.obj strcmp.obj symbols.obj tclass.obj transfrm.obj
@@ -26,9 +29,9 @@ terminal.lib : console.obj
libs\win16\terminal.lib : console.obj
console.obj : console.c extend.h types.h
bcc -c -mh -O2 -I.\include -o$@ source\rtl\console.c
bcc -c $(c_opt) -o$@ source\rtl\console.c
tlib .\libs\b16\terminal.lib -+$@,,
# bcc -c -mh -O2 -DWINDOWS -I.\include -o$@ source\rtl\console.c
# bcc -c -DWINDOWS $(c_opt) -o$@ source\rtl\console.c
# tlib .\libs\win16\terminal.lib -+$@,,
arrays.obj : arrays.c extend.h types.h
@@ -37,7 +40,7 @@ classes.obj : classes.c extend.h types.h
codebloc.obj : codebloc.c extend.h types.h
dates.obj : dates.c extend.h types.h dates.h set.h
datesx.obj : source\tools\datesx.c extend.h types.h
debug.obj : source\tools\debug.c extend.h types.h
debug.obj : source\tools\debug.c extend.h types.h
dynsym.obj : source\vm\dynsym.c extend.h types.h
environ.obj : environ.c extend.h types.h
error.obj : error.prg extend.h types.h init.h harbour.exe
@@ -46,7 +49,8 @@ errorsys.obj : errorsys.prg extend.h types.h init.h harbour.exe
extend.obj : extend.c extend.h types.h
files.obj : extend.c extend.h types.h
genobj.obj : source\tools\genobj.c extend.h types.h
io.obj : source\tools\io.c extend.h types.h
io.obj : source\tools\io.c extend.h types.h
initsymb.obj : source\vm\initsymb.c extend.h types.h
itemapi.obj : itemapi.c extend.h types.h
math.obj : math.c extend.h types.h
mathx.obj : source\tools\mathx.c extend.h types.h
@@ -56,33 +60,33 @@ strcmp.obj : strcmp.c extend.h types.h
stringp.obj : source\tools\stringp.prg extend.h types.h init.h harbour.exe
strings.obj : strings.c extend.h types.h
stringsx.obj : source\tools\stringsx.c extend.h types.h
symbols.obj : symbols.asm
symbols.obj : symbols.asm
tclass.obj : tclass.prg extend.h types.h init.h harbour.exe
transfrm.obj : transfrm.c extend.h types.h
{source\tools}.prg{obj}.obj:
bin\harbour $< /n /osource\tools
bcc -c -mh -O2 -I.\include -o$@ $*.c
bcc -c $(c_opt) -o$@ $*.c
tlib .\libs\b16\hbtools.lib -+$@,,
.prg.obj:
bin\harbour $< /n /osource\rtl
bcc -c -mh -O2 -I.\include -o$@ $*.c
bcc -c $(c_opt) -o$@ $*.c
tlib .\libs\b16\harbour.lib -+$@,,
{source\vm}.c{obj}.obj:
bcc -c -mh -O2 -I.\include -o$@ $<
bcc -c $(c_opt) -o$@ $<
tlib .\libs\b16\harbour.lib -+$@,,
{source\tools}.c{obj}.obj:
bcc -c -mh -O2 -I.\include -o$@ $<
bcc -c $(c_opt) -o$@ $<
tlib .\libs\b16\hbtools.lib -+$@,,
{source\compiler}.c{obj}.obj:
bcc -c -mh -O2 -I.\include;source\compiler -o$@ $<
bcc -c $(c_opt) -Isource\compiler -o$@ $<
.c.obj:
bcc -c -mh -O2 -I.\include -o$@ $<
bcc -c $(c_opt) -o$@ $<
tlib .\libs\b16\harbour.lib -+$@,,
.asm.obj:
@@ -90,10 +94,10 @@ transfrm.obj : transfrm.c extend.h types.h
tlib .\libs\b16\harbour.lib -+$@,,
harbour.exe : y_tab.obj lexyy.obj lex_tab.obj harbour.obj genobj32.obj
echo -mh -O2 -ebin\harbour.exe -Iinclude;source\compiler obj\y_tab.obj > b31.bc
echo -ebin\harbour.exe obj\y_tab.obj > b31.bc
echo obj\lexyy.obj obj\lex_tab.obj >> b31.bc
echo obj\harbour.obj obj\genobj32.obj >> b31.bc
bcc @b31.bc
bcc $(c_opt) -Isource\compiler @b31.bc
fixflex.obj : source\compiler\fixflex.c
genobj32.obj : source\compiler\genobj32.c
@@ -106,10 +110,10 @@ source\compiler\y_tab.c : harbour.y
bison -d -v -y -osource\compiler\y_tab.c source\compiler\harbour.y
fixflex.exe : fixflex.obj
bcc -mh -O2 -I.\include -ebin\fixflex.exe obj\fixflex.obj
bcc -mh $(c_opt) -ebin\fixflex.exe obj\fixflex.obj
source\compiler\lex_tab.c :: harbour.l fixflex.exe
source\compiler\lexyy.c :: harbour.l fixflex.exe
flex -i -8 -osource\compiler\lexyy.c source\compiler\harbour.l
if exist source\compiler\lexyy.bak del source\compiler\lexyy.bak
fixflex source\compiler\lexyy.c source\compiler\lex_tab.c
fixflex source\compiler\lexyy.c source\compiler\lex_tab.c -P-

View File

@@ -6,22 +6,53 @@
#include <stdio.h>
#include <string.h>
#define BUF_SIZE 4095
void fixup (char * inbuf, char * outbuf, int c_plus_plus)
{
char * ptr;
if (c_plus_plus)
{
/* If compiling for C++, the arrays need to be extern "C" in both modules */
static char tempbuf [BUF_SIZE];
strcpy (tempbuf, "extern \"C\" ");
strcpy (outbuf, tempbuf);
strcat (outbuf, inbuf + 7);
strcat (tempbuf, inbuf + 7);
strcpy (inbuf, tempbuf);
}
else
{
/* if compiling for C, the arrays only need to be extern in lexyy.c */
strcpy (outbuf, inbuf + 7);
memcpy (inbuf, "extern", 6);
}
ptr = strchr (inbuf, '=');
if (ptr) *ptr = ';';
}
int main (int argc, char * argv [])
{
int rc = 0;
int c_plus_plus = 0, rc = 0;
char backup [MAXPATH];
if (argc < 3)
{
// Must have 2 arguments.
/* Must have at least 2 arguments. */
rc = 1;
puts ("\nUsage: FIX_FLEX source dest\n\nWhere source is the name of the generated FLEX source file and dest\nis the name of the source file to extract the two largest flex tables into.");
puts ("\nUsage: FIX_FLEX source dest [-P[+|-]]\n\n\Where source is the name of the generated FLEX source file, dest\n\is the name of the source file to extract the two largest flex tables into\n\and -P or -P+ is needed when compiling Harbour using C++ instead of C.\nNote: -P- may be used to indicate the default of compiling Harbour using ANSI C.");
}
else
{
// Rename source to backup.
int i;
size_t len;
for (i = 3; i < argc; i++)
{
if (strcmp (argv[i], "-P") == 0) c_plus_plus = 1;
if (strcmp (argv[i], "-P+") == 0) c_plus_plus = 1;
if (strcmp (argv[i], "-P-") == 0) c_plus_plus = 0;
}
/* Rename source to backup. */
strcpy (backup, argv[1]);
len = strlen (backup);
for (i = 1; i < 4; i++) if (backup [len - i] == '.') backup [len - i] = 0;
@@ -34,7 +65,7 @@ int main (int argc, char * argv [])
}
if (rc == 0)
{
// Read from backup as source.
/* Read from backup as source. */
FILE * source = fopen (backup, "r");
if (!source)
{
@@ -43,7 +74,7 @@ int main (int argc, char * argv [])
}
else
{
// Create new source.
/* Create new source. */
FILE * replace = fopen (argv[1], "w");
if (!replace)
{
@@ -52,7 +83,7 @@ int main (int argc, char * argv [])
}
else
{
// Create dest.
/* Create dest. */
FILE * dest = fopen (argv[2], "w");
if (!dest)
{
@@ -61,16 +92,15 @@ int main (int argc, char * argv [])
}
else
{
// Initialize.
/* Initialize. */
int copy = 0, move = 0, check_count = 3;
int defer_move = 0, defer_end = 0;
#define BUF_SIZE 4095
static char inbuf [BUF_SIZE + 1];
static char outbuf [sizeof (inbuf)];
do
{
// Read from source
/* Read from source */
fgets (inbuf, BUF_SIZE, source);
if (ferror (source))
{
@@ -82,19 +112,16 @@ int main (int argc, char * argv [])
char * ptr;
strcpy (outbuf, inbuf);
// Check for stuff to copy or move to dest.
/* Check for stuff to copy or move to dest. */
if (check_count > 0 && !move && !copy)
{
ptr = strstr (inbuf, "yy_nxt");
if (ptr)
{
// It's the first of the two big tables.
// Move it out of source into dest, leaving only
// an extern declaration.
strcpy (outbuf, inbuf + 7); // skip "static "
memcpy (inbuf, "extern", 6);
ptr = strchr (inbuf, '=');
if (ptr) *ptr = ';';
/* It's the first of the two big tables.
Move it out of source into dest, leaving only
an extern or extern "C" declaration. */
fixup (inbuf, outbuf, c_plus_plus);
move = 1;
defer_move = 1;
check_count--;
@@ -104,13 +131,10 @@ int main (int argc, char * argv [])
ptr = strstr (inbuf, "yy_chk");
if (ptr)
{
// It's the second of the two big tables.
// Move it out of source into dest, leaving only
// an extern declaration.
strcpy (outbuf, inbuf + 7); // skip "static "
memcpy (inbuf, "extern", 6);
ptr = strchr (inbuf, '=');
if (ptr) *ptr = ';';
/* It's the second of the two big tables.
Move it out of source into dest, leaving only
an extern or extern "C" declaration. */
fixup (inbuf, outbuf, c_plus_plus);
move = 1;
defer_move = 1;
check_count--;
@@ -120,9 +144,9 @@ int main (int argc, char * argv [])
ptr = strstr (inbuf, "#define FLEX_SCANNER");
if (ptr)
{
// It's the start of various #defines that
// need to be copied from source to dest in
// order to set up the yyconst define.
/* It's the start of various #defines that
need to be copied from source to dest in
order to set up the yyconst define. */
copy = 1;
check_count--;
}
@@ -131,18 +155,18 @@ int main (int argc, char * argv [])
}
else if (move || copy)
{
// Check for stuff to end copy or move.
/* Check for stuff to end copy or move. */
ptr = strstr (inbuf, "}");
if (ptr && move) defer_end = 1; // End of table to move.
if (ptr && move) defer_end = 1; /* End of table to move. */
else
{
ptr = strstr (inbuf, "#ifdef YY_USE_PROTOS");
if (ptr && copy) copy = 0; // End of #defines to copy.
if (ptr && copy) copy = 0; /* End of #defines to copy. */
}
}
if (move || copy)
{
// If moving or copying from source to dest, do so.
/* If moving or copying from source to dest, do so. */
fputs (outbuf, dest);
if (ferror (dest))
{
@@ -152,7 +176,7 @@ int main (int argc, char * argv [])
}
if (!feof (source) && (!move || defer_move) && rc == 0)
{
// If not moving to dest, then write to new source.
/* If not moving to dest, then write to new source. */
fputs (inbuf, replace);
if (ferror (replace))
{
@@ -160,7 +184,7 @@ int main (int argc, char * argv [])
printf ("\nError %d (DOS error %02xd) writing to %s (after renaming to %s).", errno, _doserrno, argv[1], backup);
}
}
// Clean up.
/* Clean up. */
if (defer_move) defer_move = 0;
if (defer_end)
{

View File

@@ -0,0 +1,24 @@
@echo off
IF A%1 == A GOTO :SINTAX
IF A%2 == A GOTO :NOOUTPUT
echo -P -mh -O2 -Fm -e%2.exe -I..\..\include ..\..\source\vm\hvm.c %1.c > b16.bc
echo ..\..\libs\b16\harbour.lib ..\..\libs\b16\hbtools.lib ..\..\libs\b16\terminal.lib >> b16.bc
bcc @b16.bc
del b16.bc
GOTO :END
:NOOUTPUT
echo -P -mh -O2 -Fm -e%1.exe -I..\..\include ..\..\source\vm\hvm.c %1.c > b16.bc
echo ..\..\libs\b16\harbour.lib ..\..\libs\b16\hbtools.lib ..\..\libs\b16\terminal.lib >> b16.bc
bcc @b16.bc
del b16.bc
GOTO :END
:SINTAX
ECHO syntax: BuildExe Harbour_Output_Filename [Exe_Output_Filename]
ECHO Use Harbour_Output_Filename and Exe_Output_Filename without extensions
ECHO\
:END

View File

@@ -0,0 +1,10 @@
@echo off
REM From .PRG to .C = Harbour
..\..\bin\harbour %1.prg /n
if errorlevel 1 goto end
REM From .C to .EXE = Bld+Exe
call bldpexe %1 %2
:end