#
# /emx/test/makefile
#
#
# NOTE: Some targets need additional tools, not shipped with emx:
#
# diff  (gnudiff.zip): dst1, gcvt, inet, math1, mktime1, mktime2, printf,
#		       scanf, strptime, strtod, strtol
# sed   (gnused.zip):  dll7
# MASM 6.00A:          c16.dll emxaout1.exe emxaout2.exe emxaout3.exe
# Microsoft C 6.00A:   c16.dll
# Devoloper's Toolkit: msgtest
#
# -------------------- CUSTOMIZATION --------------------
#
# Hostname of a Unix host, for the select2 target
#
UNIXHOST=fidelio
#
# ------------------------- END -------------------------

CFLAGS=-g -Wall
CC0=gcc
CC=$(CC0) $(CFLAGS)
B=/emx/bin/
I=/emx/include/
S=$(I)sys/
IP=/emx/include/cpp/
L=/emx/lib/
LL=\emx\lib\ #
LIBSRC=/emx/src/lib/
SIGNAL=$(I)signal.h $(S)signal.h
FCNTL=$(I)fcntl.h $(S)fcntl.h
ERRNO=$(I)errno.h $(S)errno.h
PROCESS=$(I)process.h $(S)process.h
BUILTIN=$(S)builtin.h $(I)386/builtin.h
LIBS=$(L)crt0.o $(L)st/c.a $(L)gcc.a
LIBSMT=$(L)crt0.o $(L)mt/c.a $(L)gcc.a
LIBP=$(L)stdcpp.a
LIBOS2=$(L)os2.a
LIBBSD=$(L)bsd.a
LIBSYS=$(L)crt0.obj $(L)st/c.lib $(L)gcc.lib $(L)st/sys.lib


.SUFFIXES: .o .c .cc .s .exe

.c.o:
	$(CC) -c $<

.cc.o:
	$(CC) -c $<

.c.s:
	$(CC) -S $<

.o.exe:
	$(CC) -o $*.exe $<

.PHONY:	math3 math3c math3n

default:        reg-all

reg-all:	reg-base reg-os2 reg-tcpip reg-slow
reg-base:	reg-base-auto reg-base-look
reg-tcpip:	reg-tcpip-auto reg-tcpip-look
reg-os2:	reg-os2-auto reg-os2-look
reg-auto:	reg-base-auto reg-tcpip-auto reg-os2-auto
reg-look:	reg-base-look reg-tcpip-look reg-os2-look

#
# All programs but regression tests
#
all-tests:      common plusplus os2only dosonly

common:		access.exe alarm.exe args.exe bsdtest.exe conv.exe \
		coreheap.exe coretest.exe coretst2.exe ctypetst.exe debug.exe \
		dttest.exe dupexec.exe errno.exe exec.exe explode.exe \
		float.exe fls.exe ftwtest.exe fullpath.exe glob1.exe \
		hexdump.exe hw_io.exe longlong.exe malloc3.exe mdecho.exe \
		mftest.exe mkstemp.exe nfiles.exe nls.exe \
		opendir.exe opensize.exe opentest.exe pid.exe printf0.exe \
		retcode.exe sbrk1.exe scanf0.exe sig2.exe sig3.exe \
		sig4.exe sig6.exe sig8.exe \
		sigsegv.exe splitarg.exe stack.exe \
		strftime.exe system.exe swaptest.exe \
		termio.exe timetest.exe tmpnam.exe \
		trunc.exe uname.exe version.exe vftest.exe \
		video.exe wmftest.exe wm_test.exe

dosonly:        hw_mem.exe int10.exe

os2only:	dll-all c16 far16.exe eatest.exe emxaout1.exe emxaout2.exe \
		emxaout3.exe fork.exe forkexec.exe forkwait.exe idle.exe \
		kbd.exe msgtest os2test.exe pmtest1.exe pipe.exe popen.exe \
		read_kbd.exe sbrk1sys.exe select.exe showmem1.exe \
		threads.exe thunk.exe vio.exe write1.exe sockets

c16:            c16.dll c16test1.exe c16test2.exe

dll-all:        dll1 dll2 dll3 dll4 dll5 dll6 dll7 dll8

dll1:           dlltest1.exe testdll1.dll

dll2:           dlltest2.exe testdll2.dll

dll3:           dlltest3.exe testdll3.dll

dll4:           dlltest4.exe testdll4.dll

dll5:           dlltest5.exe testdll5.dll

dll6:           dlltest6.exe testdll6.dll

dll7:           dlltest7.exe testdll7.dll

dll8:           dlltest8.exe testdll8.dll

sockets:        impsockh.exe poorteln.exe sockecho.exe

#
# Make procbuf.exe, dll3, and dll8 last as they require OS/2
#
plusplus:	hello.exe stdio.exe test1.exe test2.exe except.exe \
		procbuf.exe dll3 dll8

msgtest:        msgtest.exe msgtest.msg

clean:
	-del *.o $(DELOPT)
	-del *.exe $(DELOPT)
	-del *.dll $(DELOPT)
	-del *.obj $(DELOPT)
	-del *.map $(DELOPT)
	-del *.msg $(DELOPT)
	-del *.lib $(DELOPT)
	-del *.a $(DELOPT)
	-del coreheap $(DELOPT)
	-del coretest $(DELOPT)
	-del coretest.cor $(DELOPT)
	-del dbcs.out $(DELOPT)
	-del dst1.out $(DELOPT)
	-del forkdll.err $(DELOPT)
	-del forkdll.out $(DELOPT)
	-del gcvt.out $(DELOPT)
	-del inet.out $(DELOPT)
	-del math1.out $(DELOPT)
	-del mktime1.out $(DELOPT)
	-del mktime2.out $(DELOPT)
	-del scanf.out $(DELOPT)
	-del strptime.out $(DELOPT)
	-del stdio1.tst $(DELOPT)
	-del pmtest1 $(DELOPT)
	-del pmtest1.res $(DELOPT)
	-del sbrk2.ao $(DELOPT)
	-del strtod.out $(DELOPT)
	-del strtol.t1 $(DELOPT)
	-del strtol.t2 $(DELOPT)
	-del strtol.t3 $(DELOPT)
	-del strtol.t4 $(DELOPT)
	-del testdll3.def $(DELOPT)
	-del testdll7.def $(DELOPT)
	-del testdll8.def $(DELOPT)
	-del printf.out $(DELOPT)
	-del telltext.tmp $(DELOPT)

access.o:       access.c $(I)stdio.h $(I)io.h $(I)string.h $(I)stdlib.h
alarm.o:        alarm.c $(I)stdio.h $(I)stdlib.h $(I)string.h $(SIGNAL)
args.o:         args.c $(I)stdio.h $(I)stdlib.h
bsdtest.o:      bsdtest.c $(I)stdio.h $(I)stdlib.h
conv.o:         conv.c $(I)stdio.h $(I)stdlib.h $(I)string.h
ctypetst.o:     ctypetst.c $(I)stdio.h $(I)string.h $(I)ctype.h
dttest.o:       dttest.c $(I)stdio.h $(I)stdlib.h $(I)getopt.h $(I)time.h \
                $(S)dirtree.h $(S)param.h
