# $Id: Makefile.unx,v 1.7 2003/12/08 22:20:49 j_ali Exp $
# Copyright (c) Slash'EM Development Team 2002-2003
# NetHack may be freely redistributed.  See license for details.
#
# This makefile is for making gtkhack, a seperate program which talks
# to a game executable using the NhExt protocol.

AWK = awk
CC = gcc

# Where the NhProxy library is installed.
NHPROXYLIB = ../../src
# and its associated header files.
NHPROXYINC = ../../include

# The pkg-config executable
PKG_CONFIG = pkg-config
# A semi-colon seperated list of directories to add to PKG_CONFIG_PATH
# so that pkg-config can find the package config files (eg., gtk+-2.0.pc).
PKG_CONFIG_PATH = /usr/devel/lib/pkgconfig
# The pkg-config commands
GTKCFLAGS = $(PKG_CONFIG) --cflags gtk+-2.0
GTKLIBS = $(PKG_CONFIG) --libs gtk+-2.0

# Debugging
CFLAGS = -g -I$(NHPROXYINC) -DGTKHACK
LFLAGS = -g

#CFLAGS = -O -I$(NHPROXYINC) -DGTKHACK
#LFLAGS =

LIBS = -lpthread

# ----------------------------------------
#
# Nothing below this line should have to be changed.

# timestamps for primary header files, matching src/Makefile
CONFIG_H = ../../src/config.h-t
HACK_H  = ../../src/hack.h-t

all:	gtkhack

.c.o:
	$(CC) `$(GTKCFLAGS)` $(CFLAGS) -c $<

CSRC = gtkhack.c gtk.c gtkgetlin.c gtkstatus.c gtkmenu.c gtkyn.c gtkextcmd.c \
	gtkmap.c gtkmessage.c gtkmisc.c gtktile.c xshmmap.c gtkext.c \
	gtkhackrc.c gtkprefs.c panic.c gtkconnect.c gtkconcb.c gtksupport.c \
	gtkprogress.c
OBJS = gtkhack.o gtk.o gtkgetlin.o gtkstatus.o gtkmenu.o gtkyn.o gtkextcmd.o \
	gtkmap.o gtkmessage.o gtkmisc.o gtktile.o xshmmap.o gtkext.o \
	gtkhackrc.o gtkprefs.o panic.o gtkconnect.o gtkconcb.o gtksupport.o \
	gtkprogress.o

gtkhack:	$(OBJS) $(NHPROXYLIB)/nhproxy.a
	$(CC) `$(GTKLIBS)` $(LFLAGS) -o $@ $(OBJS) $(NHPROXYLIB)/nhproxy.a $(LIBS)

clean:
	$(RM) *.o gtkhack

spotless:	clean

depend: ../../sys/unix/depend.awk $(CSRC) 
	$(AWK) -f ../../sys/unix/depend.awk ../../include/*.h $(CSRC) | \
	sed -e 's:\.\./include:\.\./\.\./include:g' -e 's:\.\./win/gtk/::g' \
	  -e 's:touch:@echo /**/ >>:' > makedep
	@echo '/^# DO NOT DELETE THIS LINE OR CHANGE ANYTHING BEYOND IT/+2,$$d' >eddep
	@echo '$$r makedep' >>eddep
	@echo 'w' >>eddep
	@cp Makefile.unx Makefile.bak
	ed - Makefile.unx < eddep
	ed - Makefile.w32 < eddep
	@rm -f eddep makedep
	@echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile.unx
	@echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile.unx
	@echo '# see make depend above' >> Makefile.unx
	@echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile.w32
	@echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile.w32
	@echo '# see Makefile.unx' >> Makefile.w32
	- diff Makefile.bak Makefile.unx
	@rm -f Makefile.bak

# DO NOT DELETE THIS LINE OR CHANGE ANYTHING BEYOND IT

# config.h timestamp
$(CONFIG_H): ../../include/config.h
	@echo /**/ >> $(CONFIG_H)
# hack.h timestamp
$(HACK_H): ../../include/hack.h
	@echo /**/ >> $(HACK_H)
#
gtkhack.o: gtkhack.c ../../include/winGTK.h ../../include/prxyclnt.h \
		../../include/proxycb.h gtkconnect.h \
		gtksupport.h
gtk.o: gtk.c ../../include/md5.h ../../include/winGTK.h ../../include/wintype.h \
		../../include/func_tab.h ../../include/dlb.h ../../include/patchlevel.h \
		../../include/proxycb.h ../../include/prxyclnt.h
gtkgetlin.o: gtkgetlin.c ../../include/winGTK.h
gtkstatus.o: gtkstatus.c ../../include/winGTK.h
gtkmenu.o: gtkmenu.c ../../include/winGTK.h ../../include/patchlevel.h
gtkyn.o: gtkyn.c ../../include/winGTK.h
gtkextcmd.o: gtkextcmd.c ../../include/winGTK.h ../../include/proxycb.h \
		../../include/func_tab.h
gtkmap.o: gtkmap.c ../../include/winGTK.h ../../include/dlb.h \
		../../include/patchlevel.h ../../include/decl.h ../../include/proxycb.h \
		../../include/prxyclnt.h gtkprogress.h
gtkmessage.o: gtkmessage.c ../../include/winGTK.h
gtkmisc.o: gtkmisc.c ../../include/winGTK.h ../../include/proxycb.h
gtktile.o: gtktile.c ../../include/winGTK.h ../../include/dlb.h ../../include/proxycb.h \
		../../include/prxyclnt.h gtkprogress.h
xshmmap.o: xshmmap.c ../../include/winGTK.h
gtkext.o: gtkext.c ../../include/winGTK.h ../../include/prxyclnt.h
gtkhackrc.o: gtkhackrc.c ../../include/winGTK.h
gtkprefs.o: gtkprefs.c ../../include/winGTK.h ../../include/patchlevel.h
panic.o: panic.c $(CONFIG_H)
gtkconnect.o: gtkconnect.c gtkconcb.h gtkconnect.h \
		gtksupport.h
gtkconcb.o: gtkconcb.c gtkconcb.h gtkconnect.h \
		gtksupport.h ../../include/winGTK.h \
		../../include/prxyclnt.h
gtksupport.o: gtksupport.c gtksupport.h
gtkprogress.o: gtkprogress.c ../../include/winGTK.h gtkprogress.h
# DEPENDENCIES MUST END AT END OF FILE
# IF YOU PUT STUFF HERE IT WILL GO AWAY
# see make depend above
