# hacks/Makefile.in --- xscreensaver, Copyright (c) 1997-1999 Jamie Zawinski.
# the `../configure' script generates `hacks/Makefile' from this file.


.SUFFIXES:
.SUFFIXES: .c .o

srcdir		= .


install_prefix	=
prefix		= /usr/local
exec_prefix	= ${prefix}
bindir		= ${exec_prefix}/bin
mandir		= ${prefix}/man
# maybe this should be 6 (games)?
mansuffix	= 1
manNdir		= $(mandir)/man$(mansuffix)

CC		= gcc -Wall -Wstrict-prototypes -Wnested-externs -std=c89 -U__STRICT_ANSI__
CFLAGS		= -g -O2
LDFLAGS		=  -L${exec_prefix}/lib
DEFS		= -DSTANDALONE -DHAVE_CONFIG_H
LIBS		= 
PERL		= /usr/bin/perl

DEPEND		= makedepend
DEPEND_FLAGS	= 
DEPEND_DEFINES	= 

SHELL		= /bin/sh
INSTALL		= /usr/bin/install -c
SUID_FLAGS      = -o root -m 4755
INSTALL_PROGRAM = ${INSTALL}
INSTALL_SCRIPT  = ${INSTALL}
INSTALL_SETUID  = $(INSTALL_PROGRAM) $(SUID_FLAGS)
INSTALL_DATA	= ${INSTALL} -m 644
INSTALL_DIRS	= ${INSTALL} -d
GNOME_DATADIR	= /usr/share
HACKDIR		= ${exec_prefix}/lib/xscreensaver
HACK_CONF_DIR	= ${GNOME_DATADIR}/control-center/screensavers

X_CFLAGS	=  -I/usr/X11R6/include
X_LIBS		=  -L/usr/X11R6/lib
X_PRE_LIBS	=  -lSM -lICE
X_EXTRA_LIBS	= 
XMU_LIBS	= -lXmu

# Note: see comment in ../driver/Makefile.in for explanation of X_LIBS, etc.
#
HACK_PRE	= $(LIBS) $(X_LIBS)
HACK_POST     = $(X_PRE_LIBS) -lXt -lX11 $(XMU_LIBS) -lXext $(X_EXTRA_LIBS) -lm
HACK_LIBS	= $(HACK_PRE)             $(HACK_POST)
XPM_LIBS	= $(HACK_PRE) `gtk-config --libs` `gnome-config --libs glib gtk gdk_pixbuf gdk_pixbuf_xlib gnome` -L/usr/lib -L/usr/X11R6/lib -ldl -lXi -lXext -lX11 -lm  $(HACK_POST)
JPEG_LIBS	= -ljpeg
XLOCK_LIBS	= $(HACK_LIBS)

UTILS_SRC	= $(srcdir)/../utils
UTILS_BIN	= ../utils

INCLUDES	= -I. -I$(srcdir) -I$(UTILS_SRC) -I..  -I/usr/X11R6/include -I/usr/include/libxml -I/usr/X11R6/include `gtk-config --cflags` `gnome-config --cflags glib gtk gdk_pixbuf gdk_pixbuf_xlib gnome`

UTIL_SRCS	= $(UTILS_SRC)/alpha.c $(UTILS_SRC)/colors.c \
		  $(UTILS_SRC)/grabscreen.c $(UTILS_SRC)/grabclient.c \
		  $(UTILS_SRC)/hsv.c $(UTILS_SRC)/resources.c \
		  $(UTILS_SRC)/spline.c $(UTILS_SRC)/usleep.c \
		  $(UTILS_SRC)/visual.c $(UTILS_SRC)/logo.c \
		  $(UTILS_SRC)/yarandom.c $(UTILS_SRC)/erase.c \
		  $(UTILS_SRC)/xshm.c $(UTILS_SRC)/xdbe.c
UTIL_OBJS	= $(UTILS_BIN)/alpha.o $(UTILS_BIN)/colors.o \
		  $(UTILS_BIN)/grabscreen.o $(UTILS_BIN)/grabclient.o \
		  $(UTILS_BIN)/hsv.o $(UTILS_BIN)/resources.o \
		  $(UTILS_BIN)/spline.o $(UTILS_BIN)/usleep.o \
		  $(UTILS_BIN)/visual.o $(UTILS_BIN)/logo.o \
		  $(UTILS_BIN)/yarandom.o $(UTILS_BIN)/erase.o \
		  $(UTILS_SRC)/xshm.o $(UTILS_SRC)/xdbe.o

