#
# /emx/samples/makefile
#
CFLAGS=-g -Wall
CC=gcc $(CFLAGS)

.SUFFIXES: .c .m .exe

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

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

default:        c-samples

all:            c-samples cpp-samples objc-samples

c-samples:      calc.exe graph.exe eatool.exe sieve.exe sort.exe \
                which.exe wm_demo.exe wm_hello.exe

cpp-samples:    sign

objc-samples:   objcsamp.exe

sign:           sign.dll signtest.exe

wps:            flag
flag:           flag.dll

clean:
	-del *.exe
	-del *.dll
	-del *.lib
	-del *.o
	-del *.obj
	-del sign.def
	-del flag.cs2
	-del flag.def
	-del flag.h
	-del flag.ih
	-del flag.ph
	-del flag.psc
	-del flag.res
	-del flag.sc

calc.exe:       calc.c
eatool.exe:     eatool.c
objcsamp.exe:   objcsamp.m
sieve.exe:      sieve.c
sort.exe:       sort.c
which.exe:      which.c

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

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

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

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

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 -Zmtd

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

signtest.exe: signtest.cc sign.lib signtest.def
	$(CC) -o signtest.exe signtest.cc sign.lib signtest.def -liostream -Zomf

#
# Flag (Workplace Shell sample)
#
############################################################
# The IBM Programmer's Toolkit for OS/2 2.1 is required!!! #
############################################################
#
# Building and installing the Flag sample:
#
# 1. Include the path name of the Toolkit headers in the INCLUDE,
#    SMINCLUDE and C_INCLUDE_PATH environment variables
#
# 2. Type "SET SMEMIT=H;IH;PH;PSC;CS2;DEF" to tell SC what files to
#    emit
#
# 3. Type "dmake flag" to build flag.dll
#
# 4. Type "flag install" to register the Flag class of flag.dll
#
# 5. Type "flag create FlagTest" to create a Flag object named FlagTest
#    on the desktop
#
# Removing the Flag class:
#
# 1. Delete all Flag objects
#
# 2. Type "flag uninstall" to deregister the Flag class
#
# 3. Reboot to unload flag.dll.  You don't need this step unless you want
#    to overwrite or delete flag.dll
#

flag.ih: flag.csc
	sc -r flag.csc

flag.res: flag.rc flag.ih
	rc -r flag.rc

flag.obj: flag.c flag.ih
	gcc -c -Zomf -Zsys -Zdll -Zc++-comments flag.c

flagdlg.obj: flagdlg.c flag.ih
	gcc -c -Zomf -Zsys -Zdll -Zc++-comments flagdlg.c

flag.dll: flag.obj flagdlg.obj flag.res flag.def
	gcc -Zomf -Zsys -Zdll -o flag.dll flag.obj flagdlg.obj flag.def flag.res
