############################################################
#
# $Id : Makefile.in 7.2 2006/04/01 $
#
# xcubes Makefile.in for configure (UNIX X11 support)
############################################################

# default target

wIDGET = cubes
WIDGET = Cubes
VERNUM = 7.2
GROUP = xpuzzles
P=x
R=$(P)
V=$(P)
PROG = $(R)$(wIDGET)
#VER = $(V)$(wIDGET)-$(VERNUM)
VER = $(V)$(wIDGET)

# this tells GNU make not to export variables into the environment
# But other makes do not understand its significance, so it must
# not be the first target in the file. So it is here, before
# any variables are created, but after the default target
.NOEXPORT :

SHELL = /bin/sh
MANNUM = 6

srcdir = @srcdir@
top_srcdir = @top_srcdir@
#VPATH = @srcdir@/

prefix = @prefix@
exec_prefix = @exec_prefix@

bindir = @bindir@
mandir = @mandir@/man$(MANNUM)
xapploaddir = @APPDEFAULTS@
#xapploaddir = @libdir@/X11/app-defaults
#xapploaddir = @libdir@/app-defaults
datarootdir = @datarootdir@
datadir = @datadir@
readdir = $(datadir)/games/$(GROUP)
scoredir = /var/games/$(GROUP)
logdir = /usr/tmp

INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
M = @XM_PREFIX@

DESTDIR =

#CC = cc -g
#CC = acc -g
#CC = gcc -g -Wall -ansi -pedantic
#CC = gcc -g -Wall -W -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Waggregate-return -Wmissing-prototypes -Wstrict-prototypes -pedantic -Wno-long-long
#CC = gcc -g -Wall
#CC = g++ -g -Wall
#CC = CC -g
CC = @CC@

LINT = lint
#LINT = alint

INDENT = indent

MORE = more
#MORE = less

PRINT = lpr
#PRINT = enscript -2r

SCOREPATH = $(scoredir)
SCOREFILE = $(wIDGET).scores
LOGPATH = $(logdir)
LOGFILE = $(wIDGET).log

LN_S = @LN_S@
RM = rm -f
RM_S = $(RM)
ECHO = echo

#BLN_S = set file/enter=[]
#RM = delete/noconfirm/nolog
#RM_S = set file/remove/nolog
#ECHO = write sys$output

# Assumes a directory of /var/games/$(GROUP) if -DSCOREPATH not set.
# Assumes a directory of /usr/tmp if -DLOGPATH not set.
DEFINES = \
-DSOUNDPATH=\"$(readdir)\" -DSOUNDEXT=\".au\" \
-DBUMPSOUND=\"bump\" -DDRIPSOUND=\"drip\" \
-DSCOREPATH=\"$(SCOREPATH)\" -DSCOREFILE=\"$(SCOREFILE)\" \
-DLOGPATH=\"$(LOGPATH)\" -DLOGFILE=\"$(LOGFILE)\"
DEFS = @DEFS@ $(DEFINES)
# -DPICTURE=\"$(readdir)/mandrill.xbm\"
# -DPICTURE=\"$(readdir)/mandrill.xpm\"
# -DSRAND=srand48 -DLRAND=lrand48 -DMAXRAND=2147483648.0
# -DSRAND=srandom -DLRAND=random -DMAXRAND=2147483648.0
# -DSRAND=srand -DLRAND=rand -DMAXRAND=32768.0
# -DHAVE_USLEEP
# -DHAVE_NANOSLEEP
XWIDGETINC = @XWIDGETINC@ -I$(top_srcdir) -I.
CFLAGS = @CFLAGS@
#CFLAGS = -O
#CFLAGS = -g
XWIDGETLDFLAGS = @XWIDGETLDFLAGS@
XLIBS = @XLIBS@
XWIDGETLIBS = @XWIDGETLIBS@

N=
C=.c
#C++
#C=.cc
#C=.cpp

O=.@OBJEXT@
S=$(N) $(N)
E=@EXEEXT@
A=

#VMS
#O=.obj
#S=,
#E=.exe
#A=;*

# please define
# C as the C source code extension
# O as the object extension
# S as the separator for object code
# E as the executable extension

HDRS = $(WIDGET)P.h $(WIDGET).h \
xwin.h file.h timer.h rngs.h sound.h picture.h \
icons/$(wIDGET).xbm icons/$(wIDGET).xpm