SRCS		= thomaskjaer.c

OBJS		= thomaskjaer.o

NEXES		= thomaskjaer

EXES		= $(NEXES)

HACK_OBJS_1	= $(UTILS_BIN)/resources.o $(UTILS_BIN)/visual.o \
		  $(UTILS_BIN)/usleep.o $(UTILS_BIN)/yarandom.o 
HACK_OBJS	= screenhack.o $(HACK_OBJS_1)
XLOCK_OBJS	= screenhack-xlock.o xlockmore.o $(COLOR_OBJS) $(HACK_OBJS_1)
COLOR_OBJS	= $(UTILS_BIN)/hsv.o $(UTILS_BIN)/colors.o
GRAB_OBJS	= $(UTILS_BIN)/grabclient.o
XSHM_OBJS	= $(UTILS_BIN)/xshm.o
XDBE_OBJS	= $(UTILS_BIN)/xdbe.o

MEN		= thomaskjaer.man
STAR		= *
EXTRAS		= README Makefile.in xlock_23.h xml2man.pl .gdbinit \
		  config/README \
		  config/$(STAR).xml \
		  images/$(STAR).xbm \
		  images/$(STAR).xpm \
		  images/thomaskjaer/$(STAR).xbm \
		  images/thomaskjaer/$(STAR).xpm \

VMSFILES	= compile_axp.com compile_decc.com link_axp.com link_decc.com \
		  vms_axp.opt vms_axp_12.opt vms_decc.opt vms_decc_12.opt

TARFILES	= $(SRCS) $(HDRS) $(SCRIPTS) $(MEN) $(EXTRAS) $(VMSFILES)


default: all
all: $(EXES)

install:   install-program   install-scripts install-xml install-man
uninstall: uninstall-program uninstall-xml uninstall-man

install-strip:
	$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' \
		install

# the hacks, in $HACKDIR
install-program:: $(EXES)
	@if [ ! -d $(install_prefix)$(HACKDIR) ]; then			\
	  $(INSTALL_DIRS) $(install_prefix)$(HACKDIR) ;			\
	 fi ;								\
	for program in $(NEXES); do					\
	  echo $(INSTALL_PROGRAM) $$program				\
	    $(install_prefix)$(HACKDIR)/$$program ;			\
	  $(INSTALL_PROGRAM) $$program					\
	    $(install_prefix)$(HACKDIR)/$$program ;			\
	done ;								\
	if [ no = yes ]; then				\
	  sinst="$(INSTALL_SETUID)" ;					\
	else								\
	  sinst="$(INSTALL_PROGRAM)" ;					\
	fi ;								\
	for program in $(SEXES); do					\
	  instargs="$$program $(install_prefix)$(HACKDIR)/$$program" ;	\
	  echo $$sinst $$instargs ;					\
	  if   $$sinst $$instargs ; then				\
	      true ;							\
	  elif [ no = yes ]; then				\
	    echo $(INSTALL_PROGRAM) $$instargs ;			\
	    if   $(INSTALL_PROGRAM) $$instargs ; then			\
	      echo "" ;							\
	      echo "WARNING: unable to install $$program setuid:"	\
	           "installed non-setuid instead." ;			\
	      echo "" ;							\
	    else							\
	      exit 1 ;							\
	    fi ;							\
	  else								\
	    exit 1 ;							\
	  fi ;								\
	done

install-scripts: $(SCRIPTS) munge-scripts
	@for program in $(SCRIPTS); do					\
	  if [ -r $$program ] ; then					\
	    p=$$program ;						\
	  else								\
	    p=$(srcdir)/$$program ;					\
	  fi ;								\
	  echo $(INSTALL_SCRIPT) $$p					\
	    $(install_prefix)$(HACKDIR)/$$program ;			\
	  $(INSTALL_SCRIPT) $$p						\
	    $(install_prefix)$(HACKDIR)/$$program ;			\
	done

munge-scripts: $(SCRIPTS)
	@tmp=/tmp/mf.$$$$ ;						\
	perl="${PERL}" ;						\
	rm -f $$tmp ;							\
	for program in $(SCRIPTS); do					\
	  echo "adjusting location of perl in $$program..." ;		\
	  sed "s@^\(#!\)\(/[^ ]*/perl[^ ]*\)\(.*\)\$$@\1$$perl\3@"	\
	      < $(srcdir)/$$program > $$tmp ;				\
	  if cmp -s $(srcdir)/$$program $$tmp ; then			\
	    true ;							\
	  else								\
	    cat $$tmp > ./$$program ;					\
	  fi ;								\
	done ;								\
	rm -f $$tmp

