SHELL = /bin/sh

PREFIX=/usr/local
INSTDIR=$(DESTDIR)/$(PREFIX)/bin
MANDIR=$(DESTDIR)/$(PREFIX)/man

CC = gcc
LD = gcc

EXECS = scsi_serialno scsimap scsiremap


CFLAGS = -g -O2 -Wall -D_REENTRANT
# CFLAGS = -g -O2 -Wall -D_REENTRANT -DSG_KERNEL_INCLUDES
# CFLAGS = -g -O2 -Wall -pedantic -D_REENTRANT

LDFLAGS =

all: $(EXECS) scsimap.1.gz


depend dep:
	for i in *.c; do $(CC) $(INCLUDES) $(CFLAGS) -M $$i; \
	done > .depend

clean:
	/bin/rm -f *.o scsi_serialno scsimap.1.gz core .depend 

scsi_serialno: scsi_serialno.o
	$(LD) -o $@ $(LDFLAGS) $^ 

scsimap.1.gz:	scsimap.1
	gzip < scsimap.1 > scsimap.1.gz

install: $(EXECS) scsimap.1.gz
	install -d $(INSTDIR)
	install -d ${MANDIR}/man1
	for name in $^; \
	 do install -o root -g root -m 755 $$name $(INSTDIR); \
	done
	install -o root -g root -m 644 scsimap.1.gz ${MANDIR}/man1

uninstall:
	dists="$(EXECS)"; \
	for name in $$dists; do \
	 rm -f $(INSTDIR)/$$name; \
	done
	rm -f ${MANDIR}/man1/scsimap.1.gz

ifeq (.depend,$(wildcard .depend))
include .depend
endif