COREOBJS = $(WIDGET)$(O)$(S)$(WIDGET)S$(O)$(S)$(WIDGET)U$(O)
OBJS = xwin$(O)$(S)file$(O)$(S)timer$(O)$(S)rngs$(O)$(S)\
sound$(O)$(S)picture$(O)$(S)\
$(COREOBJS)$(S)$(P)$(wIDGET)$(O)

CORESRCS = $(WIDGET)$(C) $(WIDGET)S$(C) $(WIDGET)U$(C)
SRCS = xwin$(C) file$(C) timer$(C) rngs$(C) \
sound$(C) picture$(C) \
$(CORESRCS) $(P)$(wIDGET)$(C)

all : $(PROG)

$(PROG) : $(OBJS)
	$(CC) -o $@ $(OBJS) $(XWIDGETLDFLAGS) $(XWIDGETLIBS)
	@ $(ECHO) "$@ BUILD COMPLETE"
	@ $(ECHO) ""
	@ $(ECHO) "To install: \"make install\" is safer but"
	@ $(ECHO) "\"make install-games\" may work better, see README."

$(WIDGET)$(O) : $(WIDGET)$(C) $(HDRS)
$(WIDGET)S$(O) : $(WIDGET)S$(C) $(WIDGET)P.h $(WIDGET).h
$(WIDGET)U$(O) : $(WIDGET)U$(C) $(WIDGET)P.h $(WIDGET).h
xwin$(O) : xwin$(C) xwin.h
file$(O) : file$(C) file.h
timer$(O) : timer$(C) timer.h
rngs$(O) : rngs$(C) rngs.h
sound$(O) : sound$(C) sound.h file.h
picture$(O) : picture$(C) picture.h file.h
$(P)$(wIDGET)$(O) : $(P)$(wIDGET)$(C) $(WIDGET).h xwin.h file.h

install : $(PROG)$(E)
	$(srcdir)/mkinstalldirs $(DESTDIR)$(bindir)
	$(INSTALL_PROGRAM) $(PROG)$(E) $(DESTDIR)$(bindir)/$(R)$(M)$(wIDGET)$(E)
	$(srcdir)/mkinstalldirs $(DESTDIR)$(mandir)
	$(INSTALL_DATA) $(PROG).man $(DESTDIR)$(mandir)/$(PROG).$(MANNUM)
	$(srcdir)/mkinstalldirs $(DESTDIR)$(xapploaddir)
	$(INSTALL_DATA) $(WIDGET).ad $(DESTDIR)$(xapploaddir)/$(WIDGET)
	$(srcdir)/mkinstalldirs $(DESTDIR)$(readdir)
	$(INSTALL_DATA) mandrill.xpm $(DESTDIR)$(readdir)/mandrill.xpm
	$(INSTALL_DATA) mandrill.xbm $(DESTDIR)$(readdir)/mandrill.xbm
	$(INSTALL_DATA) bump.au $(DESTDIR)$(readdir)/bump.au
	$(INSTALL_DATA) drip.au $(DESTDIR)$(readdir)/drip.au
	@ $(ECHO) "$@ COMPLETE"
	@ $(ECHO) ""
	@ $(ECHO) "To use $(R)$(M)$(wIDGET) from a menu, you may want to install the"
	@ $(ECHO) "images.  Do a \"make install-png\" for Gnome and KDE, or do a"
	@ $(ECHO) "\"make install-xpm\" or a \"make install-xpm-home\" for CDE."

uninstall :
	$(RM) $(DESTDIR)$(bindir)/$(R)$(M)$(wIDGET)$(E)$(A)
	$(RM) $(DESTDIR)$(mandir)/$(PROG).$(MANNUM)
	$(RM) $(DESTDIR)$(xapploaddir)/$(WIDGET)
	@ $(ECHO) "mandrill bitmaps and sound files could be used by other $(GROUP)"
	@ $(ECHO) "\"Control-C\" to break"
	sleep 5
	$(RM) $(DESTDIR)$(readdir)/mandrill.xpm
	$(RM) $(DESTDIR)$(readdir)/mandrill.xbm
	$(RM) $(DESTDIR)$(readdir)/bump.au
	$(RM) $(DESTDIR)$(readdir)/drip.au

