# Makefile for HEYU, a program to control an X10 CM11A computer interface.
# This makefile is generated by the Configure program.
#
BIN = debian/tmp/usr/bin
MAN = debian/tmp/usr/man/man1
MAN5 = debian/tmp/usr/man/man5
GROUP = sys
OWNER = bin

#       set DFLAGS equal to:
#          -DSYSV       if using SYSTEM V
#          -DVOID       if compiler doesn't understand 'void'

#This makefile is built for linux
CC = gcc
CFLAGS = -g -O $(DFLAGS) -Wall
DFLAGS = -DSYSV -DPOSIX -DHAS_ITIMER -DLINUX -DHASSELECT
LIBS = -lm -lc
# # The rest of the makefile should need no changes

## Makefile template for Heyu, a program to control an X10 CM11A computer
## interface.  From this point on the Makefile is copied from Makefile.in
## by the Configure program

SRCS =	date.c erase.c info.c  message.c relay.c \
	monitor.c reset.c setclock.c stop.c \
	tty.c turn.c x10.c xread.c xwrite.c status.c cm11a.c \
	eeprom.c preset.c parse_sched.c

OBJS =	date.o erase.o info.o message.o relay.o \
	monitor.o reset.o setclock.o stop.o \
	tty.o turn.o x10.o xread.o xwrite.o status.o cm11a.o \
	eeprom.o preset.o parse_sched.o

OTHERSRC = README Makefile x10config protocol.txt eeprom.h \
	x10sched.conf.sample  monit x10biff heyu.1 x10.h x10config.5 \
	history.txt version.h heyufaq.txt x10sched.5 makesched sunrise.c \
	Configure Makefile.in dusk.c install.sh INSTALL

EVERYTHING = $(OTHERSRC) $(SRCS)

all:	heyu dawndusk

heyu:	$(OBJS) version.h
	$(CC) $(LDFLAGS) -o heyu $(OBJS) $(LIBS)

$(OBJS): x10.h

eeprom.o:	eeprom.h

install: $(BIN)/heyu  $(MAN)/heyu.1 $(MAN5)/x10config.5 $(MAN5)/x10sched.5

uninstall:
	rm -f $(BIN)/heyu
	rm -f $(MAN)/heyu.1
	rm -f $(MAN5)/x10config.5
	rm -f $(MAN5)/x10sched.5

$(BIN)/heyu:	heyu
	cp heyu $(BIN)
	chgrp $(GROUP) $(BIN)/heyu
	chmod 755 $(BIN)/heyu
	chown $(OWNER) $(BIN)/heyu

$(MAN)/heyu.1: heyu.1
	cp heyu.1 $(MAN)
	chmod 644 $(MAN)/heyu.1

$(MAN5)/x10config.5: x10config.5
	cp x10config.5 $(MAN5)
	chmod 644 $(MAN5)/x10config.5

$(MAN5)/x10sched.5: x10sched.5
	cp x10sched.5 $(MAN5)
	chmod 644 $(MAN5)/x10sched.5

lint:
	lint $(DFLAGS) $(SRCS)

shar:	x10_heyu.shar.1 x10_heyu.shar.2

x10.o:	x10.c version.h

ci:	$(SRCS) index.html Makefile
	@ for FL in $+ ; do \
	if test -w $$FL ; then \
        ci -l $$FL ;\
	fi ;\
	done

x10_heyu.shar.1:
	shar $(OTHERSRC) >x10_heyu.shar.1

x10_heyu.shar.2:
	shar $(SRCS) > x10_heyu.shar.2

bigshar:
	shar $(EVERYTHING) > x10_heyu.shar

tar:    x10_heyu.tgz

x10_heyu.tgz:	$(EVERYTHING)
	rm -fr heyu.dir
	mkdir heyu.dir
	cp -p $(EVERYTHING) heyu.dir
	cp Makefile.dist heyu.dir/Makefile
	tar -czvf x10_heyu.tgz heyu.dir

beta:	x10_beta.tgz

x10_beta.tgz: $(EVERYTHING)
	rm -fr heyu.beta
	mkdir heyu.beta
	cp -p $(EVERYTHING) heyu.beta
	cp Makefile.dist heyu.dir/Makefile
	tar -czvf x10_beta.tgz heyu.beta

zip:	x10_heyu.zip

x10_heyu.zip:	$(EVERYTHING)
	rm -f x10_heyu.zip
	zip -kl x10_heyu.zip $(EVERYTHING)

touch:
	touch $(OTHERSRC)
	touch $(SRCS)

clean:
	rm -f *.o

clobber: clean
	rm -f heyu

upload:	heyu index.html x10_heyu.tgz x10_heyu.zip
	/bin/sh -c ./upload.sh

rcsdiffrw:
	@-for x in `$(MAKE) rw`	;\
	do	\
		echo 		;\
		echo $$x	;\
		echo =========	;\
		rcsdiff $$x	;\
	done 2>&1		;\
	echo			;\
	echo all done

dawndusk:	dusk.o sunrise.o
	$(CC) -o dawndusk dusk.o sunrise.o $(LIBS)

list:
	@ls $(EVERYTHING) | more

rw:
	@ls -l $(EVERYTHING) | \
		egrep '^[^l].w' | \
		sed 's;.* ;;'   # strip to last space

populate: $(EVERYTHING)

$(EVERYTHING):
	co -r$(revision) $@

