prefix ?= /

CC =	gcc
LIBS =	-lutil


all: empty_tty empty_tty.1.gz mbm-power.1.gz 01f3507g f3507g.conf f3507g_autosuspend

empty_tty: empty_tty.c
	${CC} ${CFLAGS} -Wall ${LIBS} -o empty_tty empty_tty.c

mbm-power.1.gz: mbm-power.1
	gzip -9 < $< > $@

empty_tty.1.gz: empty_tty.1
	gzip -9 < $< > $@

install: mbm-power.1.gz 01f3507g f3507g.conf f3507g_autosuspend empty_tty change_powerstate
	mkdir -p $(DESTDIR)$(prefix)/etc/pm/sleep.d/
	install --mode=755 01f3507g $(DESTDIR)$(prefix)/etc/pm/sleep.d/01f3507g
	install --mode=644 f3507g.conf $(DESTDIR)$(prefix)/etc/f3507g.conf
	
	mkdir -p $(DESTDIR)$(prefix)/usr/share/man/man1/
	install --mode=644 mbm-power.1.gz $(DESTDIR)$(prefix)/usr/share/man/man1/mbm-power.1.gz

	[ -f `which strip` ] && strip empty_tty
	mkdir -p $(DESTDIR)$(prefix)/usr/bin/
	install --mode=755 empty_tty $(DESTDIR)$(prefix)/usr/bin/empty_tty
	install --mode=644 empty_tty.1.gz $(DESTDIR)$(prefix)/usr/share/man/man1/empty_tty.1.gz
	install --mode=755 f3507g_autosuspend $(DESTDIR)$(prefix)/usr/bin/f3507g_autosuspend
	install --mode=755 change_powerstate $(DESTDIR)$(prefix)/usr/bin/change_powerstate

distclean: clean

deinstall:
	rm $(DESTDIR)$(prefix)/usr/bin/empty_tty
	rm $(DESTDIR)$(prefix)/usr/share/man/man1/empty_tty.1
	
uninstall:	deinstall


clean:
	rm -f mbm-power.1.gz
	rm -f empty_tty
	rm -f empty_tty.1.gz
	
FreeBSD:	empty_tty
NetBSD:		empty_tty
OpenBSD:	empty_tty

Linux:		empty_tty
Cygwin:		empty_tty

UnixWare:	SunOS
OpenUNIX:	SunOS
AIX:		SunOS
OSF1:		SunOS
HP-UX:		SunOS
SunOS:
	cc -o empty_tty empty_tty.c

UnixWare-gcc:	SunOS-gcc
OpenUNIX-gcc:	SunOS-gcc
HP-UX-gcc:	SunOS-gcc
SunOS-gcc:
	gcc ${CFLAGS} -Wall -o empty_tty empty_tty.c