install-man: $(MEN)
	@men="$(MEN)" ;							\
	if [ ! -d $(install_prefix)$(manNdir) ]; then			\
	  $(INSTALL_DIRS) $(install_prefix)$(manNdir) ;			\
	 fi ;								\
	for man in $$men; do						\
	  instname=`echo $$man | sed 's/\.man$$/\.$(mansuffix)/'` ;	\
	  echo $(INSTALL_DATA) $(srcdir)/$$man				\
	   $(install_prefix)$(manNdir)/$$instname ;			\
	  $(INSTALL_DATA) $(srcdir)/$$man				\
	    $(install_prefix)$(manNdir)/$$instname ;			\
	done

install-xml:
	@if [ ! -d $(install_prefix)$(HACK_CONF_DIR) ]; then		\
	  $(INSTALL_DIRS) $(install_prefix)$(HACK_CONF_DIR) ;		\
	 fi ;								\
	 files=`cd $(srcdir)/config/ ; echo README $(STAR).xml` ;	\
	 for file in $$files ; do					\
	   echo $(INSTALL_DATA) $(srcdir)/config/$$file			\
	    $(install_prefix)$(HACK_CONF_DIR)/$$file ;			\
	  $(INSTALL_DATA) $(srcdir)/config/$$file			\
	    $(install_prefix)$(HACK_CONF_DIR)/$$file ;			\
	done

uninstall-program:
	@for program in $(EXES) $(SCRIPTS); do				\
	  echo rm -f $(install_prefix)$(HACKDIR)/$$program ;		\
	  rm -f $(install_prefix)$(HACKDIR)/$$program ;			\
	done

uninstall-man:
	@men="$(MEN)" ;							\
	for man in $$men; do						\
	  instname=`echo $$man | sed 's/\.man$$/\.$(mansuffix)/'` ;	\
	  echo rm -f $(install_prefix)$(manNdir)/$$instname ;		\
	  rm -f $(install_prefix)$(manNdir)/$$instname ;		\
	done

uninstall-xml:
	@cd $(srcdir)/config/ ;						\
	 for file in README $(STAR).xml ; do				\
	  echo rm -f $(install_prefix)$(HACK_CONF_DIR)/$$file ;		\
	  rm -f $(install_prefix)$(HACK_CONF_DIR)/$$file ;		\
	done

clean:
	-rm -f *.o a.out core $(EXES)

distclean: clean
	-rm -f Makefile TAGS *~ "#"*

# Adds all current dependencies to Makefile
depend:
	$(DEPEND) -s '# DO NOT DELETE: updated by make depend'		    \
	$(DEPEND_FLAGS) --						    \
	$(INCLUDES) $(DEFS) $(DEPEND_DEFINES) $(CFLAGS) $(X_CFLAGS) --	    \
	$(SRCS)

# Adds some dependencies to Makefile.in -- not totally accurate, but pretty
# close.  This excludes dependencies on files in /usr/include, etc.  It tries
# to include only dependencies on files which are themselves a part of this
# package.
distdepend::
	@echo updating dependencies in `pwd`/Makefile.in... ;		    \
	$(DEPEND) -w 0 -f - 						    \
	-s '# DO NOT DELETE: updated by make distdepend' $(DEPEND_FLAGS) -- \
	$(INCLUDES) $(DEFS) $(DEPEND_DEFINES) $(CFLAGS) $(X_CFLAGS) --	    \
	$(SRCS) 2>/dev/null |						    \
	sort -d |							    \
	(								    \
	  awk '/^# .*Makefile.in ---/,/^# DO .*distdepend/' < Makefile.in ; \
	  sed -e '/^#.*/d'						    \
	      -e 's@ \./@ @g;s@ /[^ ]*@@g;/^.*:$$/d'			    \
	      -e 's@\.\./utils@$$(UTILS_SRC)@g'				    \
	      -e 's@ \([^$$]\)@ $$(srcdir)/\1@g'			    \
	      -e 's@ $$(srcdir)/\(.*config.h\)@ \1@g' ;			    \
	  echo ''							    \
	) > /tmp/distdepend.$$$$ &&					    \
	mv Makefile.in Makefile.in.bak &&				    \
	mv /tmp/distdepend.$$$$ Makefile.in

