# GCC with EMX

.SUFFIXES: .c .cpp .asm .o .obj .rc .res

MFLAGS     = -nologo
MDUMMY     =

OBJ        = .obj
CO         = .o
LBI        = .lib
LBO        = .a
RES        = .res

AS         = nasm
AFLAGS     = -fobj -DUNDERSCORE

CC         = g++
CFLAGS     = -Wall -Wno-uninitialized -DOS2 -DOS2EMX_PLAIN_CHAR
CFLAGS_DLL =
CFLAGS_DBG = -g -DDEBUG=$(DEBUG)
CFLAGS_OPT = -O2

CL         = g++
LFLAGS     = -Zomf
LFLAGS_DLL = -Zdll
LFLAGS_DBG = -g
LFLAGS_OPT = -s
LFLAGS_OUT = -o .^\
LDEF_PREFX =
LDEF_SUFFX = _icc.def
LOBJ_PREFX =
LOBJ_SUFFX =
LLIB_PREFX =
LLIB_SUFFX =

LB         = ar cr
LBENDL     =

LI         = emximp
IFLAGS_OUT = -o

RC         = rc
RFLAGS     = -n

LIBS_TCP   =
LIBS_MM    = -lmmpm2
LIBS_UNI   =

C_INCLUDE_PATH     = $(INCDIR);$(C_INCLUDE_PATH)
CPLUS_INCLUDE_PATH = $(INCDIR);$(CPLUS_INCLUDE_PATH)

!ifdef TCP40
MFLAGS = $(MFLAGS) TCP40=Yes
CFLAGS = $(CFLAGS) -DTCPV40HDRS
!ifdef GCC_ROOT
LFLAGS = $(LFLAGS) -L$(GCC_ROOT)\lib\tcpipv4
!else
!ifdef GCC_HOME
LFLAGS = $(LFLAGS) -L$(GCC_HOME)\lib\tcpipv4
!else
!error GCC_HOME or GCC_ROOT must be defined.
!endif
!endif
!endif

!ifdef DEBUG
CFLAGS = $(CFLAGS) $(CFLAGS_DBG)
LFLAGS = $(LFLAGS) $(LFLAGS_DBG)
MFLAGS = $(MFLAGS) DEBUG=$(DEBUG)
!else
CFLAGS = $(CFLAGS) $(CFLAGS_OPT)
LFLAGS = $(LFLAGS) $(LFLAGS_OPT)
!endif

!ifdef DLL
CFLAGS = $(CFLAGS) $(CFLAGS_DLL)
LFLAGS = $(LFLAGS) $(LFLAGS_DLL)
!endif

.asm.obj:
   $(AS) $(AFLAGS) $<

.c.o:
   $(CC) $(CFLAGS) -x c -c $< -o $@

.cpp.o:
   $(CC) $(CFLAGS) -c $< -o $@

.rc.res:
   $(RC) $(RFLAGS) -r $<