install-games : $(PROG)$(E)
	$(srcdir)/mkinstalldirs $(DESTDIR)$(mandir)
	$(INSTALL_DATA) $(PROG).man $(DESTDIR)$(mandir)/$(PROG).$(MANNUM)
	$(srcdir)/mkinstalldirs $(DESTDIR)$(xapploaddir)
	$(INSTALL_DATA) $(WIDGET).ad $(DESTDIR)$(xapploaddir)/$(WIDGET)
	$(srcdir)/mkinstalldirs /usr/games
	$(INSTALL_PROGRAM) $(PROG)$(E) /usr/games/$(R)$(M)$(wIDGET)$(E)
	chmod 2755 /usr/games/$(R)$(M)$(wIDGET)$(E)
	$(srcdir)/mkinstalldirs /var/games/$(GROUP)
	chmod 775 /var/games/$(GROUP)
	$(INSTALL_PROGRAM) $(wIDGET).scores /var/games/$(GROUP)/$(wIDGET).scores
	chmod 664 /var/games/$(GROUP)/$(wIDGET).scores
	chown games:games /usr/games/$(R)$(M)$(wIDGET)$(E)
	chown games:games /var/games/$(GROUP)
	chown games:games /var/games/$(GROUP)/$(wIDGET).scores
	@ $(ECHO) "$@ COMPLETE"
	@ $(ECHO) ""
	@ $(ECHO) "To use $(R)$(M)$(wIDGET) from a menu, you may want to install the "
	@ $(ECHO) "images.  Do a \"make install-png\" for Gnome and KDE, or do a"
	@ $(ECHO) "\"make install-xpm\" or a \"make install-xpm-home\" for CDE."

uninstall-games :
	$(RM) $(DESTDIR)$(mandir)/$(PROG).$(MANNUM)
	$(RM) $(DESTDIR)$(xapploaddir)/$(WIDGET)
	rm -rf /usr/games/$(R)$(M)$(wIDGET)$(E)
	rm -rf /var/games/$(GROUP)/$(wIDGET).scores

# Gnome and KDE
install-png :
	$(srcdir)/mkinstalldirs $(DESTDIR)$(datadir)/icons/png/hicolor/16x16/apps
	$(INSTALL_DATA) icons/mini.$(wIDGET).png $(DESTDIR)$(datadir)/icons/png/hicolor/16x16/apps/$(wIDGET).png
	$(srcdir)/mkinstalldirs $(DESTDIR)$(datadir)/icons/png/hicolor/22x22/apps
	$(INSTALL_DATA) icons/small.$(wIDGET).png $(DESTDIR)$(datadir)/icons/png/hicolor/22x22/apps/$(wIDGET).png
	$(srcdir)/mkinstalldirs $(DESTDIR)$(datadir)/icons/png/hicolor/32x32/apps
	$(INSTALL_DATA) icons/normal.$(wIDGET).png $(DESTDIR)$(datadir)/icons/png/hicolor/32x32/apps/$(wIDGET).png
	$(srcdir)/mkinstalldirs $(DESTDIR)$(datadir)/icons/png/hicolor/48x48/apps
	$(INSTALL_DATA) icons/big.$(wIDGET).png $(DESTDIR)$(datadir)/icons/png/hicolor/48x48/apps/$(wIDGET).png
	$(srcdir)/mkinstalldirs $(DESTDIR)$(datadir)/icons/png/hicolor/all/apps
	$(LN_S) $(DESTDIR)$(datadir)/icons/png/hicolor/16x16/apps/$(wIDGET).png $(DESTDIR) $(datadir)/icons/png/hicolor/all/apps/mini.$(wIDGET).png
	$(LN_S) $(DESTDIR)$(datadir)/icons/png/hicolor/22x22/apps/$(wIDGET).png $(DESTDIR)$(datadir)/icons/png/hicolor/all/apps/small.$(wIDGET).png
	$(LN_S) $(DESTDIR)$(datadir)/icons/png/hicolor/32x32/apps/$(wIDGET).png $(DESTDIR)$(datadir)/icons/png/hicolor/all/apps/normal.$(wIDGET).png
	$(LN_S) $(DESTDIR)$(datadir)/icons/png/hicolor/48x48/apps/$(wIDGET).png $(DESTDIR)$(datadir)/icons/png/hicolor/all/apps/big.$(wIDGET).png

