+# Makefile for udev extra invoked from the udev main Makefile
#
# Copyright (C) 2003 IBM
+# Copyright (C) 2004-2005 Kay Sievers <kay.sievers@vrfy.org>
#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
+# Released under the GNU General Public License, version 2.
#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-SCSI_ID_VERSION=0.2
+SCSI_ID_VERSION = 0.9
+
+PROG = scsi_id
+OBJS= scsi_serial.o
+HEADERS = scsi_id.h scsi.h scsi_id_version.h
+GEN_HEADERS = scsi_id_version.h
+MAN_PAGES = scsi_id.8
prefix =
-sbindir = ${prefix}/sbin
+exec_prefix = ${prefix}
+etcdir = ${prefix}/etc
+sbindir = ${exec_prefix}/sbin
+usrbindir = ${exec_prefix}/usr/bin
+usrsbindir = ${exec_prefix}/usr/sbin
mandir = ${prefix}/usr/share/man
+configdir = ${etcdir}/udev/
+srcdir = .
-INSTALL = /usr/bin/install -c
+INSTALL = /usr/bin/install -c
INSTALL_PROGRAM = ${INSTALL}
INSTALL_DATA = ${INSTALL} -m 644
+INSTALL_SCRIPT = ${INSTALL_PROGRAM}
-# Note some of the variables used here are set when built under udev, and
-# otherwise might not be set.
+# be able to run without udev
+LIBSYSFS = -lsysfs
+CROSS =
+QUIET =
+CC = $(CROSS)gcc
+LD = $(CROSS)gcc
+AR = $(CROSS)ar
+STRIPCMD = $(CROSS)strip
+CFLAGS += -Wall -pipe -fno-builtin -Wstrict-prototypes -Wsign-compare -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
+LDFLAGS += -Wl
-override CFLAGS+=-DSCSI_ID_VERSION=\"$(SCSI_ID_VERSION)\" $(DEBUG) -Wall
+all: $(PROG) $(MAN_PAGES)
+.PHONY: all
+.DEFAULT: all
-PROG=scsi_id
-SYSFS=-lsysfs
+%.o: %.c $(GEN_HEADERS)
+ $(QUIET) $(CC) -c $(CFLAGS) $< -o $@
-#
-# Built static and stripped when built with udev.
-#
-# STRIP=-s
-# LDFLAGS=$(STRIP)
-LD=$(CC)
+$(PROG): %: $(HEADERS) %.o $(OBJS)
+ $(QUIET) $(LD) $(LDFLAGS) $@.o $(OBJS) -o $@ $(LIBUDEV) $(LIBSYSFS) $(LIB_OBJS)
+ $(QUIET) $(STRIPCMD) $@
-OBJS= scsi_id.o \
- scsi_serial.o \
+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\" >> $@
-all: $(PROG)
+# man pages
+%.8: %.xml
+ xmlto man $?
+.PRECIOUS: %.8
-# XXX use a compressed man page?
+clean:
+ rm -f $(PROG) $(OBJS) $(GEN_HEADERS)
+.PHONY: clean
-install: all
- $(INSTALL_PROGRAM) -D $(PROG) $(sbindir)/$(PROG)
+install-bin: all
+ $(INSTALL_PROGRAM) $(PROG) $(DESTDIR)$(sbindir)/$(PROG)
+.PHONY: install-bin
+
+uninstall-bin:
+ - rm $(DESTDIR)$(sbindir)/$(PROG)
+.PHONY: uninstall-bin
+
+install-man:
$(INSTALL_DATA) -D scsi_id.8 $(DESTDIR)$(mandir)/man8/scsi_id.8
-
-uninstall:
- -rm $(sbindir)/$(PROG)
- -rm $(mandir)/man8/scsi_id.8
+.PHONY: uninstall-man
-$(OBJS): scsi_id.h scsi.h
+uninstall-man:
+ -rm -f $(DESTDIR)$(mandir)/man8/scsi_id.8
+.PHONY: uninstall-man
-clean:
- rm -f $(PROG) $(OBJS)
+install-config:
+ @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
+.PHONY: install-config
+
+install: all install-bin install-config install-man
+.PHONY: install
-$(PROG): $(OBJS)
- $(LD) $(LDFLAGS) -o $(PROG) $(CRT0) $(OBJS) $(SYSFS) $(LIB_OBJS) $(ARCH_LIB_OBJS)
+uninstall: uninstall-bin uninstall-man
+.PHONY: uninstall