TAGS: tags
tags:
	find $(srcdir) -name '*.[chly]' -print | xargs etags -a

echo_tarfiles:
	@echo $(TARFILES)

check_men:
	@badmen="" ;							\
	 for exe in $(EXES) $(SCRIPTS); do				\
	   if ! [ -f $(srcdir)/$$exe.man				\
		  -o "$$exe" = webcollage-helper ]; then		\
	     badmen="$$badmen $$exe" ;					\
	   fi ;								\
	 done ;								\
	 if [ -n "$$badmen" ]; then					\
	   echo "" ;							\
	   echo "Warning: The following programs have no manuals:" ;	\
	   echo "" ;							\
	   for m in $$badmen ; do					\
	     echo "    $$m" ;						\
	   done ;							\
	 fi

check_xml:
	@badxml="" ;							\
	 for exe in $(EXES) $(SCRIPTS); do				\
	   if ! [ -f $(srcdir)/config/$$exe.xml				\
		  -o "$$exe" = webcollage-helper			\
		  -o "$$exe" = xsublim ]; then				\
	     badxml="$$badxml $$exe" ;					\
	   fi ;								\
	 done ;								\
	 if [ -n "$$badxml" ]; then					\
	   echo "" ;							\
	   echo "Warning: The following programs have no configurators:" ; \
	   echo "" ;							\
	   for m in $$badxml ; do					\
	     echo "    $$m" ;						\
	   done ;							\
	   echo "" ;							\
	 fi




# Rules for generating the VMS makefiles on Unix, so that it doesn't have to
# be done by hand...
#
VMS_AXP_COMPILE_1=$$ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE
VMS_AXP_COMPILE_2=)/INCL=([],[-],[-.UTILS])

compile_axp.com: Makefile.in
	@echo generating $@ from $<...  ;				    \
	( for c in $(SRCS) ; do						    \
	   c=`echo $$c | tr a-z A-Z` ;					    \
	   echo "$(VMS_AXP_COMPILE_1)$(VMS_AXP_COMPILE_2) $$c" ;	    \
         done ;								    \
	 foo="$(VMS_AXP_COMPILE_1),XLOCKMORE$(VMS_AXP_COMPILE_2)" ;	    \
         echo $${foo}/OBJ=SCREENHACK-XLOCK.OBJ SCREENHACK.C ;		    \
	) | sort -d > $@

compile_decc.com: compile_axp.com
	@echo generating $@ from $<...  ;				    \
	sed 's/axp/decc/g' < $< > $@

#### TODO: generating link_axp.com is kinda tricky...

link_decc.com: link_axp.com
	@echo generating $@ from $<...  ;				    \
	sed 's/axp/decc/g' < $< > $@

$(srcdir)/../setup.com: Makefile.in
	@echo generating $@ from $<...  ;				    \
	( echo '$$! Xscreensaver - definition of various DCL symbols' ;     \
	  echo '$$ set NOON' ;						    \
	  echo '$$ set def [.HACKS]' ;					    \
	  echo '$$ mydisk = f$$trnlmn("SYS$$DISK")' ;			    \
	  echo '$$ mydir  = mydisk+f$$directory()' ;			    \
	  ( for c in $(EXES) ; do					    \
	     c2="$${c}		" ;					    \
	     c2=`echo "$${c2}" | sed 's/^\(........*\)	$$/\1/'` ;	    \
	     echo '$$' "$${c2}:== $$'mydir'$${c}" ;			    \
             done ;							    \
	  ) | sort -d ;							    \
          echo '$$ set def [-.DRIVER]' ;				    \
          echo '$$ mydir  = mydisk+f$$directory()' ;			    \
          echo "$$ xscreensaver :== $$'mydir'xscreensaver" ;		    \
	  echo "$$ xscreen*command :== $$'mydir'xscreensaver-command" ;     \
	  echo '$$ set def [-]' ;					    \
	  echo '$$ exit' ; 						    \
          ) > $@

distdepend:: compile_axp.com compile_decc.com
distdepend:: link_axp.com link_decc.com
distdepend:: $(srcdir)/../setup.com
distdepend:: check_men check_xml


