When built on Win32 with gcc, don't use popen, as it doesn't seem to work

* gcg.c: When built on Win32 with gcc, don't use popen,
	as it doesn't seem to work when gcc is itself running under
	cygwin, but gcg is not.

	* makefile.cygwin: New file.
This commit is contained in:
Tor Lillqvist 1999-07-03 07:49:44 +00:00
parent 2815f523e9
commit 7b46c30e0c
3 changed files with 79 additions and 2 deletions

View File

@ -1,3 +1,11 @@
1999-07-03 Tor Lillqvist <tml@iki.fi>
* gcg.c: When built on Win32 with gcc, don't use popen,
as it doesn't seem to work when gcc is itself running under
cygwin, but gcg is not.
* makefile.cygwin: New file.
Sun Jun 6 11:16:56 PDT 1999 Manish Singh <yosh@gimp.org>
* Makefile.am

View File

@ -13,6 +13,11 @@
extern int opterr, optind, optopt;
extern char *optarg;
extern int getopt(int nargc, char** nargv, char* ostr);
#if defined(__GNUC__)
#define DONT_USE_POPEN
#endif
#endif
#ifndef CPP_PROGRAM
@ -23,6 +28,10 @@ extern int getopt(int nargc, char** nargv, char* ostr);
#define CPP_SEARCH
#endif
#ifdef DONT_USE_POPEN
#define GCGTMP "__gcg.tmp"
#endif
Id header_root = NULL;
Id source_name = NULL;
@ -73,7 +82,7 @@ void open_out(PNode*(*func)(Module*),
gchar* str;
PNode* guard;
FILE* f;
g_string_append(s, "/");
g_string_append(s, G_DIR_SEPARATOR_S);
str = p_to_str(func(current_module), NULL);
g_string_append(s, str);
g_free(str);
@ -111,11 +120,21 @@ int main(int argc, char* argv[]){
g_string_append(cpp_cmd, " ");
g_string_append(cpp_cmd, argv[optind]);
#ifdef DONT_USE_POPEN
g_string_append(cpp_cmd, " -o " GCGTMP);
system(cpp_cmd->str);
yyin=fopen(GCGTMP, "r");
#else
yyin=popen(cpp_cmd->str, "r");
#endif
/*yyin=fopen(argv[optind], "r");*/
g_assert(yyin);
yyparse();
#ifdef DONT_USE_POPEN
fclose(yyin);
#else
pclose(yyin);
#endif
if(!source_name)
source_name = p_to_str(p_fmt("~.c",

50
tools/gcg/makefile.cygwin Normal file
View File

@ -0,0 +1,50 @@
## Makefile for building gcg with gcc -mno-cygwin
## Use: make -f makefile.cygwin
################################################################
CC = gcc -mno-cygwin -mpentium
LEX = flex
YACC = bison -y
INSTALL = install
GLIB_VER = 1.3
GLIB = ../../../glib
CFLAGS = -g -I$(GLIB) -DCPP_PROGRAM="\"$(CC) -E -x c\"" -DYY_NEVER_INTERACTIVE
all: gcg.exe
YFLAGS = -d -v
LFLAGS = -d
lexer.c : lexer.l
$(LEX) $(LFLAGS) -t lexer.l >lexer.c
parser.c parser.h: parser.y
$(YACC) $(YFLAGS) parser.y
cp y.tab.c parser.c
cp y.tab.h parser.h
gcg_OBJECTS = \
gcg.o \
getopt.o \
parser.o \
lexer.o \
output.o \
pnode.o \
db.o \
output_enum.o \
output_flags.o\
output_object.o\
fp.o \
marshall.o \
gcg.exe : $(gcg_OBJECTS)
$(CC) $(CFLAGS) -o gcg.exe $(gcg_OBJECTS) -L $(GLIB) -lglib-$(GLIB_VER) $(LDFLAGS)
clean:
-rm parser.[ch] lexer.c *.exe *.o