exec.o:         exec.c $(I)stdio.h $(I)string.h $(I)process.h $(SIGNAL) \
                $(S)wait.h $(I)time.h
explode.o:      explode.c $(I)stdio.h $(I)stdlib.h
far16.o:        far16.c $(I)stdio.h $(I)os2.h $(I)os2thunk.h
fullpath.o:     fullpath.c $(I)stdio.h $(I)stdlib.h $(S)param.h \
                $(I)getopt.h
glob1.o:        glob1.c $(I)stdlib.h $(I)stdio.h $(I)string.h $(I)getopt.h \
                $(I)glob.h $(I)assert.h
hexdump.o:      hexdump.c $(I)stdio.h $(I)stdlib.h $(I)io.h $(FCNTL) \
                $(S)ioctl.h
hw_io.o:        hw_io.c $(I)stdio.h $(I)stdlib.h $(S)hw.h $(I)string.h
hw_mem.o:       hw_mem.c $(I)stdio.h $(I)stdlib.h $(S)hw.h $(I)memory.h \
                $(I)io.h
idle.o:         idle.c $(I)stdio.h $(I)process.h $(I)string.h $(I)os2emx.h \
                $(I)stdlib.h
eatest.o:       eatest.c $(I)stdio.h $(I)stdlib.h $(I)string.h $(I)getopt.h \
                $(I)io.h $(S)ea.h
malloc3.o:      malloc3.c $(I)stdio.h $(I)stdlib.h $(I)string.h
mdecho.o:       mdecho.c $(I)stdio.h $(S)moddef.h
mftest.o:       mftest.c $(I)stdio.h $(I)stdlib.h $(I)getopt.h $(ERRNO)
os2test.o:      os2test.c $(I)stdio.h $(I)string.h $(I)os2emx.h
pid.o:          pid.c $(I)stdio.h $(I)process.h
pipe.o:         pipe.c $(I)stdio.h $(I)io.h $(I)process.h $(I)unistd.h \
                $(I)stdlib.h $(FCNTL) $(I)string.h $(SIGNAL) $(S)wait.h
popen.o:        popen.c $(I)stdio.h $(I)stdlib.h $(I)string.h $(I)getopt.h \
                $(S)wait.h
printf0.o:      printf0.c $(I)stdio.h
retcode.o:      retcode.c $(I)stdlib.h
sbrk1.o:        sbrk1.c $(I)stdio.h $(I)stdlib.h $(I)string.h $(I)ulimit.h \
		$(S)uflags.h
select.o:       select.c $(I)stdio.h $(I)io.h $(I)process.h $(I)unistd.h \
                $(I)stdlib.h $(FCNTL) $(I)string.h $(SIGNAL) $(S)ioctl.h \
                $(S)types.h $(S)time.h $(S)wait.h
showmem1.o:     showmem1.c $(I)stdio.h $(I)stdlib.h
sig2.o:         sig2.c $(I)stdio.h $(I)stdlib.h $(SIGNAL) $(I)setjmp.h \
                $(I)process.h
sig3.o:         sig3.c $(I)stdio.h $(I)stdlib.h $(SIGNAL) $(I)setjmp.h
sig4.o:         sig4.c $(I)stdio.h $(I)stdlib.h $(SIGNAL)
sig6.o:         sig6.c $(I)stdio.h $(I)stdlib.h $(I)string.h $(SIGNAL) \
                $(I)setjmp.h $(I)float.h
sigsegv.o:      sigsegv.c $(I)stdio.h $(I)stdlib.h $(SIGNAL)
splitarg.o:     splitarg.c $(I)stdio.h $(I)stdlib.h $(I)string.h
stack.o:        stack.c $(I)stdio.h $(I)stdlib.h $(I)string.h $(SIGNAL) \
                $(I)alloca.h
stdio.o:        stdio.cc $(I)stdio.h $(IP)iostream.h
strftime.o:     strftime.c $(I)stdio.h $(I)time.h $(I)locale.h $(I)string.h \
                $(I)stdlib.h
system.o:       system.c $(I)stdio.h $(I)stdlib.h $(I)string.h $(I)process.h
swaptest.o:     swaptest.c $(I)stdio.h $(I)stdlib.h $(I)io.h
termio.o:       termio.c $(I)stdio.h $(I)stdlib.h $(I)string.h $(I)io.h \
                $(ERRNO) $(SIGNAL) $(I)process.h $(I)setjmp.h $(I)ctype.h \
                $(S)types.h $(S)time.h $(S)termio.h $(I)fcntl.h \
                $(S)ioctl.h $(I)termios.h
test1.o:        test1.cc $(I)stdio.h $(IP)iostream.h
test2.o:        test2.cc $(IP)iostream.h
timetest.o:     timetest.c $(I)stdio.h $(I)time.h $(S)types.h \
                $(S)stat.h $(I)io.h $(I)stdlib.h $(I)ctype.h $(I)string.h \
                $(I)getopt.h
tmpnam.o:       tmpnam.c $(I)stdio.h
trunc.o:        trunc.c $(I)stdio.h $(I)stdlib.h $(I)io.h $(I)getopt.h \
                $(I)fcntl.h
uname.o:        uname.c $(I)stdio.h $(S)utsname.h
video.o:        video.c $(I)stdio.h $(I)stdlib.h $(S)video.h
int10.o:        int10.c $(I)stdio.h $(I)stdlib.h $(I)dos.h
wm_test.o:      wm_test.c $(I)stdio.h $(I)stdlib.h $(I)string.h \
                $(S)video.h $(S)winmgr.h $(S)kbdscan.h

fork.exe:       fork.c $(PROCESS) $(I)stdio.h $(I)string.h $(I)stdlib.h \
		$(I)getopt.h $(SIGNAL) $(I)time.h $(FCNTL) $(S)wait.h $(LIBS)
	$(CC) fork.c

forkexec.exe:	forkexec.c $(I)stdio.h $(I)string.h $(I)unistd.h $(PROCESS) \
		$(LIBS)
	$(CC) forkexec.c

forkwait.exe:	forkwait.c $(I)stdio.h $(I)unistd.h $(PROCESS) $(LIBS)
	$(CC) forkwait.c

msgtest.exe:    msgtest.c
	$(CC) -Zomf msgtest.c

errno.exe:      errno.c $(I)stdio.h $(I)stdlib.h $(I)string.h $(ERRNO) $(LIBS)
	$(CC) errno.c

longlong.exe:     longlong.c $(I)stdio.h $(I)stdlib.h $(LIBS)
	$(CC) longlong.c

mkstemp.exe:	mkstemp.c $(I)stdio.h $(I)unistd.h $(LIBS)
	$(CC) mkstemp.c
	emxbind -aq mkstemp.exe -h40

