# @(#)Makefile.in
#
# Copyright 1997 - 2010  David A. Bagley, bagleyd@tux.org
#
# All Rights Reserved
#
# Permission to use, copy, modify, and distribute this software and
# its documentation for any purpose and without fee is hereby granted,
# provided that the above copyright notice appear in all copies and
# that both that copyright notice and this permission notice appear in
# supporting documentation, and that the name of the author not be
# used in advertising or publicity pertaining to distribution of the
# software without specific, written prior permission.
#
# This program is distributed in the hope that it will be "useful",
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

# xskewb Makefile.in for configure (UNIX X11 support)

wIDGET = skewb
WIDGET = Skewb
WIDGET2 = $(WIDGET)2d
WIDGET3 = $(WIDGET)3d
GROUP = xpuzzles
P=x
R=$(P)
V=
PROG = $(R)$(wIDGET)
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\" \
-DMOVESOUND=\"move\" \
-DSCOREPATH=\"$(SCOREPATH)\" -DSCOREFILE=\"$(SCOREFILE)\" \
-DLOGPATH=\"$(LOGPATH)\" -DLOGFILE=\"$(LOGFILE)\"
DEFS = @DEFS@ $(DEFINES)
# -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
# -DCONSTPIXMAPS
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=.o
#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 \
$(WIDGET2)P.h $(WIDGET2).h \
$(WIDGET3)P.h $(WIDGET3).h \
$(WIDGET)GLP.h $(WIDGET)GL.h \
xwin.h file.h timer.h rngs.h \
sound.h version.h \
pixmaps/$(wIDGET).xbm pixmaps/$(wIDGET).xpm

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

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

all : $(PROG)

