# Make file for eject

# to be overidden when building Debian packages
DESTDIR =

# Default device to eject. Can be a partial name such as "cdrom" or
# a full device name such as "/dev/sda4".
DEFAULTDEVICE = \"cdrom\"

# Location to install binary. Default is /usr/local/bin. You may
# prefer to install it in /usr/bin or /sbin
BINDIR	= /usr/local/bin
#BINDIR=/usr/bin
#BINDIR=/usr/sbin

# Location to install man page. Default is /usr/local/man. You may
# prefer to install it in /usr/man
MANDIR	= /usr/local/man
#MANDIR	= /usr/man

# File permissions for binary. Use MODE=4555 if you want to install it
# setuid root (see man page).
MODE	= 555
#MODE	= 4555

# Compiler to use
CC	= gcc

# Linker to use
LD	= gcc

# Preprocessor options
# Define -DGETOPTLONG if you have GNU getopt_long()
# -I options are needed for some systems that do not have /usr/include/scsi
CPPFLAGS = -I/usr/src/linux -I/usr/src/linux/include -DDEFAULTDEVICE=$(DEFAULTDEVICE) -DGETOPTLONG

# Compile and link options
# On a.out systems you might want to add -N when linking
# RPM_OPT_FLAGS can be set by rpm tool
# ...For production code
CFLAGS	= -Wall -O3 $(RPM_OPT_FLAGS)
LDFLAGS = -s
# ...For debug
#CFLAGS	= -Wall -g
#LDFLAGS = -g

eject:	eject.o
	$(LD) $(LDFLAGS) -o eject eject.o

eject.o: eject.c
	$(CC) $(CPPFLAGS) $(CFLAGS) -c eject.c

volname: volname.o
	$(LD) $(LDFLAGS) -o volname volname.o

volname.o: volname.c
	$(CC) $(CPPFLAGS) $(CFLAGS) -c volname.c

install: eject
	install -D -m $(MODE) eject $(DESTDIR)$(BINDIR)/eject
	install -D -m 444 eject.1 $(DESTDIR)$(MANDIR)/man1/eject.1
	@for dir in /bin /usr/bin /sbin /usr/sbin /usr/local/bin /usr/local/sbin ; do \
	  test $(BINDIR) = $$dir  && continue ; \
	  if [ -x $$dir/eject ] ; then  \
	    echo "Note: There is another version of eject in $$dir" ; \
	  fi ; \
	done

clean:
	$(RM) eject eject.o volname volname.o core *~
	$(RM) -r debian/tmp

dist:	clean
	cd .. ; tar --exclude RCS -czvf eject-2.0.3.tar.gz eject-2.0.3

deb:	eject
	fakeroot debian/rules binary
