# $Id: Makefile.in,v 1.4 1997/04/03 08:57:11 fritz Exp $
#
# Makefile for telesctrl
# (C) 1997 Fritz Elfert
#
#
SHELL			= /bin/sh
CFLAGS			= -Wall -O2 -I.
LDFLAGS			= -L../lib @LIBS@
PROGRAMS		=
MODULES			= telesctrl.o
MANPAGES		=
INSTALL			= @INSTALL@
INSTALL_PROGRAM	= $(INSTALL) -o 0 -g 0 -m 0750
INSTALL_MAN		= $(INSTALL) -o 0 -g 0 -m 0644
prefix			= @prefix@
exec_prefix		= @exec_prefix@
ifeq (../.config,$(wildcard ../.config))
	include ../.config
	SBINDIR			= $(CONFIG_SBINDIR)
	mandir			= $(CONFIG_MANDIR)
	ifeq ($(CONFIG_TELESCTRL),y)
		PROGRAMS	+= telesctrl
		MANPAGES	+= telesctrl.8
	endif
	ifeq ($(CONFIG_HISAXCTRL),y)
		PROGRAMS	+= hisaxctrl
		MANPAGES	+= hisaxctrl.8
	endif
else
	MANPAGES		= telesctrl.8
	SBINDIR			= /sbin
	mandir			= @mandir@
endif
MAN8DIR			= $(mandir)/man8
CC				= @CC@

#.SUFFIXES:
#.SUFFIXES: .c .o

%.8: %.man
	cp $< $@

all: $(PROGRAMS) $(MANPAGES)

config:
	@./configure

telesctrl:	$(MODULES)
	$(CC) $(CFLAGS) $? $(LDFLAGS) -o $@

hisaxctrl:	$(MODULES)
	$(CC) $(CFLAGS) $? $(LDFLAGS) -o $@

hisaxctrl.8: telesctrl.8
	cp $< $@

install: $(PROGRAMS) $(MANPAGES)
	mkdir -p $(SBINDIR)
	$(INSTALL_PROGRAM) $(PROGRAMS) $(SBINDIR)
	mkdir -p $(MAN8DIR)
	$(INSTALL_MAN) $(MANPAGES) $(MAN8DIR)

install-strip: $(PROGRAMS) $(MANPAGES)
	mkdir -p $(SBINDIR)
	$(INSTALL_PROGRAM) -s $(PROGRAMS) $(SBINDIR)
	mkdir -p $(MAN8DIR)
	$(INSTALL_MAN) $(MANPAGES) $(MAN8DIR)

uninstall:
	@for i in `echo $(PROGRAMS)` ; do \
		rm -f $(SBINDIR)/$$i ; \
	done
	@for i in `echo $(MANPAGES)` ; do \
		rm -f $(MAN8DIR)/$$i ; \
	done

clean:
	rm -f *.o *~ $(PROGRAMS) *.8

distclean: clean
	rm -f config.status config.cache config.log Makefile