scanf0.exe:     scanf0.c $(I)stdio.h $(LIBS)
	$(CC) scanf0.c

dupexec.exe:    dupexec.c $(I)stdio.h $(I)stdlib.h $(I)string.h $(I)unistd.h \
                $(FCNTL) $(PROCESS) $(LIBS)
	$(CC) dupexec.c
	emxbind -aq dupexec -p

version.exe:    version.c $(I)stdio.h $(I)stdlib.h $(I)string.h \
		$(I)emx/syscalls.h $(LIBS)
	$(CC) version.c

write1.exe:     write1.c $(I)stdio.h $(I)stdlib.h $(I)string.h \
                $(FCNTL) $(S)types.h $(S)stat.h $(I)unistd.h $(I)io.h \
                $(ERRNO) $(I)getopt.h $(I)emx/io.h $(LIBS)
	$(CC) write1.c

#
# Sockets
#
impsockh.exe: impsockh.c $(I)stdio.h $(I)stdlib.h $(I)unistd.h \
              $(S)types.h $(S)socket.h $(LIBS) $(L)socket.a
	$(CC) impsockh.c -lsocket

poorteln.exe: poorteln.c $(I)stdio.h $(I)stdlib.h $(I)process.h $(I)string.h \
              $(I)io.h $(I)unistd.h $(ERRNO) $(FCNTL) \
              $(S)types.h $(S)socket.h $(S)ioctl.h $(I)netinet/in.h \
              $(I)arpa/inet.h $(I)netdb.h easysock.o $(LIBSMT) $(L)socket.a
	$(CC) -Zmt poorteln.c easysock.o -lsocket

sockecho.exe: sockecho.c $(I)stdio.h $(I)stdlib.h $(I)string.h $(I)signal.h \
              $(FCNTL) $(I)unistd.h $(I)getopt.h $(I)io.h $(ERRNO) \
              $(S)types.h $(S)wait.h $(S)socket.h $(S)ioctl.h \
              $(I)netinet/in.h $(I)arpa/inet.h $(I)netdb.h \
              $(LIBS) $(L)socket.a
	$(CC) -DACCEPT_BROKEN_EINTR sockecho.c -lsocket

#
# Regression tests running automatically
#
# Note that some of the tests need a `diff' tool
#
# Make bigint1s, bigint2, dst1, seektext, and telltext last as those
# tests are slow
#
reg-base-auto:  bigint1f ctrlz1 dbcs divtest fls fnmatch gcvt internal \
		malloc1 math1 math2 math3 mktime1 mktime2 pack pow printf \
		rndheap rwv scanf strptime strtod \
		strtol utf2 sig5 snprintf swab stdio1-auto ungetc \
		string xchg bigint1s bigint2 dst1 seektext telltext

#
# Regression test 1 for internal bigint functions
#
bigint1f: bigint1.exe
	bigint1

bigint1s: bigint1.exe
	@echo Don't panic! This test takes quite a time
	bigint1 -i 40000

bigint1.exe: bigint1.c $(I)stdio.h $(I)stdlib.h $(I)string.h $(I)getopt.h \
		$(I)assert.h $(I)emx/bigint.h $(LIBS) $(LIBBSD)
	$(CC) bigint1.c -lbsd

#
# Regression test 2 for internal bigint functions
#
bigint2: bigint2.exe
	@echo Don't panic! This test takes quite a time
	bigint2

bigint2.exe: bigint2.c $(I)stdio.h $(I)float.h $(I)assert.h \
		$(I)emx/bigint.h $(LIBS)
	$(CC) bigint2.c

#
# Regression test for tell(), lseek(), eof(), fseek(), and ftell()
# for text-mode files ending with Ctrl-Z
#
ctrlz1:	ctrlz1.exe ctrlz1.inp
	ctrlz1

ctrlz1.exe:	ctrlz1.c $(I)stdio.h $(I)stdlib.h $(I)string.h \
		$(I)io.h $(FCNTL) $(S)types.h $(S)stat.h $(LIBS)
	$(CC) ctrlz1.c

#
# Regression test for DBCS processing
#
dbcs: nls.exe dbcs.in dbcs.ok
	nls -bdfm <dbcs.in >dbcs.out
	diff dbcs.out dbcs.ok

nls.exe:	nls.c $(I)stdio.h $(I)stdlib.h $(I)string.h $(I)getopt.h \
		$(I)sys/nls.h $(LIBS)
	$(CC) nls.c

#
# Regression test for div()
#
divtest: divtest.exe
	divtest

divtest.exe:    divtest.c $(I)stdio.h $(I)stdlib.h $(LIBS)
	$(CC) divtest.c

#
# Regression test for daylight saving time
#
dst1:	dst1.exe dst1.ok1 dst1.ok2 dst1.ok3 dst1.ok4 dst1.ok5 dst1.ok6
	@echo Don't panic! The dst1 tests may take several minutes
	dst1 -z "UTC0" >dst1.out
	diff dst1.out dst1.ok1
	dst1 -z "XXX1" >dst1.out
	diff dst1.out dst1.ok2
	dst1 -z "XXX-2" >dst1.out
	diff dst1.out dst1.ok3
	dst1 -z "CET-1CED,3,-1,0,7200,10,-1,0,10800,3600" >dst1.out
	diff dst1.out dst1.ok4
	dst1 -z "XXX9:30YYY,9,2,1,7200,3,2,1,10800,3600" >dst1.out
	diff dst1.out dst1.ok5
	dst1 -z "XXX-9:30YYY,3,0,2,7200,9,0,30,10800,3600" >dst1.out
	diff dst1.out dst1.ok6

dst1.exe: dst1.c $(I)stdio.h $(I)stdlib.h $(I)time.h $(I)limits.h \
		$(I)string.h $(I)emx/time.h $(LIBS)
	$(CC) dst1.c

#
# Regression test for __fls()
#
fls: fls.exe
	fls

fls.exe:	fls.c $(I)assert.h $(BUILTIN) $(LIBS)
	$(CC) fls.c

#
# Regression test for fnmatch()
#
fnmatch: fnmtest.exe fnmtest.inp
	fnmtest -r <fnmtest.inp

fnmtest.exe: fnmtest.c $(I)stdio.h $(I)stdlib.h $(I)string.h \
                $(I)fnmatch.h $(LIBS)
	$(CC) fnmtest.c

#
# Regression test for gcvt()
#
gcvt: gcvt.exe gcvt.inp gcvt.ok
	gcvt <gcvt.inp >gcvt.out
	diff gcvt.ok gcvt.out

gcvt.exe: gcvt.c $(I)stdio.h $(I)stdlib.h $(I)math.h $(LIBS)
	$(CC) gcvt.c

#
# Regression test for internal constants etc.
#
internal: internal.exe
	internal

