# winmain  : GUI main() for WinMain()
# libmain  : DllEntryPoint() and dummy LibMain()
# dll0w32.o: replaces dll0.o from emx, calls DllEntryPoint()
# wemx2    : apps with runtime (replace dos.o in emx2.a)
# c_dllnrt : Dll without runtime / not defined in emx for a.out
# wthreads : replaces _beginthread(), _endthread() and _thread()
# excpt    : exceptions for gnu c under win32
# excpt2   : exceptions for gnu c under win32 (with finally support)

VPATH=.;..

LIB=\rsxnt\lib

all:	$(LIB)\winmain.a  \
	$(LIB)\libmain.a  \
	$(LIB)\wthreads.a \
	$(LIB)\c_dllnrt.a \
	$(LIB)\wemx2.a	  \
	$(LIB)\dll0w32.o  \
        $(LIB)\excpt.a    \
        $(LIB)\excpt2.a

.s.o:
	as -o $*.o $<

.c.o:
	gcc -c -Wall -O2 -Zrsx32 $<

#######################################################################

begintex.o: ..\begintex.c
	gcc -Zrsx32 -Zmt -c -Wall -O2 ..\begintex.c

beginthr.o: ..\beginthr.c
	gcc -Zrsx32 -Zmt -c -Wall -O2 ..\beginthr.c

thread.o: ..\thread.c
	gcc -Zrsx32 -Zmt -c -Wall -O2 ..\thread.c

#######################################################################

excpt.o: ..\excpt.c
	gcc -Zwin32 -c -Wall -O2 ..\excpt.c

excptex.o: ..\excpt.c
        gcc -Zwin32 -c -Wall -O2 -DRSXNT_SEH -o excptex.o ..\excpt.c

#######################################################################

$(LIB)\winmain.a: winmain.o
	-del $(LIB)\winmain.a
	ar -r $(LIB)\winmain.a winmain.o

$(LIB)\libmain.a: dllentry.o libmain.o
	-del $(LIB)\libmain.a
	ar -r $(LIB)\libmain.a dllentry.o libmain.o

$(LIB)\wthreads.a: beginthr.o thread.o begintex.o
	-del $(LIB)\wthreads.a
	ar -r $(LIB)\wthreads.a beginthr.o thread.o begintex.o

$(LIB)\wemx2.a: dos.o
	-del $(LIB)\wemx2.a
	ar -r $(LIB)\wemx2.a ..\IMPORT#1 dos.o ..\IMPORT#1

$(LIB)\c_dllnrt.a: crt3.o getenv.o dllnrti.o emxenv.o
	-del $(LIB)\c_dllnrt.a
	ar -r $(LIB)\c_dllnrt.a crt3.o getenv.o dllnrti.o emxenv.o ..\IMPORT#1

$(LIB)\dll0w32.o: dll0w32.S
	gcc -c -x assembler-with-cpp -o $(LIB)\dll0w32.o dll0w32.S

$(LIB)\excpt.a: excpt.o excpt1.o
	-del $(LIB)\excpt.a
	ar -r $(LIB)\excpt.a excpt.o excpt1.o

$(LIB)\excpt2.a: excptex.o excpt2.o
        -del $(LIB)\excpt2.a
        ar -r $(LIB)\excpt2.a excptex.o excpt2.o
