diff --git a/ctrtool/Makefile b/ctrtool/Makefile index 7a534c9..55bc16b 100644 --- a/ctrtool/Makefile +++ b/ctrtool/Makefile @@ -8,25 +8,25 @@ CXXFLAGS = -I. CFLAGS = -O2 -Wall -Wno-unused-variable -Wno-unused-result -I. -std=c99 CC = gcc CXX = g++ -ifeq ($(OS),Windows_NT) +SYS := $(shell gcc -dumpmachine) +ifneq (, $(findstring linux, $(SYS))) + # Linux + CFLAGS += -Wno-unused-but-set-variable +else ifneq(, $(findstring cygwin, $(SYS))) + # Cygwin + CFLAGS += -Wno-unused-but-set-variable -DUSE_FILE32API + LIBS += -liconv +else ifneq(, $(findstring darwin, $(SYS))) + # OS X + LIBS += -liconv +else #Windows Build CFG CFLAGS += -Wno-unused-but-set-variable - LIBS += -static-libgcc -static-libstdc++ -else - UNAME_S := $(shell uname -s) - ifeq ($(UNAME_S),Darwin) - # OS X - CFLAGS += - LIBS += -liconv - else - # Linux - CFLAGS += -Wno-unused-but-set-variable - LIBS += - endif + LIBS += -static-libgcc endif main: $(OBJS) - $(CXX) -o $(OUTPUT) $(LIBS) $(OBJS) + $(CXX) -o $(OUTPUT) $(OBJS) $(LIBS) clean: rm -rf $(OUTPUT) $(OBJS) diff --git a/ctrtool/oschar.c b/ctrtool/oschar.c index f850ef3..b712ff2 100644 --- a/ctrtool/oschar.c +++ b/ctrtool/oschar.c @@ -1,6 +1,8 @@ #include #ifndef _WIN32 +#ifndef __CYGWIN__ #define LIBICONV_PLUG +#endif #include #endif #include "oschar.h" diff --git a/ctrtool/utils.h b/ctrtool/utils.h index 990d900..eb68fcb 100644 --- a/ctrtool/utils.h +++ b/ctrtool/utils.h @@ -46,7 +46,7 @@ inline int fseeko64(FILE *__stream, long long __off, int __whence) { return _fseeki64(__stream, __off, __whence); } -#elif __APPLE__ +#elif __APPLE__ || __CYGWIN__ #define fseeko64 fseek // OS X file I/O is 64bit #elif __linux__ extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence); diff --git a/makerom/Makefile b/makerom/Makefile index fd0832f..f7ae626 100644 --- a/makerom/Makefile +++ b/makerom/Makefile @@ -5,22 +5,24 @@ OBJS = $(foreach dir,$(SRC_DIR),$(subst .c,.o,$(wildcard $(dir)/*.c))) # Compiler Settings CFLAGS = --std=gnu99 -O2 -Wall -Wno-unused-value -Wno-unused-result -I. CC = gcc -ifeq ($(OS),Windows_NT) + +SYS := $(shell gcc -dumpmachine) +ifneq (, $(findstring linux, $(SYS))) + # Linux + CFLAGS += -Wno-unused-but-set-variable +else ifneq(, $(findstring cygwin, $(SYS))) + # Cygwin + CFLAGS += -Wno-unused-but-set-variable + LIBS += -liconv +else ifneq(, $(findstring darwin, $(SYS))) + # OS X + LIBS += -liconv +else #Windows Build CFG CFLAGS += -Wno-unused-but-set-variable LIBS += -static-libgcc -else - UNAME_S := $(shell uname -s) - ifeq ($(UNAME_S),Darwin) - # OS X - LIBS += -liconv - else - # Linux - CFLAGS += -Wno-unused-but-set-variable - endif endif - # MAKEROM Build Settings OUTPUT = makerom @@ -29,7 +31,7 @@ main: build rebuild: clean build build: $(OBJS) - $(CC) -o $(OUTPUT) $(LIBS) $(OBJS) + $(CC) -o $(OUTPUT) $(OBJS) $(LIBS) clean: rm -rf $(OUTPUT) $(OBJS) \ No newline at end of file diff --git a/makerom/oschar.c b/makerom/oschar.c index f850ef3..b712ff2 100644 --- a/makerom/oschar.c +++ b/makerom/oschar.c @@ -1,6 +1,8 @@ #include #ifndef _WIN32 +#ifndef __CYGWIN__ #define LIBICONV_PLUG +#endif #include #endif #include "oschar.h"