uninstall-png :
	$(RM) $(DESTDIR)$(datadir)/icons/png/hicolor/all/apps/mini.$(wIDGET).png
	$(RM) $(DESTDIR)$(datadir)/icons/png/hicolor/all/apps/small.$(wIDGET).png
	$(RM) $(DESTDIR)$(datadir)/icons/png/hicolor/all/apps/normal.$(wIDGET).png
	$(RM) $(DESTDIR)$(datadir)/icons/png/hicolor/all/apps/big.$(wIDGET).png
	$(RM) $(DESTDIR)$(datadir)/icons/png/hicolor/16x16/apps/$(wIDGET).png
	$(RM) $(DESTDIR)$(datadir)/icons/png/hicolor/22x22/apps/$(wIDGET).png
	$(RM) $(DESTDIR)$(datadir)/icons/png/hicolor/32x32/apps/$(wIDGET).png
	$(RM) $(DESTDIR)$(datadir)/icons/png/hicolor/48x48/apps/$(wIDGET).png

#CDE
install-xpm :
	$(srcdir)/mkinstalldirs $(DESTDIR)$(datadir)/dt/icons
	$(INSTALL_DATA) icons/$(wIDGET).t.xpm $(DESTDIR)$(datadir)/dt/icons/$(wIDGET).t.pm
	$(INSTALL_DATA) icons/$(wIDGET).s.xpm $(DESTDIR)$(datadir)/dt/icons/$(wIDGET).s.pm
	$(INSTALL_DATA) icons/$(wIDGET).m.xpm $(DESTDIR)$(datadir)/dt/icons/$(wIDGET).m.pm
	$(INSTALL_DATA) icons/$(wIDGET).l.xpm $(DESTDIR)$(datadir)/dt/icons/$(wIDGET).l.pm

uninstall-xpm :
	$(RM) $(DESTDIR)$(datadir)/dt/icons/$(wIDGET).t.pm
	$(RM) $(DESTDIR)$(datadir)/dt/icons/$(wIDGET).s.pm
	$(RM) $(DESTDIR)$(datadir)/dt/icons/$(wIDGET).m.pm
	$(RM) $(DESTDIR)$(datadir)/dt/icons/$(wIDGET).l.pm

#CDE HOME directory
install-xpm-home :
	$(srcdir)/mkinstalldirs $(HOME)/.dt/icons
	$(INSTALL_DATA) icons/$(wIDGET).t.xpm $(HOME)/.dt/icons/$(wIDGET).t.pm
	$(INSTALL_DATA) icons/$(wIDGET).s.xpm $(HOME)/.dt/icons/$(wIDGET).s.pm
	$(INSTALL_DATA) icons/$(wIDGET).m.xpm $(HOME)/.dt/icons/$(wIDGET).m.pm
	$(INSTALL_DATA) icons/$(wIDGET).l.xpm $(HOME)/.dt/icons/$(wIDGET).l.pm

uninstall-xpm-home :
	$(RM) $(HOME)/.dt/icons/$(wIDGET).t.pm
	$(RM) $(HOME)/.dt/icons/$(wIDGET).s.pm
	$(RM) $(HOME)/.dt/icons/$(wIDGET).m.pm
	$(RM) $(HOME)/.dt/icons/$(wIDGET).l.pm

SUFFIXES : $(C) $(O) $(E)

$(C)$(O) :
	$(CC) -c $(CPPFLAGS) $(DEFS) $(XWIDGETINC) $(CFLAGS) $<

Makefile : Makefile.in config.status
	$(SHELL) config.status
config.status : configure
	$(SHELL) config.status --recheck
configure : configure.in
# enable this rule if you want autoconf to be executed automatically when
# configure.in is changed. This is commented out, since patching might give
# configure.in a newer timestamp than configure and not everybody has autoconf
#	cd $(srcdir); autoconf

run :
	./$(PROG)

run.scores :
	./$(PROG) -scores

run.version :
	./$(PROG) -version

gdb :
	gdb ./$(PROG)

dbx :
	dbx ./$(PROG)

clean :
	$(RM) *.o *.exe* core *~ *% *.bak make.log MakeOut Makefile.dep \
$(PROG) $(PROG).errs $(PROG).1.html $(PROG)._man
	cd win ; make -f Makefile clean

distclean : clean
	$(RM) Makefile config.status config.cache config.log
	rm -rf autom4te.cache
	cd win ; make -f Makefile distclean

clean.all : distclean