internal.exe: internal.c $(I)stdio.h $(I)limits.h $(BUILTIN) $(S)fmutex.h \
		$(S)rmutex.h $(S)smutex.h $(I)emx/thread.h $(I)emx/time.h \
		$(LIBS)
	$(CC) -Zmt internal.c

#
# Regression test for malloc()
#
malloc1: malloc1.exe
	malloc1

malloc1.exe:	malloc1.c $(I)stdio.h $(I)stdlib.h $(LIBS)
	$(CC) malloc1.c

#
# Regression test 1 for math functions
#
math1: math1.exe math1.inp math1.ok
	math1 <math1.inp >math1.out
	diff math1.ok math1.out

math1.exe:	math1.c $(I)stdio.h $(I)stdlib.h $(I)math.h $(LIBS)
	$(CC) math1.c

#
# Regression test 2 for math functions
#
math2: math2.exe
	math2

math2.exe:      math2.c $(I)math.h $(I)float.h $(I)assert.h $(LIBS)
	$(CC) math2.c

#
# Regression test 3 for math functions
#
math3: math3c math3n

math3c: math3c.exe
	math3c

math3n: math3n.exe
	math3n

math3c.exe:	math3.c math3c.h math3c.vs math3c.vd math3c.vx \
		$(I)stdio.h $(I)math.h $(I)float.h $(LIBS)
	$(CC) -DHEADER=math3c.h -o math3c.exe math3.c

math3n.exe:	math3.c math3n.h math3n.vs math3n.vd math3n.vx \
		$(I)stdio.h $(I)math.h $(I)float.h $(LIBS)
	$(CC) -DHEADER=math3n.h -o math3n.exe math3.c

#
# Regression test 1 for mktime()
#
mktime1: mktime1.exe mktime1.inp mktime1.ok
	mktime1 <mktime1.inp >mktime1.out
	diff mktime1.out mktime1.ok

mktime1.exe: mktime1.c $(I)stdio.h $(I)stdlib.h $(I)time.h $(I)string.h $(LIBS)
	$(CC) mktime1.c

#
# Regression test 2 for mktime()
#

mktime2: mktime2.exe mktime2.ok1 mktime2.ok2
	mktime2 UTC0 >mktime2.out
	diff mktime2.out mktime2.ok1
	mktime2 CET-1 >mktime2.out
	diff mktime2.out mktime2.ok2

mktime2.exe: mktime2.c $(I)stdio.h $(I)stdlib.h $(I)time.h $(LIBS)
	$(CC) mktime2.c

#
# Regression test for #pragma pack()
#
pack:   pack.exe
	pack

pack.exe:       pack.c $(I)stdio.h $(LIBS)
	$(CC) pack.c

#
# Regression test for pow()
#
pow:	pow.exe
	pow

pow.exe:	pow.c $(I)stdio.h $(I)math.h $(I)float.h $(I)emx/float.h \
		$(LIBS)
	$(CC) pow.c

#
# Regression test for printf()
#
printf: printf.exe
	printf >printf.out
	diff printf.out printf.ok

# Note: Don't use -Wall as this implies -Wformat
printf.exe:     printf.c $(I)stdio.h $(LIBS)
	$(CC0) -g printf.c

#
# Regression test for malloc()
#
rndheap:        rndheap.exe
	@echo Don't panic! This test may take several minutes
	rndheap -a -i20000 -n256 -s32768 -q 1
	rndheap -a -i20000 -n256 -s32768 -q -t 1
	rndheap -a -i10000 -n32 -s128000 -q -t 1
	rndheap -a -i40000 -n8000 -s30 -f1217 -q 1
	rndheap -a -i10000 -n40 -s100000 -q -r 1

rndheap.exe:    rndheap.c $(I)stdio.h $(I)stdlib.h $(I)string.h $(I)malloc.h \
		$(I)getopt.h $(I)emx/umalloc.h $(S)fmutex.h $(S)rmutex.h \
		$(SIGNAL) $(ERRNO) $(BUILTIN) $(LIBS)
	$(CC) -Zmt -DHAVE_ALL rndheap.c

#
# Regression test for readv() and writev()
#
rwv:	rwv.exe
	rwv

rwv.exe:	rwv.c $(I)stdio.h $(I)stdlib.h $(I)string.h \
		$(I)sys/types.h $(I)sys/stat.h \
		$(I)sys/uio.h $(I)unistd.h $(FCNTL) $(LIBS)
	$(CC) rwv.c

#
# Regression test for scanf()
#
scanf:  scanf.exe
	scanf >scanf.out
	diff scanf.out scanf.ok

# Note: Don't use -Wall as this implies -Wformat
scanf.exe:      scanf.c $(I)stdio.h $(I)string.h $(LIBS)
	$(CC0) -g scanf.c

#
# Regression test for fseek() on text streams
#
seektext: seektext.exe testtext.cr testtext.lf
	@echo Don't panic! This test may take several minutes
	seektext testtext.cr
	seektext testtext.lf

seektext.exe:   seektext.c $(I)stdio.h $(I)stdlib.h $(LIBS) $(LIBBSD)
	$(CC) seektext.c -lbsd

#
# Regression test for the return value of signal()
#
sig5:   sig5.exe
	sig5

sig5.exe:       sig5.c $(I)stdio.h $(SIGNAL) $(LIBS)
	$(CC) sig5.c

#
# Regression test for snprintf()
#
snprintf: snprintf.exe
	snprintf

snprintf.exe: snprintf.c $(I)stdio.h $(LIBS)
	$(CC0) -g snprintf.c

#
# Regression tests for stdio
#
stdio1-auto: stdio1.exe
	stdio1 -t stdio1.tst
	-del stdio1.tst
	stdio1 -uf
	stdio1 -us

stdio1-interactive: stdio1.exe
	stdio1 -ud
	stdio1 -i

stdio1.exe: stdio1.c $(I)assert.h $(I)stdio.h $(I)stdlib.h $(I)string.h \
             $(SIGNAL) $(I)unistd.h $(LIBS)
	$(CC) -Zbsd-signals stdio1.c

#
# Regression test for string functions
#
string: string.exe
	string

string.exe:     string.c $(I)assert.h $(I)stdio.h $(I)string.h $(LIBS)
	$(CC) string.c

#
# Regression test for strptime()
#
strptime: strptime.exe strptime.inp strptime.ok
	strptime <strptime.inp >strptime.out
	diff strptime.ok strptime.out

strptime.exe: strptime.c $(I)stdio.h $(I)string.h $(I)time.h $(LIBS)
	$(CC) strptime.c

#
# Regression test for strtod()
#
strtod:	strtod.exe strtod.inp
	strtod <strtod.inp >strtod.out
	diff strtod.out strtod.ok

strtod.exe: strtod.c $(I)stdio.h $(I)stdlib.h $(I)math.h $(I)string.h \
		$(ERRNO) $(LIBS)
	$(CC) strtod.c

