# debian, RedHat, Mandrake
ifeq ($(OSTYPE), linux-gnu)
	OPERATING_SYSTEM = Linux
endif
# SuSE
ifeq ($(OSTYPE), linux)
	OPERATING_SYSTEM = Linux
endif


# for creating windows binary under linux
ifeq ($(OSTYPE), Linux_to_Windows)
	OPERATING_SYSTEM = Linux_to_Windows
endif


# HPUX 11.00
ifeq ($(OSTYPE), hpux11.00)
	OPERATING_SYSTEM = HPUX
endif


# Windows with msys
ifeq ($(OSTYPE), msys)
	OPERATING_SYSTEM = MSYS
endif


# Macintosh OS X
ifeq ($(OSTYPE), darvin)
	OPERATING_SYSTEM = MACOSX
endif


# Windows XP
ifeq ($(OS), Windows_NT)
	OPERATING_SYSTEM = Windows
endif

# Windows {98,ME} (hopefully)
ifeq ($(OPERATING_SYSTEM), )
	OPERATING_SYSTEM = Windows
endif


ifeq ($(OPERATING_SYSTEM), Linux)
	SHELLTYPE = sh
endif
ifeq ($(OPERATING_SYSTEM), Linux_to_Windows)
	SHELLTYPE = sh
endif
ifeq ($(OPERATING_SYSTEM), HPUX)
	SHELLTYPE = sh
endif
ifeq ($(OPERATING_SYSTEM), MSYS)
	SHELLTYPE = sh
endif
ifeq ($(OPERATING_SYSTEM), Windows)
	SHELLTYPE = COMMAND.COM
	RM = del
endif



ifeq ($(OPERATING_SYSTEM), Linux)
	# Linux
	# compiler
	CXX ?= g++
	# suffix of the object files
	OBJ_SUFFIX ?= o
	# optimization flags
	CXXFLAGS ?= -march=pentium -O2 -Wall -Werror
	# flags for automatic generating of the dependencies
	DEPGEN_FLAGS ?= -MMD -MP
	override CPPFLAGS += -DLINUX
endif

ifeq ($(OPERATING_SYSTEM), Linux_to_Windows)
	MINGW_DIR ?= /mnt/Win98/MinGW32
	PROGNAME ?= FreeDoko.exe
	CXX = i586-mingw32msvc-g++
	OBJ_SUFFIX = o
	CXXFLAGS ?= -Wall -Werror -O2 -march=pentium
	DEPGEN_FLAGS = -MMD -MP
	override CPPFLAGS += -DWINDOWS
	C_INCLUDE_PATH ?= $(MINGW_DIR)/include
	LIBRARY_PATH ?= $(MINGW_DIR)/lib
	INCLUDE ?= -I$(C_INCLUDE_PATH)
	LIBS ?= -L$(LIBRARY_PATH)
	LIBS = -L/usr/lib/gcc-lib/i586-mingw32msvc/3.3.1/
endif

ifeq ($(OPERATING_SYSTEM), HPUX)
	# HPUX
	CXX ?= g++
	OBJ_SUFFIX ?= o
	CXXFLAGS ?= -O2 -Wall -Werror
	DEPGEN_FLAGS ?= -MMD -MP
	override CPPFLAGS += -DHPUX
endif

ifeq ($(OPERATING_SYSTEM), MSYS)
	# Windows
	CXX ?= D:/mingw32/bin/g++
	OBJ_SUFFIX ?= o
	CXXFLAGS ? =-mno-cygwin -march=pentium -fnative-struct -O2 -Wall 
	DEPGEN_FLAGS ?= -MMD -MP
	override CPPFLAGS += -DWINDOWS
endif

ifeq ($(OPERATING_SYSTEM), Windows)
	# Windows
	CXX ?= D:/mingw32/bin/g++
	OBJ_SUFFIX ?= o
	CXXFLAGS ? =-mno-cygwin -march=pentium -fnative-struct -O2 -Wall 
	DEPGEN_FLAGS ?= -MMD -MP
	override CPPFLAGS += -DWINDOWS
endif

ifeq ($(OPERATING_SYSTEM), Linux)
	PROGNAME ?= a.out
endif

ifeq ($(OPERATING_SYSTEM), MSYS)
	PROGNAME ?= a.exe
endif
ifeq ($(OPERATING_SYSTEM), Windows)
	PROGNAME ?= a.exe
endif