PACKAGE=$(VER)/$(WIDGET).h $(VER)/$(WIDGET)P.h \
$(VER)/xwin.h $(VER)/file.h $(VER)/timer.h $(VER)/rngs.h \
$(VER)/sound.h $(VER)/picture.h \
$(VER)/icons/mouse-l.xbm $(VER)/icons/mouse-r.xbm \
$(VER)/icons/$(wIDGET).xbm $(VER)/icons/$(wIDGET).xpm \
$(VER)/icons/$(wIDGET).t.xpm $(VER)/icons/$(wIDGET).s.xpm \
$(VER)/icons/$(wIDGET).m.xpm $(VER)/icons/$(wIDGET).l.xpm \
$(VER)/icons/$(wIDGET).p.xpm \
$(VER)/icons/mini.$(wIDGET).png $(VER)/icons/small.$(wIDGET).png \
$(VER)/icons/normal.$(wIDGET).png $(VER)/icons/big.$(wIDGET).png \
$(VER)/mandrill.xbm $(VER)/mandrill.xpm \
$(VER)/bump.au $(VER)/bumpdat.au $(VER)/drip.au  $(VER)/play.sh \
$(VER)/$(WIDGET)$(C) $(VER)/$(WIDGET)S$(C) $(VER)/$(WIDGET)U$(C) \
$(VER)/xwin$(C) $(VER)/file$(C) $(VER)/timer$(C) $(VER)/rngs$(C) \
$(VER)/sound$(C) $(VER)/picture$(C) \
$(VER)/$(P)$(wIDGET)$(C) $(VER)/README \
$(VER)/Imakefile $(VER)/$(PROG).man $(VER)/$(PROG).html \
$(VER)/$(WIDGET).ad $(VER)/$(wIDGET).scores \
$(VER)/configure $(VER)/Makefile.in $(VER)/configure.in \
$(VER)/config.guess $(VER)/config.sub $(VER)/install-sh $(VER)/mkinstalldirs \
$(VER)/vms/README.vms $(VER)/vms/$(PROG).hlp \
$(VER)/vms/make.com $(VER)/vms/mmov.com \
$(VER)/vms/vms_amd.c $(VER)/vms/vms_amd.h $(VER)/vms/vms_mmov.c \
$(VER)/win/Makefile $(VER)/win/w$(wIDGET).h \
$(VER)/win/mandrill.bmp $(VER)/win/bump.wav $(VER)/win/drip.wav \
$(VER)/win/w$(wIDGET).rc $(VER)/win/w$(wIDGET).ini $(VER)/win/w$(wIDGET).ico

zip : distclean
	cd .. ; zip $(VER) $(PACKAGE)

pkzip : distclean
	cd .. ; pkzip $(VER) $(PACKAGE)

tar : distclean
	cd .. ; tar cvf $(VER).tar $(PACKAGE)

compress : tar
	cd .. ; compress -f $(VER).tar

gzip : tar
	cd .. ; gzip -f $(VER).tar

bzip2 : tar
	cd .. ; bzip2 -f $(VER).tar

dist : bzip2

tgz : tar
	cd .. ; gzip -c $(VER).tar > `echo $(VER) | cut -c1-8`.tgz ; \
$(RM) $(VER).tar

tbz : tar
	cd .. ; bzip2 -c $(VER).tar > `echo $(VER) | cut -c1-8`.tbz ; \
$(RM) $(VER).tar

dist.man : $(PROG).html vms/$(PROG).hlp

# man2html 3.0.1
$(PROG).html : $(PROG).man
	nroff -c -man < $(PROG).man | man2html > $(PROG).html

# found man2hlp.sh in lynx source
vms/$(PROG).hlp : $(PROG).man
	man2hlp.sh $(PROG).man > vms/$(PROG).hlp

html : $(PROG).html

hlp : vms/$(PROG).hlp

man :
	nroff -c -man $(PROG).man | $(MORE)

print:
	$(PRINT) $(HDRS) $(SRCS)

read :
	$(MORE) README

lint :
	$(LINT) -ax -DLINT $(DEFS) $(XWIDGETINC) $(SRCS) $(XWIDGETLIBS)

indent :
	$(INDENT) $(HDRS) $(SRCS)

# fixes output from CDE dticon for Sun CC compiler
fix-xpm :
	for x in icons/*.xpm; do\
		cp $${x} $${x}.old;\
		sed -e "s/static char/static const char/" $${x}.old > $${x};\
		$(RM) $${x}.old;\
	done