#
# Regression test for strtol() and strtoul()
#
strtol:         strtol.exe strtol.in1 strtol.in2 strtol.in3 strtol.in4 \
		strtol.ok1 strtol.ok2 strtol.ok3 strtol.ok4
	strtol s 0 <strtol.in1 >strtol.t1
	strtol u 0 <strtol.in2 >strtol.t2
	strtol s 1 <strtol.in3 >strtol.t3
	strtol u 2 <strtol.in4 >strtol.t4
	diff strtol.ok1 strtol.t1
	diff strtol.ok2 strtol.t2
	diff strtol.ok3 strtol.t3
	diff strtol.ok4 strtol.t4

strtol.exe:     strtol.c $(I)stdio.h $(I)stdlib.h $(I)string.h $(I)errno.h \
                $(LIBS)
	$(CC) strtol.c

#
# Regression test for swab()
#
swab: swab.exe
	swab

swab.exe:	swab.c $(I)stdio.h $(I)stdlib.h $(I)string.h $(LIBS)
	$(CC) swab.c

#
# Regression test for ftell() on text streams
#
telltext: telltext.exe testtext.cr testtext.lf
	@echo Don't panic! This test may take several minutes
	telltext testtext.cr telltext.tmp
	telltext -u testtext.lf telltext.tmp
	-del telltext.tmp

telltext.exe:   telltext.c $(I)stdio.h $(I)stdlib.h $(I)string.h $(LIBS)
	$(CC) telltext.c

#
# Regression test for ungetc()
#
ungetc: ungetc.exe ungetc.inp
	ungetc -sb
	ungetc -b255 -u1 -sb
	ungetc -b3 -u1 -sb -v3
	ungetc -b7 -u1 -sb -v7
	ungetc -b13 -u1 -sb -v13
	@echo Don't panic! The following 3 tests may take several minutes
	ungetc -sb -r10000
	ungetc -b255 -u1 -sb -r10000
	ungetc -b7 -u1 -sb -r10000 -v7

ungetc.exe: ungetc.c $(I)stdio.h $(I)stdlib.h $(I)string.h $(LIBS)
	$(CC) ungetc.c

#
# Regression test for mblen(), mbtowc(), wctomb(), mbstowcs(), and wcstombs()
#
utf2: utf2.exe
	utf2 -c
	utf2 -s

utf2.exe:       utf2.c $(I)stdio.h $(I)stdlib.h $(I)string.h \
                $(I)limits.h $(I)emx/locale.h $(LIBS) $(LIBBSD)
	$(CC) utf2.c -lbsd

#
# Regression test for __cxchg(), __lxchg(), and __sxchg()
#
xchg:	xchg1.exe xchg2.exe
	xchg1
	xchg2

xchg1.exe: xchg.c $(I)stdlib.h $(I)assert.h $(BUILTIN)
	gcc -o xchg1.exe -Wall -O2 xchg.c

xchg2.exe: xchg.c $(I)stdlib.h $(I)assert.h $(BUILTIN)
	gcc -o xchg2.exe -Wall xchg.c

#
# Regression tests running automatically, OS/2 required
#
# Note that some of the tests need a `diff' tool
#
reg-os2-auto: forkdll probe sbrk2 stdio3

#
# Verify that fork() duplicates DLL data
#
forkdll: forkdll.exe forkdll.ok
	forkdll forkdll.c >forkdll.out 2>forkdll.err
	diff forkdll.out forkdll.c
	diff forkdll.err forkdll.ok

forkdll.exe: forkdll.c $(I)stdio.h $(I)stdlib.h $(I)unistd.h $(I)getopt.h \
		$(S)types.h $(S)wait.h $(I)emx/syscalls.h
	gcc -Zcrtdll -g -Wall forkdll.c

#
# Check stack probes
#
probe: probe.exe
	probe

probe.exe: probe.c $(I)os2emx.h $(I)stdio.h $(I)stdlib.h
	gcc -g -Wall -mprobe probe.c

#
# Regression test for sbrk() and brk()
#
sbrk2: sbrk2.exe sbrk2sys.exe
	sbrk2 -c
	sbrk2 -m
	sbrk2 -a
	sbrk2sys -c
	sbrk2sys -m
	sbrk2sys -a

sbrk2.exe: sbrk2.c $(I)os2emx.h $(I)stdio.h $(I)stdlib.h $(I)stdarg.h \
		$(I)ulimit.h $(I)assert.h $(I)signal.h $(I)setjmp.h \
		$(S)uflags.h $(LIBS)
	$(CC) -DHEAPSIZE=0x100000 -o sbrk2.ao sbrk2.c
	emxbind -bq -h1 sbrk2.ao
	del sbrk2.ao

sbrk2sys.exe: sbrk2.c $(I)os2emx.h $(I)stdio.h $(I)stdlib.h $(I)stdarg.h \
		$(I)ulimit.h $(I)assert.h $(I)signal.h $(I)setjmp.h \
		$(S)uflags.h $(LIBSYS)
	$(CC) -Zomf -Zsys -DSYS -DHEAPSIZE=0x100000 -o sbrk2sys.exe sbrk2.c

#
# Regression test for thread-safe streams
#
stdio3:	stdio3.exe
	stdio3

stdio3.exe: stdio3.c $(I)stdio.h $(I)stdlib.h $(I)unistd.h $(PROCESS) \
		$(I)assert.h $(LIBSMT)
	$(CC) -Zmt stdio3.c

#
# Regression tests running automatically, TCP/IP required
#
# Note that some of the tests need a `diff' tool
#

reg-tcpip-auto: byteord close1 hreloc inet select2

#
# Regression test for htonl(), htons(), ntohl(), and ntohs()
#
byteord: byteord.exe
	byteord

byteord.exe: byteord.c $(I)stdio.h $(S)types.h $(I)netinet/in.h \
             $(LIBS) $(L)socket.a
	$(CC) byteord.c -lsocket

#
# Regression test for close_handle() of emx.dll
#
close1:  close1.exe
	close1

close1.exe: close1.c $(I)stdio.h $(I)stdlib.h $(I)unistd.h $(FCNTL) $(ERRNO) \
            $(S)types.h $(S)socket.h $(S)ioctl.h $(LIBS) $(L)socket.a
	$(CC) close1.c -lsocket

#
# Regression test for handle relocation caused by socket()
#
hreloc: hreloc.exe
	hreloc

hreloc.exe: hreloc.c $(I)stdio.h $(I)string.h $(I)unistd.h \
		$(ERRNO) $(S)fcntl.h $(S)types.h $(S)stat.h $(S)socket.h \
		$(LIBS) $(L)socket.a
	$(CC) hreloc.c -lsocket

#
# Regression test for inet_addr(), inet_network(), and inet_ntoa()
#
inet: inet.exe inet.inp inet.ok
	inet <inet.inp >inet.out
	diff inet.out inet.ok

inet.exe: inet.c $(I)stdio.h $(I)string.h $(S)types.h $(I)netinet/in.h \
          $(I)arpa/inet.h $(LIBS) $(L)socket.a
	$(CC) inet.c -lsocket