constpixmaps :
	@ $(ECHO) "USE with -DCONSTPIXMAPS"
	for pix in pixmaps/*.xpm; do\
		base=`basename $$pix`;\
		sed 's/static char/static const char/' $$pix > $$base;\
	done

$(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 INSTALL."

$(WIDGET)$(O) : $(WIDGET)$(C) $(WIDGET)P.h $(WIDGET).h xwin.h file.h timer.h rngs.h pixmaps/$(wIDGET).xbm pixmaps/$(wIDGET).xpm
$(WIDGET)S$(O) : $(WIDGET)S$(C) $(WIDGET)P.h $(WIDGET).h rngs.h
$(WIDGET)U$(O) : $(WIDGET)U$(C) $(WIDGET)P.h $(WIDGET).h
(WIDGET2)$(O) : $(WIDGET2)$(C) $(WIDGET)P.h $(WIDGET).h $(WIDGET2)P.h $(WIDGET2).h xwin.h
$(WIDGET3)$(O) : $(WIDGET3)$(C) $(WIDGET)P.h $(WIDGET).h $(WIDGET3)P.h $(WIDGET3).h xwin.h
$(WIDGET)GL$(O) : $(WIDGET)GL$(C) $(WIDGET)P.h $(WIDGET).h $(WIDGET)GLP.h $(WIDGET)GL.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
$(P)$(wIDGET)$(O) : $(P)$(wIDGET)$(C) $(WIDGET).h xwin.h file.h version.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) move.au $(DESTDIR)$(readdir)/move.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) "sound file could be used by other $(GROUP)"
	@ $(ECHO) "\"Control-C\" to break"
	sleep 5
	$(RM) $(DESTDIR)$(readdir)/move.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) /usr/games/$(R)$(M)$(wIDGET)$(E)
	$(RM) /var/games/$(GROUP)/$(wIDGET).scores

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

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

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

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

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

uninstall-xpm-home :
	$(RM) $(HOME)/.dt/pixmaps/$(wIDGET).t.pm
	$(RM) $(HOME)/.dt/pixmaps/$(wIDGET).s.pm
	$(RM) $(HOME)/.dt/pixmaps/$(wIDGET).m.pm
	$(RM) $(HOME)/.dt/pixmaps/$(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 $(wIDGET)*.xpm
	cd win32 ; make -f Makefile clean

distclean : clean
	$(RM) config.cache config.log
	$(RM)r autom4te.cache
	cd win32 ; make -f Makefile distclean

clean.all : distclean
	$(RM) Makefile config.status*

PACKAGE=$(VER)/$(WIDGET).h $(VER)/$(WIDGET)P.h \
$(VER)/$(WIDGET2).h $(VER)/$(WIDGET2)P.h \
$(VER)/$(WIDGET3).h $(VER)/$(WIDGET3)P.h \
$(VER)/$(WIDGET)GL.h $(VER)/$(WIDGET)GLP.h \
$(VER)/xwin.h $(VER)/file.h $(VER)/timer.h $(VER)/rngs.h \
$(VER)/sound.h $(VER)/version.h \
$(VER)/pixmaps/mouse-l.xbm $(VER)/pixmaps/mouse-r.xbm \
$(VER)/pixmaps/$(wIDGET).xbm $(VER)/pixmaps/$(wIDGET).xpm \
$(VER)/pixmaps/$(wIDGET).t.xpm $(VER)/pixmaps/$(wIDGET).s.xpm \
$(VER)/pixmaps/$(wIDGET).m.xpm $(VER)/pixmaps/$(wIDGET).l.xpm \
$(VER)/pixmaps/$(wIDGET).p.xpm \
$(VER)/pixmaps/mini.$(wIDGET).png $(VER)/pixmaps/small.$(wIDGET).png \
$(VER)/pixmaps/normal.$(wIDGET).png $(VER)/pixmaps/big.$(wIDGET).png \
$(VER)/move.au $(VER)/play.sh \
$(VER)/$(WIDGET)$(C) $(VER)/$(WIDGET)S$(C) $(VER)/$(WIDGET)U$(C) \
$(VER)/$(WIDGET2)$(C) $(VER)/$(WIDGET3)$(C) $(VER)/$(WIDGET)GL$(C) \
$(VER)/$(P)$(wIDGET)$(C) \
$(VER)/xwin$(C) $(VER)/file$(C) $(VER)/timer$(C) $(VER)/rngs$(C) \
$(VER)/sound$(C) \
$(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)/AUTHORS $(VER)/ChangeLog $(VER)/COPYING $(VER)/NEWS \
$(VER)/INSTALL $(VER)/README $(VER)/TODO \
$(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)/win32/Makefile $(VER)/win32/w$(wIDGET).rc $(VER)/win32/move.wav \
$(VER)/win32/w$(wIDGET).ini $(VER)/win32/$(wIDGET).ico

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

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

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

compress :
	cd .. ; tar cvf - $(PACKAGE) | compress > $(VER).tar.Z

gzip :
	cd .. ; tar cvf - $(PACKAGE) | gzip > $(VER).tar.gz

bzip2 :
	cd .. ; tar cvf - $(PACKAGE) | bzip2 > $(VER).tar.bz2

dist : bzip2

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

# man2html 3.0.1, changed psgz 1666 and txsz 1552
$(PROG).html : $(PROG).man
	nroff -c -man -Tascii < $(PROG).man | man2html -title $(PROG) > $(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

antic :
	antic *.h *.c */*.xpm */*.xbm */*.c */*.h

cppcheck :
	cppcheck -f -q *.c */*.c

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

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

PNGS=\
	pixmaps/big.$(wIDGET).png\
	pixmaps/normal.$(wIDGET).png\
	pixmaps/small.$(wIDGET).png\
	pixmaps/mini.$(wIDGET).png

pixmaps/big.$(wIDGET).png : pixmaps/$(wIDGET).l.xpm
	if grep None $< > /dev/null; then\
		sed -e 's/None/White/' $< | xpmtoppm |\
		pnmtopng -transparent 1,1,1 > $@;\
	else\
		xpmtoppm $< | pnmtopng > $@;\
	fi

pixmaps/normal.$(wIDGET).png : pixmaps/$(wIDGET).m.xpm
	if grep None $< > /dev/null; then\
		sed -e 's/None/White/' $< | xpmtoppm |\
		pnmtopng -transparent 1,1,1 > $@;\
	else\
		xpmtoppm $< | pnmtopng > $@;\
	fi

pixmaps/small.$(wIDGET).png : pixmaps/$(wIDGET).p.xpm
	if grep None $< > /dev/null; then\
		sed -e 's/None/White/' $< | xpmtoppm |\
		pnmtopng -transparent 1,1,1 > $@;\
	else\
		xpmtoppm $< | pnmtopng > $@;\
	fi

pixmaps/mini.$(wIDGET).png : pixmaps/$(wIDGET).t.xpm
	if grep None $< > /dev/null; then\
		sed -e 's/None/White/' $< | xpmtoppm |\
		pnmtopng -transparent 1,1,1 > $@;\
	else\
		xpmtoppm $< | pnmtopng > $@;\
	fi

pixmap : $(PNGS)
