#
# /emx/samples/makefile
#
# Note:
#
# To build the `flag' WPS sample with the toolkit 2.1, change to directory
# `som_oidl' and follow the instructions given in `makefile' of that
# directory.
#
# To build the `flag' WPS sample with the toolkit 3.0, change to directory
# `som_idl' and follow the instructions given in `makefile' of that
# directory.
#

CFLAGS=-g -Wall
CC=gcc $(CFLAGS)

.SUFFIXES: .c .m .exe
.PHONY: default all c-samples cpp-samples objc-samples os2-samples sign clean

.c.exe:
	$(CC) $<

.m.exe:
	$(CC) $< -lobjc

default:        c-samples

all:            c-samples cpp-samples objc-samples os2-samples

c-samples:      calc.exe graph.exe eatool.exe msort.exe redir.exe rmdirs.exe \
		qsort.exe sieve.exe stdarg.exe which.exe wm_demo.exe \
		wm_hello.exe wordref.exe

cpp-samples:    sign hello.exe

objc-samples:   objcsamp.exe

os2-samples:    pm1.exe pm2.exe regexx.dll

sign:           sign.dll signtest.exe

clean:
	-del *.exe
	-del *.dll
	-del *.lib
	-del *.o
	-del *.obj
	-del *.res
	-del sign.def

#
# For these samples, the inference rules can be used
#
calc.exe:       calc.c
eatool.exe:     eatool.c
msort.exe:      msort.c
objcsamp.exe:   objcsamp.m
qsort.exe:      qsort.c
rmdirs.exe:     rmdirs.c
sieve.exe:      sieve.c
which.exe:      which.c

#
# graph
#
graph.exe:      graph.c graph.def
	$(CC) graph.c graph.def -lgraph
	emxbind -aq graph -acim

#
# hello (C++ sample)
#
hello.exe:	hello.cc
	$(CC) hello.cc -lstdcpp

#
# redir
#
redir.exe:      redir.o redirlib.o
	$(CC) redir.o redirlib.o
	emxbind -aq redir -p

redir.o:	redir.c redirlib.h
	$(CC) -c redir.c

redirlib.o:	redirlib.c redirlib.h
	$(CC) -c redirlib.c


#
# stdarg
#
stdarg.exe:	stdarg.c
	$(CC) stdarg.c

wm_demo.exe:    wm_demo.c
	$(CC) wm_demo.c -lvideo
	emxbind -aq wm_demo -acm

wm_hello.exe:   wm_hello.c
	$(CC) wm_hello.c -lvideo
	emxbind -aq wm_hello -acm

#
# wordref (BSD database sample)
#
wordref.exe:	wordref.c
	$(CC) wordref.c -ldb

#
# pm1 (small Presentation Manager sample)
#
pm1.exe:        pm1.c pm1.h pm1.def pm1.res
	gcc -Zomf -Zsys -s -Wall pm1.c pm1.def pm1.res

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

#
# pm2 (like pm1, slightly extended)
#
pm2.exe:        pm2.obj pmlib.obj pm2.def pm2.res
	gcc -Zomf -Zsys -s pm2.obj pmlib.obj pm2.def pm2.res

pm2.obj:	pm2.c pm2.h pmlib.h
	gcc -c -Zomf -Wall pm2.c

pmlib.obj:	pmlib.c pmlib.h
	gcc -c -Zomf -Wall pmlib.c

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

#
# regexx.dll (DLL, REXX, and regexp sample)
#
regexx.dll: regexx.c regexx.def
	gcc -Zdll -Zomf -Zso -Zsys -s -O regexx.c regexx.def -lregexp

#
# sign (C++ DLL sample)
#
sign.obj:       sign.cc sign.h
	$(CC) -c sign.cc -Zdll -Zomf -Zcrtdll

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

sign.dll: sign.obj sign.def
	$(CC) -o sign.dll sign.obj sign.def -Zdll -Zomf -Zcrtdll

sign.lib: sign.def
	emximp -o sign.lib sign.def

signtest.exe: signtest.cc sign.lib signtest.def
	$(CC) signtest.cc sign.lib signtest.def -lstdcpp -Zomf -Zcrtdll