#
# Regression test for writefds vs. readfds of select()
#
# Using `sockecho -b' as server should also work
#
select2: select2.exe
	select2 -t $(UNIXHOST) daytime

# Note: compile with -Zmt as easysock.o is compiled with -Zmt
select2.exe:	select2.c $(I)stdio.h $(I)stdlib.h $(I)string.h $(I)io.h \
		$(S)types.h $(S)socket.h $(I)netinet/in.h $(I)arpa/inet.h \
		easysock.h easysock.o $(LIBS) $(L)socket.a
	$(CC) -Zmt select2.c easysock.o -lsocket

#
# Regression tests where a human must check the output
#
reg-base-look: dup malloc2 mtff sig1 sig7 sig8

dup:	dup.exe
	dup

dup.exe:        dup.c $(I)stdio.h $(I)stdlib.h $(I)string.h $(I)unistd.h \
                $(FCNTL) $(ERRNO) $(LIBS)
	$(CC) dup.c

malloc2: malloc2.exe
	malloc2
	malloc2 -b

malloc2.exe:	malloc2.c $(I)stdio.h $(I)stdlib.h $(I)assert.h $(I)umalloc.h
	$(CC) malloc2.c

mtff:	mtff.exe
	@echo This should list 10 files matching *.h
	mtff -p 2 *.h *.xyz

mtff.exe:	mtff.c $(I)stdio.h $(I)stdlib.h $(I)stddef.h $(I)os2emx.h \
		$(I)emx/syscalls.h $(LIBSMT)
	$(CC) -Zmt mtff.c

sig1:	sig1.exe
	-sig1 1
	-sig1 16

sig1.exe:	sig1.c $(I)stdio.h $(SIGNAL) $(LIBS)
	$(CC) sig1.c

sig7:	sig7.exe
	-sig7

sig7.exe:       sig7.c $(I)stdio.h $(I)stdlib.h $(SIGNAL) $(I)setjmp.h $(LIBS)
	$(CC) sig7.c

sig8:	sig8.exe
	-sig8

sig8.exe:       sig8.c $(I)stdio.h $(I)stdlib.h $(SIGNAL) $(LIBS)
	$(CC) sig8.c -Zsysv-signals

#
# Regression tests where a human must check the output, OS/2 required
#
reg-os2-look: forkmt

#
# Regression test for inheritance of _rmutex semaphores
#
forkmt:	forkmt.exe
	forkmt

forkmt.exe:	forkmt.c $(I)stdio.h $(I)stdlib.h $(I)unistd.h $(S)types.h \
		$(S)wait.h $(BUILTIN) $(S)fmutex.h $(S)rmutex.h $(LIBSMT)
	gcc -g -O -Zmt forkmt.c

#
# Regression tests where a human must check the output, TCP/IP required
#

reg-tcpip-look: mtsock sockioct

mtsock:	mtsock.exe
	mtsock >nul

mtsock.exe:	mtsock.c $(I)stdio.h $(I)stdlib.h $(I)stddef.h $(I)unistd.h \
		$(FCNTL) $(I)io.h $(S)types.h $(S)socket.h \
		$(LIBSMT) $(L)socket.a
	$(CC) -Zmt mtsock.c -lsocket

sockioct: sockioct.exe
	sockioct -c

sockioct.exe: sockioct.c $(I)stdio.h $(I)stdlib.h $(I)string.h $(I)unistd.h \
              $(S)types.h $(S)socket.h $(S)ioctl.h $(I)net/if.h \
              $(I)netinet/in.h $(I)arpa/inet.h $(I)netdb.h easysock.h \
              easysock.o $(LIBS) $(L)socket.a
	$(CC) -Zmt sockioct.c easysock.o -lsocket

#
# Extremely slow regression tests
#
reg-slow: spawn1

spawn1:	spawn1.exe
	@echo Don't panic! This test may take several minutes
	spawn1

spawn1.exe: spawn1.c $(I)stdio.h $(I)stdlib.h $(I)process.h $(LIBS)
	$(CC) spawn1.c

#
# _cdecl thunks
#
# Required tools: Microsoft C 6.00A and MASM 6.00A
#
c16test1.exe: c16test1.o c16.a
	$(CC) c16test1.o c16.a

c16test2.exe: c16test2.o c16.a
	$(CC) c16test2.o c16.a

c16test1.o: c16test1.c
	$(CC) -c c16test1.c

c16test2.o: c16test2.c
	$(CC) -c c16test2.c

c16.dll: c16init.obj c16.obj c16.def
	link c16init c16 /align:16 /nod,c16.dll,nul,,c16.def

c16init.obj: c16init.asm
	@echo MASM 6.00A required!
	ml -c -W3 c16init.asm

c16.obj: c16.c
	@echo Microsoft C 6.0 required!
	cl -c -Lp -Alfu -G2s -W4 c16.c

c16.a: c16.imp
	emximp -o c16.a c16.imp

#
# mkmsgf comes with the "IBM Developer's Toolkit for OS/2 2.0"
#
msgtest.msg:    msgtest.txt
	@echo mkmsgf required!
	mkmsgf msgtest.txt msgtest.msg

#
# dll1: DLL without runtime environment
#
testdll1.dll: testdll1.c testdll1.def $(LIBS) $(LIBOS2)
	$(CC) -Zdll -Zomf -Zno-rte -s testdll1.c testdll1.def

dlltest1.exe:   dlltest1.c imp1.o
	$(CC) dlltest1.c imp1.o

imp1.o:         testdll1.imp
	emximp -a testdll1.imp

#
# dll2: DLL without runtime environment; test shared/instance data
#
CFLAGS_TESTDLL2 = -Zdll -Zomf -Zno-rte

testdll2.obj: testdll2.c
	$(CC) $(CFLAGS_TESTDLL2) -c testdll2.c

private.obj: private.c
	$(CC) -c private.c
	emxomf -DPRIV private.o

testdll2.dll: testdll2.obj private.obj testdll2.def
	$(CC) $(CFLAGS_TESTDLL2) testdll2.obj private.obj testdll2.def

testdll2.lib: testdll2.def
	emximp -o testdll2.lib testdll2.def

dlltest2.exe: dlltest2.c testdll2.lib
	$(CC) -Zomf dlltest2.c testdll2.lib

#
# dll3: DLL using C runtime DLL; test constructors/destructors in DLL
#
CFLAGS_TESTDLL3 = -Zdll -Zomf -Zmt -Zcrtdll

testdll3.obj: testdll3.cc testdll3.h
	$(CC) -c $(CFLAGS_TESTDLL3) testdll3.cc

testdll3.def: testdll3.df testdll3.obj
	copy testdll3.df testdll3.def
	emxexp testdll3.obj >>testdll3.def

testdll3.dll: testdll3.obj testdll3.def
	$(CC) $(CFLAGS_TESTDLL3) testdll3.obj testdll3.def -lwrap

