
# define things needed during the make
CC = gcc

OPENGL_DIR = H:/opengl
TCLTK_DIR = H:/tcl805

# There are two ways to compile under OS/2, one way uses .o and
# .a files.  This way uses .obj and .lib files.  gdb only works
# when compiling the other way.  Feel free to read the emx
# documentation and try compiling the other way.

CFLAGS= -I$(OPENGL_DIR)/include -I$(TCLTK_DIR)/include \
        -g -m486 -Zomf -Zmtd
        
# I'm not sure what all these options do, but this works for me.
# If you know more than I do you can fiddle with them.
        
LFLAGS= -Zexe -Zomf -Zmtd -Zstack 32 -Zlinker /BASE:0x10000 \
		-Zlinker /ALIGN:2 -Zlinker /FARCALLTRANSLATION -Zlinker \
		/RUNFROMVDM -Zlinker /EXEPACK

# assumes libpng has been installed in the emx (default lib) directory
LIBS= 	-lpng -L$(OPENGL_DIR)/lib -llibtk -lopengl -L$(TCLTK_DIR)/lib \
        -ltk80 -ltcl80
        
GRLIBS = grsh.obj gr.obj Draw.obj util.obj togl.obj pic.obj

# define how to make the shell 
grsh.exe: $(GRLIBS)
	$(CC) -o grsh $(LFLAGS) $(GRLIBS) $(LIBS) grsh.def

togl.obj: togl.c togl.h
	$(CC) $(CFLAGS) -c togl.c

grsh.obj: grsh.c
	$(CC) $(CFLAGS) -c grsh.c

gr.obj: gr.c
	$(CC) $(CFLAGS) -c gr.c

util.obj: util.c
	$(CC) $(CFLAGS) -c util.c

Draw.obj: Draw.c
	$(CC) $(CFLAGS) -c Draw.c

pic.obj: pic.c
	$(CC) $(CFLAGS) -c pic.c

# || REM is a trick I made up to have del succeed (return no error)
# even if the files aren't there. ... There's probably a better way.
clean:
	del core *.obj *.png grsh || REM
Clean: clean
	del grsh.exe  || REM
