#
# /emx/src/lib/sys/makefile
#
GCC=gcc -O -I/emx/include -I.. -Wall -mprobe $(MT_CCFLAGS)
AR=ar
I=/emx/include/
E=$(I)sys/emx.h
L=\emx\lib\ #
SYSCALLS=syscalls.h $(I)sys/signal.h
ERRNO=$(I)errno.h $(I)sys/errno.h

.SUFFIXES: .obj .s .asm

.SOURCE.c: ..
.SOURCE.h: ..
.SOURCE.s: ..
.SOURCE.asm: ..

.PHONY: clean default dstlib sys sysmt sysst

DSTLIB=$(L)$(DIRNAME)\sys.lib

.c.obj:
	$(GCC) -c -s -Zomf $<

.s.obj:
	$(GCC) -c -s -Zomf $<

#
# Requires MASM 6.0
#
# Without -Fo, MASM writes the output file to the directory of the source file
#
.asm.obj:
	ml -c -nologo -Cx -Fo$@ $<

default:    sys

sys .SEQUENTIAL: sysst sysmt

sysmt .SETDIR=mt:
	$(MAKE) -f ../makefile dstlib DIRNAME=mt MT_CCFLAGS=-D__MT__

sysst .SETDIR=st:
	$(MAKE) -f ../makefile dstlib DIRNAME=st MT_CCFLAGS=

dstlib: $(DSTLIB)

clean:
	-del mt\*.obj $(DELOPT)
	-del st\*.obj $(DELOPT)

brk.obj: brk.c $(SYSCALLS) $(I)os2emx.h $(ERRNO) $(E)
chdir.obj: chdir.c $(SYSCALLS) $(I)os2emx.h $(E)
chdrive.obj: chdrive.c $(SYSCALLS) $(I)os2emx.h $(E)
chmod.obj: chmod.c $(SYSCALLS) $(ERRNO) $(I)os2emx.h $(I)string.h $(E)
chsize.obj: chsize.c $(SYSCALLS) $(I)os2emx.h $(E)
clock.obj: clock.c $(SYSCALLS) $(I)os2emx.h $(E)
close.obj: close.c $(SYSCALLS) $(I)os2emx.h $(E)
dup.obj: dup.c $(SYSCALLS) $(I)os2emx.h $(E)
dup2.obj: dup2.c $(SYSCALLS) $(I)os2emx.h $(E)
emxinit.obj: emxinit.s
emx_ver.obj: emx_ver.s
endthrea.obj: endthrea.c $(SYSCALLS) $(I)os2emx.h $(E)
execname.obj: execname.c $(SYSCALLS) $(I)os2emx.h $(E)
exit.obj: exit.c $(I)os2emx.h
fcntl.obj: fcntl.c $(I)os2emx.h $(ERRNO) $(SYSCALLS) $(E) $(I)fcntl.h \
           $(I)sys/fcntl.h
filefind.obj: filefind.c $(I)os2emx.h $(I)string.h $(ERRNO) $(SYSCALLS) $(E)
filesys.obj: filesys.c $(I)os2emx.h $(ERRNO) $(I)string.h $(SYSCALLS) $(E)
fstat.obj: fstat.c $(SYSCALLS) $(I)os2emx.h $(I)string.h $(I)sys/types.h \
                   $(I)sys/stat.h $(E)