testdll3.lib: testdll3.def
	emximp -o testdll3.lib testdll3.def

dlltest3.exe: dlltest3.cc testdll3.h testdll3.lib
	$(CC) -Zomf -Zmt -Zcrtdll dlltest3.cc testdll3.lib

#
# dll4: partial custom C runtime DLL
#
testdll4.dll: testdll4.c testdll4.h testdll4.def
	$(CC) -Zomf -Zdll -Zmt testdll4.c testdll4.def

testdll4.lib: testdll4.def
	emximp -o testdll4.lib testdll4.def

dlltest4.obj: dlltest4.c testdll4.h
	$(CC) -Zomf -Zmt -Zcrtdll -c dlltest4.c

dlltest4.exe: dlltest4.obj testdll4.lib
	$(CC) -Zomf -Zmt -Zcrtdll=testdll4 -L. dlltest4.c

#
# dll5: Stand-alone DLL; test RTE initialization
#
testdll5.dll: testdll5.c testdll5.h testdll5.def
	$(CC) -Zdll -Zomf -Zso -Zsys testdll5.c testdll5.def

dlltest5.exe: dlltest5.c testdll5.h testdll5.lib
	$(CC) dlltest5.c testdll5.lib -Zomf

testdll5.lib: testdll5.def
	emximp -o testdll5.lib testdll5.def

#
# dll6: single-thread custom C runtime DLL, with _DLL_InitTerm()
#
testdll6.dll: testdll6.c testdll6.h testdll6.def
	$(CC) -Zomf -Zdll testdll6.c testdll6.def

testdll6.lib: testdll6.def
	emximp -o testdll6.lib testdll6.def

dlltest6.exe: dlltest6.c testdll6.h testdll6.lib
	$(CC) -Zomf dlltest6.c -Zcrtdll=testdll6

#
# dll7: complete custom C runtime DLL which does not use emx.dll (-Zsys)
#
# Required tools: sed
#
testdll7.dll: testdll7.c testdll7.h testdll7.def
	$(CC) -Zomf -Zmt -Zsys -Zdll testdll7.c testdll7.def

testdll7.def: testdll7.df $(LL)cdll.def
	copy testdll7.df testdll7.def
	sed -e "1,/EXPORTS/d" -e "/{EMX}/d" -e "/{ST}/d" <$(LL)cdll.def >>testdll7.def

testdll7.lib: testdll7.def
	emximp -o testdll7.lib testdll7.def

dlltest7.obj: dlltest7.c testdll7.h
	$(CC) -Zomf -Zmt -Zcrtdll -c dlltest7.c

dlltest7.exe: dlltest7.obj testdll7.lib
	$(CC) -Zomf -Zmt -Zcrtdll=testdll7 -L. dlltest7.c

#
# dll8: DLL using C runtime DLL; test constructors/destructors in DLL
#       same as dll3, but use emxbind
#
CFLAGS_TESTDLL8 = -Zdll -Zmt -Zcrtdll

testdll8.o: testdll8.cc testdll8.h
	$(CC) -c $(CFLAGS_TESTDLL8) testdll8.cc

testdll8.def: testdll8.df testdll8.o
	copy testdll8.df testdll8.def
	emxexp testdll8.o >>testdll8.def

testdll8.dll: testdll8.o testdll8.def
	$(CC) $(CFLAGS_TESTDLL8) testdll8.o testdll8.def -lwrap

testdll8.a: testdll8.def
	emximp -o testdll8.imp testdll8.def
	emximp -o testdll8.a testdll8.imp
	del testdll8.imp

dlltest8.exe: dlltest8.cc testdll8.h testdll8.a
	$(CC) -Zmt -Zcrtdll dlltest8.cc testdll8.a


# Test emxaout
#
# Required tools: MASM 6.00A
#
emxaout1.exe: emxaout1.asm
	@echo MASM 6.00A required!
	ml -c emxaout1.asm
	emxaout emxaout1.obj
	gcc -Zomf emxaout1.obj

emxaout2.exe: emxaout2.asm
	@echo MASM 6.00A required!
	ml -c emxaout2.asm
	emxaout emxaout2.obj
	gcc -Zomf emxaout2.obj

emxaout3.exe: emxaout3.asm
	@echo MASM 6.00A required!
	ml -c emxaout3.asm
	emxaout emxaout3.obj
	gcc -Zomf emxaout3.obj

#
# Modules used by multiple programs
#
showmem.o:      showmem.c $(I)stdio.h $(I)stdlib.h $(I)os2emx.h

easysock.o:	easysock.c $(I)stdio.h $(I)stdlib.h $(I)string.h $(I)ctype.h \
		$(S)types.h $(S)socket.h $(I)netinet/in.h $(I)arpa/inet.h \
		$(I)netdb.h easysock.h
	$(CC) -Zmt -c easysock.c

#
# Find the number of available file handles and C streams
#
nfiles.exe:	nfiles.c $(I)stdio.h $(I)stdlib.h $(I)string.h \
		$(I)io.h $(FCNTL) $(I)os2emx.h $(LIBS)
	$(CC) nfiles.c

#
# PM test program
#
pmtest1.exe:        pmtest1 pmtest1.res
	emxbind -bpq -rpmtest1.res /emx/bin/emxl pmtest1

pmtest1:            pmtest1.o $(LIBS) $(LIBOS2)
	$(CC) -o pmtest1 pmtest1.o

pmtest1.o:      pmtest1.c pmtest1.h $(I)stdio.h $(I)os2emx.h

pmtest1.res:        pmtest1.rc pmtest1.h
	rc -r -i \emx\include pmtest1.rc

#
#
#

access.exe:     access.o $(LIBS)
	$(CC) access.o

alarm.exe:      alarm.o $(LIBS)
	$(CC) alarm.o

args.exe:       args.o $(LIBS)
	$(CC) args.o

bsdtest.exe:    bsdtest.o $(LIBS) $(LIBBSD)
	$(CC) bsdtest.o -lbsd

conv.exe:       conv.o $(LIBS)
	$(CC) conv.o

coreheap.exe:	coreheap.c $(I)stdio.h $(I)stdlib.h $(LIBS)
	$(CC) -o coreheap coreheap.c
	emxbind -b -h1 coreheap

coretest:       coretest.c $(I)stdio.h $(I)stdlib.h $(I)io.h $(FCNTL) \
                $(S)types.h $(S)stat.h $(SIGNAL) $(I)string.h $(LIBS)
	$(CC) -o coretest coretest.c

coretest.exe:   coretest
	emxbind $(B)emxl coretest

coretest.cor:   coretest.exe
	coretest

coretst2.exe:   coretest coretest.cor
	emxbind -ccoretest.cor -o coretst2 coretest

ctypetst.exe:   ctypetst.o $(LIBS)
	$(CC) ctypetst.o

debug.exe:      debug.c $(I)stdio.h $(I)string.h $(I)process.h $(S)ptrace.h \
		$(S)reg.h $(S)user.h $(I)stdlib.h $(S)wait.h $(LIBS)
	$(CC) debug.c

