# Makefile for CM11, a program to control an X10 CM11A computer interface.
# $Revision: 1.12 $
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:
#	   -DVENIX	if using VENIX
#	   -DSYSV	if using SYSTEM V
#	   -DVOID	if compiler doesn't understand 'void'
#	   -DMINIEXCH	if using the DEC mini-exchange

CFLAGS = -O $(DFLAGS) -Wall
#LDFLAGS = -z -i
#LIBS = -lm -lc_s		# uncomment if using shared libraries
LIBS = -lm -lc

##  For LINUX, use the following defines in addition to what's above
DFLAGS = -DSYSV -DPOSIX -DHAS_ITIMER -DLINUX -DHASSELECT

##  For solaris, use the following defines in addition to what's above
# DFLAGS = -DSYSV -DPOSIX -DSOLARIS -DLOCKDIR=\"/var/spool/locks\" -DHASSELECT

## if you're using freebsd, just set the flag for select.
# DFLAGS= -DHASSELECT

## If you aren't sure, try this
#DFLAGS = -DSYSV -DPOSIX 

## Use the following for nextstep 3.3 (uncomment the next 4 lines)
#DFLAGS =  -DPOSIX
#CFLAGS = -g $(DFLAGS) -posix
#LDFLAGS = -posix
#LIBS = -lm -lposix
##end of nextstep

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

EVERYTHING = $(OTHERSRC) $(SRCS)

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.htm 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
	tar -czvf x10_heyu.tgz heyu.dir

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.htm 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

list:
	@ls $(EVERYTHING) | more

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

populate: $(EVERYTHING)

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

