PROGS	= lscfg lsmcode lsvio lsvpd update-lsvpd-db
#PROGS2	= tidy_lsvpd_dbs tidy_subdirs lsvpd_test \
PROGS2	= tidy_lsvpd_dbs tidy_subdirs \
	update-vpd.hotplug vpd-name-crosslink.hotplug

DATAS	= lsvpd-functions.bash debug.bash

GEN_SRC	= lsvpd.in \
		tidy_lsvpd_dbs.in \
		update-lsvpd-db.in \
		update-vpd.hotplug.in vpd-name-crosslink.hotplug.in \
		#lsvpd_test.in
GEN	= $(GEN_SRC:.in=) lscfg lsmcode lsvio

DATADIRS = common.d  common-post.d \
		scan.d query.d \
		 lsvpd.d lscfg.d lsmcode.d lsvio.d

INSTALL = /usr/bin/install -c
INSTALL_PROGRAM = $(INSTALL) -m 755
INSTALL_DATA = $(INSTALL) -m 644

all:		$(GEN)

lscfg:		lsvpd
		cp -a $< $@

lsmcode:	lsvpd
		cp -a $< $@

lsvio:		lsvpd
		cp -a $< $@

%:	%.in ../Makefile
	sed -e "s%@libdir@%$(libdir)%g" \
		-e "s%@VERSION@%$(VERSION)%g" \
		-e "s%@DATE@%$(shell date +'%a, %d %b %Y %T %z')%g" \
		$< > $@
	chmod 755 $@

install:	all
	@ for f in $(PROGS) ; do \
		$(INSTALL_PROGRAM) $$f $(DESTDIR)$(sbindir) ;\
	done
	@ for f in $(PROGS2) ; do \
		$(INSTALL_PROGRAM) $$f $(DESTDIR)$(libdir) ;\
	done
	@ for f in $(DATAS) ; do \
		$(INSTALL_DATA) $$f $(DESTDIR)$(libdir) ;\
	done
	@ for d in $(DATADIRS) ; do \
		if [ -d "$$d" ] ; then \
			rm -rf $(DESTDIR)$(libdir)/$$d ;\
		fi ;\
		mkdir -p $(DESTDIR)$(libdir)/$$d ;\
		for f in $$d/* ; do \
			if [ -f "$$f" ] ; then \
				$(INSTALL_DATA) $$f $(DESTDIR)$(libdir)/$$d ;\
			fi ;\
		done ;\
	done

clean:
	rm -f $(GEN)