dttest.exe:     dttest.o $(LIBS)
	$(CC) dttest.o

exec.exe:       exec.o $(LIBS)
	$(CC) exec.o
	emxbind -aq exec -p

explode.exe:    explode.o $(LIBS)
	$(CC) explode.o

far16.exe:      far16.o $(LIBS) $(LIBOS2)
	$(CC) far16.o

float.exe:	float.c $(I)stdio.h $(I)float.h $(LIBS)
	$(CC) float.c

ftwtest.exe:	ftwtest.c $(I)stdio.h $(S)types.h $(S)stat.h \
		$(I)ftw.h $(LIBS)
	$(CC) ftwtest.c

fullpath.exe:   fullpath.o $(LIBS)
	$(CC) fullpath.o

glob1.exe:      glob1.o $(LIBS)
	$(CC) glob1.o

hello.exe:      hello.cc $(IP)iostream.h $(LIBS) $(LIBP)
	$(CC) hello.cc -lstdcpp

hexdump.exe:    hexdump.o $(LIBS)
	$(CC) hexdump.o

hw_io.exe:      hw_io.o $(LIBS)
	$(CC) hw_io.o
	emxbind -aq hw_io -ai

hw_mem.exe:     hw_mem.o $(LIBS)
	$(CC) hw_mem.o
	emxbind -aq hw_mem -am -p

idle.exe:       idle.o $(LIBS) $(LIBOS2)
	$(CC) idle.o

kbd.exe:        kbd.c $(LIBS) $(LIBOS2)
	$(CC) kbd.c -Zomf -Zsys

eatest.exe:     eatest.o $(LIBS) $(LIBOS2)
	$(CC) eatest.o

malloc3.exe:    malloc3.o $(LIBS)
	$(CC) malloc3.o

mdecho.exe:     mdecho.o $(LIBS) $(L)moddef.a
	$(CC) mdecho.o -lmoddef

mftest.exe:      mftest.o $(LIBS)
	$(CC) mftest.o

os2test.exe:    os2test.o $(LIBS) $(LIBOS2)
	$(CC) os2test.o

pid.exe:        pid.o $(LIBS)
	$(CC) pid.o

pipe.exe:       pipe.o $(LIBS)
	$(CC) pipe.o

popen.exe:      popen.o $(LIBS)
	$(CC) popen.o

printf0.exe:    printf0.o $(LIBS)
	$(CC) printf0.o

procbuf.exe:	procbuf.cc $(IP)iostream.h $(LIBS) $(LIBP)
	$(CC) procbuf.cc -lstdcpp

read_kbd.exe:   read_kbd.c
	$(CC) -O read_kbd.c -Zomf -Zsys

retcode.exe:    retcode.o $(LIBS)
	$(CC) retcode.o

sbrk1.exe:      sbrk1.o showmem.o $(LIBS)
	$(CC) sbrk1.o showmem.o

sbrk1sys.exe:   sbrk1.c showmem.c $(LIBSYS)
	$(CC) -Zomf -Zsys -DSYS -DHEAPSIZE=0x100000 -o sbrk1sys.exe \
		sbrk1.c showmem.c

select.exe:     select.o $(LIBS)
	$(CC) select.o

showmem1.exe:    showmem1.o showmem.o $(LIBS) $(LIBOS2)
	$(CC) showmem1.o showmem.o

sig2.exe:       sig2.o $(LIBS)
	$(CC) sig2.o

sig3.exe:       sig3.o $(LIBS)
	$(CC) sig3.o

sig4.exe:       sig4.o $(LIBS)
	$(CC) sig4.o

sig6.exe:       sig6.o $(LIBS)
	$(CC) sig6.o

sigsegv.exe:    sigsegv.o $(LIBS)
	$(CC) sigsegv.o

splitarg.exe:   splitarg.o $(LIBS)
	$(CC) splitarg.o

stack.exe:      stack.o $(LIBS)
	$(CC) stack.o

stdio.exe:      stdio.o $(LIBS) $(LIBP)
	$(CC) stdio.o -lstdcpp

strftime.exe:   strftime.o $(LIBS)
	$(CC) strftime.o

system.exe:     system.o $(LIBS)
	$(CC) system.o
	emxbind -aq system -p

swaptest.exe:   swaptest.o $(LIBS)
	$(CC) swaptest.o

termio.exe:     termio.o $(LIBS)
	$(CC) termio.o

test1.exe:      test1.o $(LIBS) $(LIBP)
	$(CC) test1.o -lstdcpp

test2.exe:      test2.o $(LIBS) $(LIBP)
	$(CC) test2.o -lstdcpp

except.exe:	except.cc $(LIBS) $(LIBP)
	$(CC) -fhandle-exceptions except.cc -lstdcpp

threads.exe:    threads.c $(I)stdio.h $(I)stdlib.h $(I)string.h \
                $(I)ctype.h $(I)getopt.h $(I)os2emx.h
	$(CC) threads.c -Zomf -Zmts

thunk.exe:      thunk.c $(I)os2thunk.h
	$(CC) thunk.c

timetest.exe:   timetest.o $(LIBS)
	$(CC) timetest.o

tmpnam.exe:     tmpnam.o $(LIBS)
	$(CC) tmpnam.o

trunc.exe:      trunc.o $(LIBS)
	$(CC) trunc.o

uname.exe:      uname.o $(LIBS)
	$(CC) uname.o

vftest.exe:     vftest.o $(LIBS) $(L)video.a
	$(CC) vftest.o -lvideo
	emxbind -aq vftest -acm

video.exe:      video.o $(LIBS) $(L)video.a
	$(CC) video.o -lvideo
	emxbind -aq video -acm

vio.exe:        vio.c
	$(CC) -O vio.c -Zomf -Zmtd

int10.exe:      int10.o $(LIBS)
	$(CC) int10.o
	emxbind -aq int10 -ac

wmftest.exe:    wmftest.o $(LIBS) $(L)video.a
	$(CC) wmftest.o -lvideo
	emxbind -aq wmftest -acm

wm_test.exe:    wm_test.o $(LIBS) $(L)video.a
	$(CC) wm_test.o -lvideo
	emxbind -aq wm_test -acm

opendir.exe:	opendir.c $(I)stdio.h $(S)types.h $(I)dirent.h $(S)dirent.h \
		$(LIBS)
	$(CC) opendir.c

opensize.exe:   opensize.c $(I)stdio.h $(I)stdlib.h $(I)string.h \
		$(I)io.h $(FCNTL) $(ERRNO) $(S)types.h $(S)stat.h $(LIBS)
	$(CC) opensize.c

opentest.exe:   opentest.c $(I)stdio.h $(I)stdlib.h $(I)string.h \
		$(I)io.h $(FCNTL) $(ERRNO) $(S)types.h $(S)stat.h $(LIBS)
	$(CC) opentest.c
