#
# Makefile for sndconfig
#
#	$Id: Makefile,v 1.54 2001/03/15 22:16:05 notting Exp $	

CFLAGS     = -Wall $(INCLUDEPATH) -D_GNU_SOURCE=1 $(RPM_OPT_FLAGS) -g
LDFLAGS    = $(LIBPATH)
LOADLIBES  = -lkudzu /usr/lib/libnewt.a /usr/lib/libslang.a -lpci
prefix = /usr

mandir=/usr/share/man

ifneq ($(DEBUG),)
CFLAGS += -DDEBUG -ggdb
LDFLAGS += -g 
endif

VERSION=$(shell awk '/Version:/ { print $$2 }' sndconfig.spec)
CVSROOT=$(shell cat CVS/Root)
CVSTAG = r$(subst .,-,$(VERSION))

CFLAGS	+= -DVERSION=\"$(VERSION)\"

ARCH := $(patsubst sparc64,sparc,$(patsubst i%86,i386,$(shell uname -m)))

AR      = ar
RANLIB  = ranlib

OBJECTS = sndconfig.o
SOURCES = sndconfig.c

all: sndconfig sample po

sndconfig: $(OBJECTS)
	$(CC) -o sndconfig $(OBJECTS) $(LDFLAGS) $(LOADLIBES)

sample: sample.uue sample2.uue
	uudecode sample.uue > sample.au
	uudecode sample2.uue > sample2.au

po:	dummy
	make -C po
	
$(OBJECTS): $(SOURCES) $(HEADERS)

install:
	[ -d $(prefix)/sbin ] || install -m 755 -d $(prefix)/sbin
	[ -d $(prefix)/share/sndconfig ] || install -m 755 -d $(prefix)/share/sndconfig
	[ -d $(mandir)/man8 ] || install -m 755 -d $(mandir)/man8
	for d in sndconfig ; do \
	     install -s -m 755 $$d $(prefix)/sbin ;\
	     install -m 644 $$d.man $(mandir)/man8/$$d.8 ;\
	done
	install -m 644 sample.au $(prefix)/share/sndconfig
	install -m 644 sample2.au $(prefix)/share/sndconfig
	install -m 644 sample.midi $(prefix)/share/sndconfig
	make -C po instroot=$(prefix) install

clean:
	rm -f *.o *.a *~ core sndconfig sample*.au *.tar.*
	make -C po clean

tag-archive:
	@cvs -Q tag -F $(CVSTAG)

create-archive:
	@rm -rf /tmp/sndconfig
	@cd /tmp ; cvs -Q -d $(CVSROOT) export -r$(CVSTAG) sndconfig || echo "Um... export aborted."
	@mv /tmp/sndconfig /tmp/sndconfig-$(VERSION)
	@cd /tmp ; tar --bzip2 -cSpf sndconfig-$(VERSION).tar.bz2 sndconfig-$(VERSION)
	@rm -rf /tmp/sndconfig-$(VERSION)
	@cp /tmp/sndconfig-$(VERSION).tar.bz2 .
	@rm -f /tmp/sndconfig-$(VERSION).tar.bz2
	@echo ""
	@echo "The final archive is in sndconfig-$(VERSION).tar.bz2"

archive: clean tag-archive create-archive

dummy:
