From 55e299e4b3f0ca0c10dcf5b86cd9c1dbe575b4e0 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Fri, 11 Aug 2006 03:07:32 +0000 Subject: [PATCH] Upgraded ccdv-win32.c and the Makefiles so that they are fully functional under MSYS. SVN r286 (trunk) --- FLAC/Makefile.mgw | 14 ++ Makefile | 7 + Makefile.mgw | 16 +- Makefile.mingw | 22 +++ ccdv-win32.c | 266 +++++++++++++++++++++++----------- tools/dehsupp/Makefile | 16 +- tools/lemon/Makefile | 16 +- tools/makewad/Makefile | 18 ++- tools/makewad/makewad.c | 14 +- tools/re2c/Makefile | 16 +- tools/updaterevision/Makefile | 18 ++- tools/xlatcc/Makefile | 16 +- wadsrc/Makefile.mgw | 4 + zlib/Makefile.mgw | 7 + 14 files changed, 331 insertions(+), 119 deletions(-) diff --git a/FLAC/Makefile.mgw b/FLAC/Makefile.mgw index d26ba2c7fc..fdf9aa0321 100644 --- a/FLAC/Makefile.mgw +++ b/FLAC/Makefile.mgw @@ -7,6 +7,15 @@ # Copyright (C) 1995-2003 Jean-loup Gailly. # For conditions of distribution and use, see copyright notice in zlib.h +ifeq (Windows_NT,$(OS)) + WIN=1 + WINCMD=1 +endif +ifeq (msys,$(OSTYPE)) + WIN=1 + WINCMD=0 +endif + STATICLIB = libflac.a #LOC = -DASMV @@ -44,8 +53,13 @@ $(STATICLIB): $(OBJS) .PHONY: clean clean: +ifeq (1,$(WINCMD)) -del /q /f $(STATICLIB) 2>nul -del /q /f *.o 2>nul +else + rm -f $(STATICLIB) + rm -f *.o +endif cpu_asm.o: ia32/cpu_asm.nasm $(CCDV) $(NASM) -o $@ $(NASMFLAGS) $< diff --git a/Makefile b/Makefile index fa08115349..c9d7daeeca 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,11 @@ ifeq (Windows_NT,$(OS)) + WIN=1 +endif +ifeq (msys,$(OSTYPE)) + WIN=1 +endif + +ifeq (1,$(WIN)) include Makefile.mgw else include Makefile.linux diff --git a/Makefile.mgw b/Makefile.mgw index 16a0084e04..07289437ae 100644 --- a/Makefile.mgw +++ b/Makefile.mgw @@ -25,23 +25,27 @@ basetools: ccdv.exe $(MAKE) -C tools/makewad $(MAKE) -C tools/dehsupp $(MAKE) -C tools/xlatcc - $(MAKE) -C wadsrc + $(MAKE) -C wadsrc -f Makefile.mgw $(MAKE) -C flac -f Makefile.mgw cleanexe: @$(MAKE) -C . -f Makefile.mingw clean clean: - @$(MAKE) -C tools/lemon -f Makefile clean - @$(MAKE) -C tools/re2c -f Makefile clean - @$(MAKE) -C tools/dehsupp -f Makefile clean - @$(MAKE) -C tools/makewad -f Makefile clean - @$(MAKE) -C tools/xlatcc -f Makefile clean + @$(MAKE) -C tools/lemon clean + @$(MAKE) -C tools/re2c clean + @$(MAKE) -C tools/dehsupp clean + @$(MAKE) -C tools/makewad clean + @$(MAKE) -C tools/xlatcc clean @$(MAKE) -C wadsrc -f Makefile.mgw clean @$(MAKE) -C . -f Makefile.mingw clean @$(MAKE) -C zlib -f Makefile.mgw clean @$(MAKE) -C flac -f Makefile.mgw clean +ifeq (msys,$(OSTYPE)) + rm -f ccdv.exe +else del /q /f ccdv.exe 2>nul +endif ccdv.exe: ccdv-win32.c @gcc -Os -s -nostdlib -fomit-frame-pointer -o ccdv.exe ccdv-win32.c -lkernel32 -luser32 diff --git a/Makefile.mingw b/Makefile.mingw index efcae9bf2d..1d00977d55 100644 --- a/Makefile.mingw +++ b/Makefile.mingw @@ -4,6 +4,12 @@ # Where did you install the FMOD API to? Change this line so that the build process can find it. FMODDIR = "c:/program files/fmodapi375win" +ifeq (msys,$(OSTYPE)) + WINCMD=0 +else + WINCMD=1 +endif + CC ?= gcc CXX ?= g++ @@ -93,6 +99,7 @@ $(OBJDIR)/%.o : %.rc $(TARGET): testobjdir updaterev $(OBJS) $(CCDV) $(CXX) -o $@ $(OBJS) $(LDFLAGS) +ifeq (1,$(WINCMD)) clean: -del /q /f $(RELEASETARGET) 2>nul -del /q /f $(DEBUGTARGET) 2>nul @@ -102,9 +109,24 @@ clean: cleandep: -del /q /f $(DEBUGOBJDIR)\*.d 2>nul -del /q /f $(RELEASEOBJDIR)\*.d 2>nul +else +clean: + rm -f $(RELEASETARGET) + rm -f $(DEBUGTARGET) + rm -fr $(DEBUGOBJDIR) + rm -fr $(RELEASEOBJDIR) + +cleandep: + rm -f $(DEBUGOBJDIR)\*.d + rm -f $(RELEASEOBJDIR)\*.d +endif testobjdir: +ifeq (1,$(WINCMD)) -@if not exist $(OBJDIR) mkdir $(OBJDIR) +else + -@if [ ! -e $(OBJDIR) ]; then mkdir $(OBJDIR); fi +endif updaterev: tools/updaterevision/updaterevision.exe @tools/updaterevision/updaterevision . src/svnrevision.h diff --git a/ccdv-win32.c b/ccdv-win32.c index 1dd51f14c5..c3860452e5 100644 --- a/ccdv-win32.c +++ b/ccdv-win32.c @@ -18,10 +18,20 @@ #define WIN32_LEAN_AND_MEAN #include -#define COLOR_SUCCESS (FOREGROUND_GREEN|FOREGROUND_INTENSITY) /* green */ -#define COLOR_FAILURE (FOREGROUND_RED|FOREGROUND_INTENSITY) /* red */ -#define COLOR_WARNING (FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_INTENSITY) /* yellow */ -#define COLOR_COMMAND (FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY) /* cyan */ +#define COLOR_SUCCESS (FOREGROUND_GREEN|FOREGROUND_INTENSITY) /* green */ +#define COLOR_FAILURE (FOREGROUND_RED|FOREGROUND_INTENSITY) /* red */ +#define COLOR_WARNING (FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_INTENSITY) /* yellow */ +#define COLOR_COMMAND (FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY) /* cyan */ +#define COLOR_ERROROUTPUT (FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_INTENSITY) /* magenta */ +#define COLOR_WARNINGOUTPUT (FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY) /* white */ + +#define SETCOLOR_SUCCESS "\033[1;32m" /* green */ +#define SETCOLOR_FAILURE "\033[1;31m" /* red */ +#define SETCOLOR_WARNING "\033[0;33m" /* dark yellow */ +#define SETCOLOR_COMMAND "\033[1;35m" /* magenta */ +#define SETCOLOR_ERROROUTPUT "\033[1;31m" /* red */ +#define SETCOLOR_WARNINGOUTPUT "\033[1;39m" /* bold */ +#define SETCOLOR_NORMAL "\033[0;39m" /* normal */ #define TEXT_BLOCK_SIZE 8192 #define INDENT 2 @@ -36,6 +46,7 @@ char *gArLibraryTarget; BOOL gDumpCmdArgs; char *gArgsStr; int gColumns; +BOOL gRxvt; int gExitStatus; HANDLE gHeap; @@ -50,25 +61,47 @@ HANDLE gStdOut, gStdErr; void REGPARM(1) perror(const char *string) { char *buffer; + char errcode[9]; DWORD error = GetLastError(); DWORD len = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, NULL, error, 0, (LPTSTR)&buffer, 0, NULL); DWORD wrote; WriteFile (gStdErr, string, lstrlen(string), &wrote, NULL); - if(len == 0) + wsprintf(errcode, "%08x", error); + WriteFile (gStdErr, ": Error 0x", 10, &wrote, NULL); + WriteFile (gStdErr, errcode, 8, &wrote, NULL); + if(len != 0) { - char errcode[9]; - wsprintf(errcode, "%08x", error); - WriteFile (gStdErr, ": Error ", 8, &wrote, NULL); - WriteFile (gStdErr, errcode, 8, &wrote, NULL); - } - else - { - WriteFile (gStdErr, ": ", 2, &wrote, NULL); + WriteFile (gStdErr, "\n", 1, &wrote, NULL); WriteFile (gStdErr, buffer, len, &wrote, NULL); LocalFree(buffer); } WriteFile (gStdErr, "\n", 1, &wrote, NULL); + gColumns = 0; +} + +static int REGPARM(1) str2int(const char *string) +{ + int out = 0; + + while (*string >= '0' && *string <= '9') + { + out = out * 10 + *string++ - '0'; + } + return out; +} + +static void Writef(HANDLE hFile, const char *fmt, ...) +{ + char buf[1024]; + int buflen; + va_list arglist; + DWORD wrote; + + va_start(arglist, fmt); + buflen = wvsprintf(buf, fmt, arglist); + va_end(arglist); + WriteFile(hFile, buf, buflen, &wrote, NULL); } static void DumpFormattedOutput() @@ -82,19 +115,43 @@ static void DumpFormattedOutput() int curcol; int i; - if(!GetConsoleScreenBufferInfo(gStdOut, &info)) - { - WriteFile(gStdOut, gBuf, lstrlen(gBuf), &out, NULL); - WriteFile(gStdOut, "\n", 1, &out, NULL); - return; - } - for(i = 0; i < 8; ++i) { spaces[i] = ' '; } spaces[i] = '\0'; + if(gRxvt) + { + curcol = 0; + saved = NULL; + if(gDumpCmdArgs) + { + Writef(gStdOut, SETCOLOR_COMMAND "%s" SETCOLOR_NORMAL "\n", gArgsStr); + for(i = gColumns; i > 0; i -= 7) + { + WriteFile(gStdOut, "=======", i > 7 ? 7 : i, &out, NULL); + } + WriteFile(gStdOut, SETCOLOR_ERROROUTPUT, sizeof(SETCOLOR_ERROROUTPUT), &out, NULL); + } + else + { + WriteFile(gStdOut, SETCOLOR_WARNINGOUTPUT, sizeof(SETCOLOR_WARNINGOUTPUT), &out, NULL); + } + WriteFile(gStdOut, gBuf + lstrlen(gArgsStr), lstrlen(gBuf + lstrlen(gArgsStr)), &out, NULL); + WriteFile(gStdOut, SETCOLOR_NORMAL, sizeof(SETCOLOR_NORMAL), &out, NULL); + HeapFree(gHeap, 0, gBuf); + return; + } + + if(!GetConsoleScreenBufferInfo(gStdOut, &info)) + { + WriteFile(gStdOut, gBuf, lstrlen(gBuf), &out, NULL); + WriteFile(gStdOut, "\n", 1, &out, NULL); + HeapFree(gHeap, 0, gBuf); + return; + } + color = info.wAttributes & ~(FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY); curcol = 0; saved = NULL; @@ -103,41 +160,19 @@ static void DumpFormattedOutput() SetConsoleTextAttribute(gStdOut, color | COLOR_COMMAND); WriteConsole(gStdOut, gBuf, lstrlen(gArgsStr)+1, &out, NULL); SetConsoleTextAttribute(gStdOut, info.wAttributes); + for(i = gColumns; i > 0; i -= 7) + { + WriteConsole(gStdOut, "=======", i > 7 ? 7 : i, &out, NULL); + } + color |= COLOR_ERROROUTPUT; } - for(cp = gBuf + lstrlen(gArgsStr) + 1;; cp++) + else { - if(*cp == '\0') - { - if(saved != NULL) - { - cp = saved; - saved = NULL; - } - else - break; - } - if(*cp == '\r') - continue; - if(*cp == '\t') - { - saved = cp + 1; - cp = spaces + 8 - (8 - ((curcol - INDENT - 1) % 8)); - } - if(curcol == 0) - { - for(i = INDENT; --i >= 0;) - WriteConsole(gStdOut, " " ,1, &out, NULL); - curcol = INDENT; - } - WriteConsole(gStdOut, cp, 1, &out, NULL); - if(++curcol == (gColumns - 1)) - { - WriteConsole(gStdOut, "\n", 1, &out, NULL); - curcol = 0; - } - else if(*cp == '\n') - curcol = 0; + color |= COLOR_WARNINGOUTPUT; } + SetConsoleTextAttribute(gStdOut, color); + WriteConsole(gStdOut, gBuf + lstrlen(gArgsStr) + 1, lstrlen(gBuf + lstrlen(gArgsStr) + 1), &out, NULL); + SetConsoleTextAttribute(gStdOut, info.wAttributes); HeapFree(gHeap, 0, gBuf); } /* DumpFormattedOutput */ @@ -226,8 +261,11 @@ static int REGPARM(2) Slurp(HANDLE fd, HANDLE hStdOut) if(hStdOut != NULL) { - GetConsoleScreenBufferInfo(hStdOut, &info); - info.dwCursorPosition.X = info.dwSize.X - 9; + if(!gRxvt) + { + GetConsoleScreenBufferInfo(hStdOut, &info); + info.dwCursorPosition.X = info.dwSize.X - 9; + } if(GetConsoleCursorInfo(hStdOut, &cursorInfo)) { cursorInfo.bVisible = FALSE; @@ -248,8 +286,15 @@ static int REGPARM(2) Slurp(HANDLE fd, HANDLE hStdOut) case WAIT_TIMEOUT: if(hStdOut != NULL) { - SetConsoleCursorPosition(hStdOut, info.dwCursorPosition); - WriteConsoleA(hStdOut, trailcp, 1, &out, NULL); + if(!gRxvt) + { + SetConsoleCursorPosition(hStdOut, info.dwCursorPosition); + WriteConsoleA(hStdOut, trailcp, 1, &out, NULL); + } + else + { + Writef(hStdOut, "\033[999C\033[9D%c", *trailcp); + } if(*++trailcp == '\0') trailcp = trail; } @@ -285,38 +330,58 @@ static int REGPARM(2) Slurp(HANDLE fd, HANDLE hStdOut) } if(hStdOut != NULL) { - info.dwCursorPosition.X = 0; - SetConsoleCursorPosition(hStdOut, info.dwCursorPosition); - WriteAction(hStdOut, ": "); - info.dwCursorPosition.X = info.dwSize.X - 10; - if(gExitStatus == 0) + if(!gRxvt) { + info.dwCursorPosition.X = 0; SetConsoleCursorPosition(hStdOut, info.dwCursorPosition); - WriteConsoleA(hStdOut, "[OK] ", 9, &out, NULL); - color = ((gNBufUsed - lstrlen(gArgsStr)) < 4) ? COLOR_SUCCESS : COLOR_WARNING; - ncells = 2; + WriteAction(hStdOut, ": "); + info.dwCursorPosition.X = info.dwSize.X - 10; + if(gExitStatus == 0) + { + SetConsoleCursorPosition(hStdOut, info.dwCursorPosition); + WriteConsoleA(hStdOut, "[OK] ", 9, &out, NULL); + color = ((gNBufUsed - lstrlen(gArgsStr)) < 4) ? COLOR_SUCCESS : COLOR_WARNING; + ncells = 2; + } + else + { + SetConsoleCursorPosition(hStdOut, info.dwCursorPosition); + WriteConsoleA(hStdOut, "[ERROR] ", 9, &out, NULL); + color = COLOR_FAILURE; + ncells = 5; + gDumpCmdArgs = 1; /* print cmd when there are errors */ + } + color |= info.wAttributes & ~(FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY); + for(i = 0; i < ncells; ++i) + { + colors[i] = color; + } + info.dwCursorPosition.X++; + WriteConsoleOutputAttribute(hStdOut, colors, ncells, info.dwCursorPosition, &out); + if(!cursorInfo.bVisible) + { + cursorInfo.bVisible = TRUE; + SetConsoleCursorInfo(hStdOut, &cursorInfo); + } + WriteConsole(hStdOut, "\n", 1, &out, NULL); } else { - SetConsoleCursorPosition(hStdOut, info.dwCursorPosition); - WriteConsoleA(hStdOut, "[ERROR] ", 9, &out, NULL); - color = COLOR_FAILURE; - ncells = 5; - gDumpCmdArgs = 1; /* print cmd when there are errors */ + WriteFile(hStdOut, "\033[255D", 6, &out, NULL); + WriteAction(hStdOut, ": "); + if(gExitStatus == 0) + { + Writef(hStdOut, "\033[999C\033[10D[%sOK%s]", + ((gNBufUsed - strlen(gArgsStr)) < + 4) ? SETCOLOR_SUCCESS : SETCOLOR_WARNING, SETCOLOR_NORMAL); + } + else + { + Writef(hStdOut, "\033[999C\033[10D[%sERROR%s]\n", + SETCOLOR_FAILURE, SETCOLOR_NORMAL); + gDumpCmdArgs = 1; /* print cmd when there are errors */ + } } - color |= info.wAttributes & ~(FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY); - for(i = 0; i < ncells; ++i) - { - colors[i] = color; - } - info.dwCursorPosition.X++; - WriteConsoleOutputAttribute(hStdOut, colors, ncells, info.dwCursorPosition, &out); - if(!cursorInfo.bVisible) - { - cursorInfo.bVisible = TRUE; - SetConsoleCursorInfo(hStdOut, &cursorInfo); - } - WriteConsole(hStdOut, "\n", 1, &out, NULL); } else { @@ -457,6 +522,38 @@ void mainCRTStartup(void) Usage(); } + if(GetConsoleScreenBufferInfo(gStdOut, &bufferInfo)) + { + gColumns = bufferInfo.dwSize.X; + } + else + { + char envbuf[16]; + DWORD envlen; + + // Check for MSYS by checking for an rxvt COLORTERM. + envlen = GetEnvironmentVariable("COLORTERM", envbuf, sizeof(envbuf)); + if(envlen > 0 && envlen < sizeof(envbuf) - 1) + { + if(lstrcmp(envbuf, "rxvt") == 0) + { + gRxvt = TRUE; + + // We're in an rxvt, so check the number of columns. + // Unfortunately, COLUMNS is not exported by default by MSYS. + envlen = GetEnvironmentVariable("COLUMNS", envbuf, sizeof(envbuf)); + if(envlen > 0 && envlen < sizeof(envbuf) - 1) + { + gColumns = str2int(envbuf); + } + else + { + gColumns = 80; + } + } + } + } + // "Running *argv[1]*" ext = Basename(arg, arglen); extlen = arglen - (ext - arg); @@ -620,15 +717,14 @@ void mainCRTStartup(void) } CloseHandle(gCCP.hThread); - if(GetConsoleScreenBufferInfo(gStdOut, &bufferInfo)) + if(!gRxvt) { - gColumns = bufferInfo.dwSize.X; if(Slurp(pipeRdDup, gStdOut) < 0) goto panic; } else { - if(Slurp(pipeRdDup, NULL) < 0) + if(Slurp(pipeRdDup, gStdOut) < 0) goto panic; } DumpFormattedOutput(); diff --git a/tools/dehsupp/Makefile b/tools/dehsupp/Makefile index 4471c399b5..fceb14e253 100644 --- a/tools/dehsupp/Makefile +++ b/tools/dehsupp/Makefile @@ -1,13 +1,21 @@ -ifeq (Windows_NT,$(OS)) +ifeq (Windows_NT,$(OS)) + WIN=1 + WINCMD=1 +endif +ifeq (msys,$(OSTYPE)) + WIN=1 + WINCMD=0 +endif + +ifeq (1,$(WIN)) EXE = dehsupp.exe - CCDV = @../../ccdv CFLAGS = $(LOC) -Os -Wall -fomit-frame-pointer else EXE = dehsupp - CCDV = @../../ccdv CFLAGS = -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -Os -Wall -fomit-frame-pointer endif +CCDV = @../../ccdv CC = gcc LDFLAGS = -s @@ -26,7 +34,7 @@ $(EXE): $(OBJS) .PHONY: clean clean: -ifeq (Windows_NT,$(OS)) +ifeq (1,$(WINCMD)) -del /q /f $(EXE) 2>nul -del /q /f *.o 2>nul else diff --git a/tools/lemon/Makefile b/tools/lemon/Makefile index 6c366ab2ad..8870943295 100644 --- a/tools/lemon/Makefile +++ b/tools/lemon/Makefile @@ -1,13 +1,21 @@ -ifeq (Windows_NT,$(OS)) +ifeq (Windows_NT,$(OS)) + WIN=1 + WINCMD=1 +endif +ifeq (msys,$(OSTYPE)) + WIN=1 + WINCMD=0 +endif + +ifeq (1,$(WIN)) EXE = lemon.exe - CCDV = @../../ccdv CFLAGS = $(LOC) -D_WIN32 -Os -Wall -Wno-implicit -fomit-frame-pointer else EXE = lemon - CCDV = @../../ccdv CFLAGS = -Os -Wall -Wno-implicit -fomit-frame-pointer endif +CCDV = @../../ccdv CC = gcc LDFLAGS = -s @@ -24,7 +32,7 @@ $(EXE): $(OBJS) .PHONY: clean clean: -ifeq (Windows_NT,$(OS)) +ifeq (1,$(WINCMD)) -del /q /f $(EXE) 2>nul -del /q /f *.o 2>nul else diff --git a/tools/makewad/Makefile b/tools/makewad/Makefile index 72716298c5..380e992bc7 100644 --- a/tools/makewad/Makefile +++ b/tools/makewad/Makefile @@ -1,17 +1,25 @@ -ifeq (Windows_NT,$(OS)) +ifeq (Windows_NT,$(OS)) + WIN=1 + WINCMD=1 +endif +ifeq (msys,$(OSTYPE)) + WIN=1 + WINCMD=0 +endif + +ifeq (1,$(WIN)) EXE = makewad.exe - CCDV = @../../ccdv CFLAGS = -Os -Wall -fomit-frame-pointer LDFLAGS = -s -L../../zlib/ -lz ZLIB = ../../zlib/libz.a else EXE = makewad - CCDV = @../../ccdv CFLAGS = -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -Os -Wall -fomit-frame-pointer LDFLAGS = -s -lz ZLIB = endif +CCDV = @../../ccdv CC = gcc OBJS = makewad.o ioapi.o zip.o @@ -24,7 +32,7 @@ all: $(EXE) $(EXE): $(OBJS) $(ZLIB) $(CCDV) $(CC) -o $(EXE) $(OBJS) $(LDFLAGS) -ifeq (Windows_NT,$(OS)) +ifeq (1,$(WIN)) $(ZLIB): make -C ../../zlib -f Makefile.mgw endif @@ -32,7 +40,7 @@ endif .PHONY: clean clean: -ifeq (Windows_NT,$(OS)) +ifeq (1,$(WINCMD)) -del /q /f $(EXE) 2>nul -del /q /f *.o 2>nul else diff --git a/tools/makewad/makewad.c b/tools/makewad/makewad.c index 0b2ced63ac..5fe54662b4 100644 --- a/tools/makewad/makewad.c +++ b/tools/makewad/makewad.c @@ -194,7 +194,7 @@ int appendtozip (zipFile zipfile, const char * zipname, const char *filename) // - otherwise, we're writing lumps into a wad/zip // */ -int buildwad (FILE *listfile, char *listfilename, char *makecmd, char *makefile) +int buildwad (FILE *listfile, char *listfilename, const char *makecmd, char *makefile) { // destination we're writing output into - // one of these: @@ -442,6 +442,7 @@ int buildwad (FILE *listfile, char *listfilename, char *makecmd, char *makefile) int __cdecl main (int argc, char **argv) { + const char *makecmd; FILE *listfile = NULL; char *listfilename = NULL; char *makefile = NULL; @@ -480,7 +481,16 @@ int __cdecl main (int argc, char **argv) return 1; } - ret = buildwad (listfile ? listfile : stdin, listfilename, argv[0], makefile); + // Hack for msys + if ((makecmd = getenv("OSTYPE")) != NULL && strcmp (makecmd, "msys") == 0) + { + makecmd = "../tools/makewad/makewad.exe"; + } + else + { + makecmd = argv[0]; + } + ret = buildwad (listfile ? listfile : stdin, listfilename, makecmd, makefile); if (listfile != NULL) { fclose (listfile); diff --git a/tools/re2c/Makefile b/tools/re2c/Makefile index d87e383b37..e1d3fc3e44 100644 --- a/tools/re2c/Makefile +++ b/tools/re2c/Makefile @@ -1,13 +1,21 @@ -ifeq (Windows_NT,$(OS)) +ifeq (Windows_NT,$(OS)) + WIN=1 + WINCMD=1 +endif +ifeq (msys,$(OSTYPE)) + WIN=1 + WINCMD=0 +endif + +ifeq (1,$(WIN)) EXE = re2c.exe - CCDV = @../../ccdv CXXFLAGS = $(LOC) -D_WIN32 -DNDEBUG -Os -Wall -Wno-unused else EXE = re2c - CCDV = @../../ccdv CXXFLAGS = -DHAVE_CONFIG_H -DNDEBUG -Os -Wall -Wno-unused endif +CCDV = @../../ccdv CXX = g++ LDFLAGS= -s @@ -24,7 +32,7 @@ $(EXE): $(OBJS) .PHONY: clean clean: -ifeq (Windows_NT,$(OS)) +ifeq (1,$(WINCMD)) -del /q /f $(EXE) 2>nul -del /q /f *.o 2>nul else diff --git a/tools/updaterevision/Makefile b/tools/updaterevision/Makefile index 8d9b6e2e42..48baf61d9a 100644 --- a/tools/updaterevision/Makefile +++ b/tools/updaterevision/Makefile @@ -1,16 +1,24 @@ +ifeq (Windows_NT,$(OS)) + WIN=1 + WINCMD=1 +endif +ifeq (msys,$(OSTYPE)) + WIN=1 + WINCMD=0 +endif + CC = gcc CFLAGS = -Os -Wall -fomit-frame-pointer LDFLAGS = -s -ifeq (Windows_NT,$(OS)) +ifeq (1,$(WIN)) EXE = updaterevision.exe - CCDV = @../../ccdv else EXE = updaterevision - CCDV = @../../ccdv - CFLAGS = -Os -Wall -fomit-frame-pointer endif +CCDV = @../../ccdv + OBJS = updaterevision.o all: $(EXE) @@ -21,7 +29,7 @@ $(EXE): $(OBJS) .PHONY: clean clean: -ifeq (Windows_NT,$(OS)) +ifeq (1,$(WINCMD)) -del /q /f $(EXE) 2>nul -del /q /f *.o 2>nul else diff --git a/tools/xlatcc/Makefile b/tools/xlatcc/Makefile index a07c2f5b52..be0fb2712a 100644 --- a/tools/xlatcc/Makefile +++ b/tools/xlatcc/Makefile @@ -1,13 +1,21 @@ -ifeq (Windows_NT,$(OS)) +ifeq (Windows_NT,$(OS)) + WIN=1 + WINCMD=1 +endif +ifeq (msys,$(OSTYPE)) + WIN=1 + WINCMD=0 +endif + +ifeq (1,$(WIN)) EXE = xlatcc.exe - CCDV = @../../ccdv CFLAGS = $(LOC) -Os -Wall -fomit-frame-pointer else EXE = xlatcc - CCDV = @../../ccdv CFLAGS = -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp $(LOC) -Os -Wall -fomit-frame-pointer endif +CCDV = @../../ccdv CC = gcc LDFLAGS= -s @@ -24,7 +32,7 @@ $(EXE): $(OBJS) .PHONY: clean clean: -ifeq (Windows_NT,$(OS)) +ifeq (1,$(WINCMD)) -del /q /f $(EXE) 2>nul -del /q /f *.o 2>nul else diff --git a/wadsrc/Makefile.mgw b/wadsrc/Makefile.mgw index fbba69ba82..14406f9f07 100644 --- a/wadsrc/Makefile.mgw +++ b/wadsrc/Makefile.mgw @@ -10,7 +10,11 @@ wadmake: zdoom.lst $(MAKEWAD).exe $(XLATCC).exe $(DEHSUPP).exe $(MAKEWAD) -make wadmake zdoom.lst clean: +ifeq (msys,$(OSTYPE)) + rm -f wadmake zdoom.pk3 xlat/*.x dehsupp.lmp +else del /q /f wadmake zdoom.pk3 xlat\*.x dehsupp.lmp 2>nul +endif ../tools/makewad/makewad.exe: $(MAKE) -C ../tools/makewad -f Makefile diff --git a/zlib/Makefile.mgw b/zlib/Makefile.mgw index f172c2806b..8895d8e5ce 100644 --- a/zlib/Makefile.mgw +++ b/zlib/Makefile.mgw @@ -63,10 +63,17 @@ minigzip: minigzip.o $(STATICLIB) .PHONY: clean clean: +ifeq (msys,$(OSTYPE)) + rm -f $(STATICLIB) + rm -f *.o + rm -f *.exe + rm -f foo.gz +else -del /q /f $(STATICLIB) 2>nul -del /q /f *.o 2>nul -del /q /f *.exe 2>nul -del /q /f foo.gz 2>nul +endif adler32.o: zlib.h zconf.h compress.o: zlib.h zconf.h