# Rules for noticing when the objects from the utils directory are out of
# date with respect to their sources, and going and building them according
# to the rules in their own Makefile...
#
$(UTILS_BIN)/alpha.o:		$(UTILS_SRC)/alpha.c
$(UTILS_BIN)/colors.o:		$(UTILS_SRC)/colors.c
$(UTILS_BIN)/grabclient.o:	$(UTILS_SRC)/grabclient.c
$(UTILS_BIN)/hsv.o:		$(UTILS_SRC)/hsv.c
$(UTILS_BIN)/resources.o:	$(UTILS_SRC)/resources.c
$(UTILS_BIN)/spline.o:		$(UTILS_SRC)/spline.c
$(UTILS_BIN)/usleep.o:		$(UTILS_SRC)/usleep.c
$(UTILS_BIN)/visual.o:		$(UTILS_SRC)/visual.c
$(UTILS_BIN)/xmu.o:		$(UTILS_SRC)/xmu.c
$(UTILS_BIN)/logo.o:		$(UTILS_SRC)/logo.c
$(UTILS_BIN)/yarandom.o:	$(UTILS_SRC)/yarandom.c
$(UTILS_BIN)/erase.o:		$(UTILS_SRC)/erase.c
$(UTILS_BIN)/xshm.o:		$(UTILS_SRC)/xshm.c
$(UTILS_BIN)/xdbe.o:		$(UTILS_SRC)/xdbe.c

$(UTIL_OBJS):
	cd $(UTILS_BIN) ; \
	$(MAKE) $(@F) CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"

# How we build object files in this directory.
.c.o:
	$(CC) -c $(INCLUDES) $(DEFS) $(CFLAGS) $(X_CFLAGS) $<

# Some hacks use a slightly-differently-compiled variant of this file.
# This is how to make the the other .o file from it.
#
screenhack-xlock.o: screenhack.c
	$(CC) -o $@ -c $(INCLUDES) $(DEFS) $(CFLAGS) $(X_CFLAGS) \
	-DXLOCKMORE $(srcdir)/screenhack.c

# Some abbreviations to keep the lines short...
XPM		= xpm-pixmap.o
ALP		= $(UTILS_BIN)/alpha.o
HSV		= $(UTILS_BIN)/hsv.o
SPL		= $(UTILS_BIN)/spline.o
LOGO		= $(UTILS_BIN)/logo.o
GRAB		= $(GRAB_OBJS)
ERASE		= $(UTILS_BIN)/erase.o
COL		= $(COLOR_OBJS)
SHM		= $(XSHM_OBJS)
DBE		= $(XDBE_OBJS)
BARS		= $(UTILS_BIN)/colorbars.o $(LOGO)

CC_HACK		= $(CC) $(LDFLAGS)

xscreensaver-sgigl: xscreensaver-sgigl.c
	$(CC) $(LDFLAGS) -o $@ $< -I$(UTILS_SRC) $(HACK_PRE) \
		$(XMU_LIBS) -lX11 -lXext $(X_EXTRA_LIBS) -lm


# The rules for those hacks which follow the `screenhack.c' API.
# If make wasn't such an utter abomination, these could all be combined
# into one rule, but we don't live in such a perfect world.  The $< rule
# is pretty much useless in the face of more than one dependency, as far
# as I can tell.
#
thomaskjaer:	thomaskjaer.o	$(HACK_OBJS) $(XPM)
	$(CC_HACK) -o $@ $@.o	$(HACK_OBJS) $(XPM) $(XPM_LIBS)

##############################################################################
#
# DO NOT DELETE: updated by make distdepend

thomaskjaer.o: ../config.h
thomaskjaer.o: $(srcdir)/images/thomaskjaer/nose-f1.xpm
thomaskjaer.o: $(srcdir)/images/thomaskjaer/nose-f2.xpm
thomaskjaer.o: $(srcdir)/images/thomaskjaer/nose-f3.xpm
thomaskjaer.o: $(srcdir)/images/thomaskjaer/nose-f4.xpm
thomaskjaer.o: $(srcdir)/images/thomaskjaer/nose-l1.xpm
thomaskjaer.o: $(srcdir)/images/thomaskjaer/nose-l2.xpm
thomaskjaer.o: $(srcdir)/images/thomaskjaer/nose-r1.xpm
thomaskjaer.o: $(srcdir)/images/thomaskjaer/nose-r2.xpm
thomaskjaer.o: $(srcdir)/screenhack.h
thomaskjaer.o: $(srcdir)/xpm-pixmap.h

