##############################
# Builds the example program #
##############################
CC = $(CONF_CC)
CFLAGS = $(CONF_CFLAGS) -I../lib $(CONF_DEBUG)
LDFLAGS = $(CONF_LDFLAGS) $(CONF_DEBUG)

############
# Includes #
############
INCS =	ascii.h calc.h calendar.h demohelp.h fileview.h gadgets.h \
	mousedlg.h puzzle.h tvcmds.h tvdemo.h

###########
# Objects #
###########
OBJS =	ascii.o calc.o calendar.o fileview.o gadgets.o mousedlg.o \
	puzzle.o tvdemo1.o tvdemo2.o tvdemo3.o

################
# Source files #
################
SRCS =	ascii.cc calc.cc calendar.cc fileview.cc gadgets.cc mousedlg.cc \
	puzzle.cc tvdemo1.cc tvdemo2.cc tvdemo3.cc \
	DEMOHELP.H32

###################
# Other variables #
###################
RCS = $(INCS) $(SRCS)
DISTFILES = Makefile mkdepend $(RCS)

#######################
# Rules to make files #
#######################
.c.o:
	$(CC) $(CFLAGS) -c $<

.cc.o:
	$(CC) $(CFLAGS) -c $<

###########
# Targets #
###########
all: confcheck hello

hello: $(OBJS)
	$(CC) $(LDFLAGS) -o hello $(OBJS) $(CONF_LIBS)

.PHONY:	ciall coall clean dist confcheck

###################
# Store revisions #
###################
ciall:
	ci Makefile $(RCS)

#####################
# Recover revisions #
#####################
coall:
	co $(RCS)

########################
# Remove garbage files #
########################
clean:
	rm -f hello *.bak *.o *~
	rm -f tvision

############################
# Package-making procedure #
############################
destdir = ../$(CONF_DISTDIR)/demo

dist: $(DISTFILES)
	@for file in $(DISTFILES); do \
		ln $$file $(destdir) || { \
			echo Copying $$file instead; \
			cp -p $$file $(destdir); \
	}; \
	done

###########################################
# Check if external variables are defined #
###########################################
confcheck:
	@if test -z "$(CONF_VERSION)"; then \
		echo Please run the main makefile; \
		exit 1; \
	fi

# Automatically generated dependencies
ascii.o: ascii.cc ascii.h
calc.o: calc.cc calc.h
calendar.o: calendar.cc calendar.h
fileview.o: fileview.cc tvcmds.h fileview.h
gadgets.o: gadgets.cc gadgets.h
mousedlg.o: mousedlg.cc mousedlg.h
puzzle.o: puzzle.cc puzzle.h
tvdemo1.o: tvdemo1.cc tvdemo.h gadgets.h fileview.h puzzle.h \
 demohelp.h
tvdemo2.o: tvdemo2.cc tvdemo.h tvcmds.h demohelp.h ascii.h calendar.h \
 calc.h
tvdemo3.o: tvdemo3.cc tvdemo.h tvcmds.h gadgets.h mousedlg.h \
 demohelp.h fileview.h
# Makefile ends here
