chiark / gitweb /
fix usb_id and let scsi_id ignore "illegal request"
[elogind.git] / extras / scsi_id / Makefile
index 5ad2bcf3e12717fe8084c8b89f8f9a246fcdf7de..7aa3e83470a0cc0dc5de6dfbf91bc5927f02ecfa 100644 (file)
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
-VERSION=0.1
+SCSI_ID_VERSION=0.9
 
 prefix =
+etcdir =        ${prefix}/etc
 sbindir =      ${prefix}/sbin
+mandir =       ${prefix}/usr/share/man
 
 INSTALL  = /usr/bin/install -c
 INSTALL_PROGRAM = ${INSTALL}
 INSTALL_DATA  = ${INSTALL} -m 644
 
-CFLAGS=-DVERSION=\"$(VERSION)\" $(DEBUG) -Wall
+# Note some of the variables used here are set when built under udev, and
+# otherwise might not be set.
+
+override CFLAGS+=-Wall -fno-builtin
 
 PROG=scsi_id
+SYSFS=-lsysfs
 
-LIBSYSFS=-lsysfs
-STRIP=-s
-LDFLAGS=$(STRIP) --static
+#
+# Built static and stripped when built with udev.
+#
+# STRIP=-s
+# LDFLAGS=$(STRIP)
+LD=$(CC)
 
-OBJS= scsi_id.o \
-       scsi_serial.o \
+OBJS=  scsi_id.o scsi_serial.o
 
 all:   $(PROG)
 
+# XXX use a compressed man page?
+
 install: all
-       $(INSTALL_PROGRAM) -D $(PROG) $(sbindir)/$(PROG)
+       $(INSTALL_PROGRAM) -D $(PROG) $(DESTDIR)$(sbindir)/$(PROG)
+       $(INSTALL_DATA) -D scsi_id.8 $(DESTDIR)$(mandir)/man8/scsi_id.8
+       @if [ ! -r $(DESTDIR)$(etcdir)/scsi_id.config ]; then \
+               echo $(INSTALL_DATA) -D ./scsi_id.config  $(DESTDIR)$(etcdir); \
+               $(INSTALL_DATA) -D ./scsi_id.config $(DESTDIR)$(etcdir)/scsi_id.config; \
+       fi
        
 uninstall:
-       -rm $(sbindir)/$(PROG)
+       -rm $(DESTDIR)$(sbindir)/$(PROG)
+       -rm $(DESTDIR)$(mandir)/man8/scsi_id.8
+       -rm $(DESTDIR)$(etcdir)/scsi_id.config
 
-$(OBJS): scsi_id.h scsi.h
+GEN_HEADER=scsi_id_version.h
+
+scsi_id_version.h:
+       @echo "/* This file is auto-generated by the Makefile */" > $@
+       @echo \#define SCSI_ID_VERSION     \"$(SCSI_ID_VERSION)\" >> $@
+       @echo \#define SCSI_ID_CONFIG_FILE     \"$(etcdir)/scsi_id.config\" >> $@
+$(OBJS): scsi_id.h scsi.h scsi_id_version.h
 
 clean:
-       rm -f $(PROG) $(OBJS)
+       rm -f $(PROG) $(OBJS) $(GEN_HEADER)
+
+spotless: clean
+
+.c.o:
+       $(QUIET) $(CC) $(CFLAGS) -c -o $@ $<
 
 $(PROG):       $(OBJS)
-       $(CC) $(OBJS) $(LDFLAGS) $(LIBSYSFS) -o $(PROG)
+       $(QUIET) $(LD) $(LDFLAGS) -o $(PROG) $(CRT0) $(OBJS) $(SYSFS) $(LIB_OBJS) $(ARCH_LIB_OBJS)