fsync.obj: fsync.c $(I)os2emx.h $(SYSCALLS) $(E)
ftime.obj: ftime.c $(I)os2emx.h $(SYSCALLS) $(I)sys/timeb.h $(I)time.h $(E)
ftruncat.obj: ftruncat.c $(I)os2emx.h $(SYSCALLS) $(E)
getcwd.obj: getcwd.c $(I)os2emx.h $(SYSCALLS) $(E)
getdrive.obj: getdrive.c $(I)os2emx.h $(SYSCALLS) $(E)
getpid.obj: getpid.c $(I)os2emx.h $(SYSCALLS) $(E)
getppid.obj: getppid.c $(I)os2emx.h $(SYSCALLS) $(E)
imphandl.obj: imphandl.c $(E)
init.obj: init.c $(I)os2emx.h $(SYSCALLS) $(I)string.h $(E)
initthre.obj: initthre.c $(SYSCALLS) $(I)os2emx.h $(E)
ioctl1.obj: ioctl1.c $(SYSCALLS) $(I)os2emx.h $(ERRNO) $(E)
ioctl2.obj: ioctl2.c $(SYSCALLS) $(I)os2emx.h $(ERRNO) $(I)sys/ioctl.h $(E)
kill.obj: kill.c $(SYSCALLS) $(ERRNO) $(I)os2emx.h $(E)
lseek.obj: lseek.c $(SYSCALLS) $(I)os2emx.h $(E)
memacces.obj: memacces.c $(SYSCALLS) $(E)
memavail.obj: memavail.c $(E)
mkdir.obj: mkdir.c $(SYSCALLS) $(I)os2emx.h $(E)
newthrea.obj: newthrea.c $(SYSCALLS) $(I)os2emx.h $(E)
nls_memu.obj: nls_memu.c $(SYSCALLS) $(I)os2emx.h $(E)
open.obj: open.c $(SYSCALLS) $(I)os2emx.h $(I)string.h $(ERRNO) $(E)
os_ver.obj: os_ver.c $(E)
p2t.obj: p2t.c $(SYSCALLS) $(I)os2emx.h $(I)time.h $(E)
pause.obj: pause.c $(SYSCALLS) $(I)os2emx.h $(E)
pipe.obj: pipe.c $(SYSCALLS) $(I)os2emx.h $(E)
portacce.obj: portacce.c $(SYSCALLS) $(E)
raise.obj: raise.c $(SYSCALLS) $(I)os2emx.h $(ERRNO) $(I)string.h $(E)
read.obj: read.c $(SYSCALLS) $(I)os2emx.h $(E)
read_kbd.obj: read_kbd.c $(SYSCALLS) $(I)os2emx.h $(E)
remove.obj: remove.c $(SYSCALLS) $(I)os2emx.h $(E)
rename.obj: rename.c $(SYSCALLS) $(I)os2emx.h $(E)
rmdir.obj: rmdir.c $(SYSCALLS) $(I)os2emx.h $(E)
sbrk.obj: sbrk.c $(SYSCALLS) $(I)os2emx.h $(ERRNO) $(E)
scrsize.obj: scrsize.c $(I)os2emx.h $(I)os2thunk.h $(E)
sigactio.obj: sigactio.c $(SYSCALLS) $(I)os2emx.h $(ERRNO) $(E)
signal.obj: signal.c $(SYSCALLS) $(I)os2emx.h $(ERRNO) $(E)
sigpendi.obj: sigpendi.c $(SYSCALLS) $(I)os2emx.h $(ERRNO) $(E)
sigprocm.obj: sigprocm.c $(SYSCALLS) $(I)os2emx.h $(E)
sigsuspe.obj: sigsuspe.c $(SYSCALLS) $(I)os2emx.h $(ERRNO) $(E)
sleep.obj: sleep.c $(SYSCALLS) $(I)os2emx.h $(E)
sleep2.obj: sleep2.c $(SYSCALLS) $(I)os2emx.h $(E)
seterrno.obj: seterrno.c $(SYSCALLS) $(ERRNO)
spawnve.obj: spawnve.c $(SYSCALLS) $(I)stdlib.h $(PROCESS) $(I)string.h \
             $(ERRNO) $(I)os2emx.h $(E)
stat.obj: stat.c $(SYSCALLS) $(I)os2emx.h $(I)string.h $(I)sys/types.h \
                 $(I)sys/stat.h $(ERRNO) $(E)
swchar.obj: swchar.c $(SYSCALLS)
systhrea.obj: systhrea.s
thunk0.obj: thunk0.asm
thunk1.obj: thunk1.asm
ulimit.obj: ulimit.c $(SYSCALLS) $(ERRNO) $(E)
umask.obj: umask.c $(SYSCALLS) $(E)
utimes.obj: utimes.c $(SYSCALLS) $(I)os2emx.h $(I)time.h $(I)sys/time.h \
                     $(I)string.h $(ERRNO) $(E)
unwind.obj: unwind.s
wait.obj: wait.c $(SYSCALLS) $(I)os2emx.h $(E)
waitpid.obj: waitpid.c $(SYSCALLS) $(I)os2emx.h $(E)
write.obj: write.c $(SYSCALLS) $(I)os2emx.h $(E)

$(DSTLIB):  brk.obj chdir.obj chdrive.obj chmod.obj chsize.obj \
    clock.obj close.obj dup.obj dup2.obj emxinit.obj emx_ver.obj \
    endthrea.obj execname.obj exit.obj fcntl.obj filefind.obj filesys.obj \
    fstat.obj fsync.obj ftime.obj ftruncat.obj getcwd.obj \
    getdrive.obj getpid.obj getppid.obj imphandl.obj \
    init.obj initthre.obj ioctl1.obj \
    ioctl2.obj kill.obj lseek.obj memacces.obj memavail.obj \
    mkdir.obj newthrea.obj nls_memu.obj open.obj os_ver.obj p2t.obj \
    pause.obj pipe.obj portacce.obj raise.obj read.obj read_kbd.obj \
    remove.obj rename.obj rmdir.obj sbrk.obj scrsize.obj seterrno.obj \
    sigactio.obj signal.obj sigpendi.obj sigprocm.obj sigsuspe.obj \
    sleep.obj sleep2.obj spawnve.obj stat.obj swchar.obj \
    systhrea.obj thunk0.obj thunk1.obj ulimit.obj umask.obj unwind.obj \
    utimes.obj wait.obj waitpid.obj write.obj
	-del $(DSTLIB)
	emxomfar rc $(DSTLIB) *.obj
