# Makefile for ADCD - A Diminutive CD player for Linux
# Copyright (C) 2004 Antonio Diaz Diaz.

prefix = /usr/local
bindir = $(prefix)/bin
mandir = $(prefix)/share/man

DISTNAME = adcd-0.3

CXX = g++
INSTALL = install
INSTALL_PROGRAM = $(INSTALL)
INSTALL_DATA = $(INSTALL) -m 644
SHELL = /bin/sh
CPPFLAGS =
CXXFLAGS = -Wall -W -O2
LDFLAGS  = -lncurses

objs = cd.o adcd.o

.PHONY : all install uninstall dist clean distclean

all : adcd

adcd : $(objs)
	$(CXX) $(LDFLAGS) $(CXXFLAGS) -o adcd $(objs)
	strip adcd

doc : adcd
	help2man -o adcd.1 --no-info ./adcd

%.o : %.cc
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<

$(objs) : cd.h


install : all
	if test ! -d $(bindir) ; then $(INSTALL) -d $(bindir) ; fi
	if test ! -d $(mandir)/man1 ; then $(INSTALL) -d $(mandir)/man1 ; fi
	$(INSTALL_PROGRAM) -p -m 755 ./adcd $(bindir)/adcd
	$(INSTALL_DATA) -p ./adcd.1 $(mandir)/man1/adcd.1

uninstall :
	-rm -f $(bindir)/adcd
	-rm -f $(mandir)/man1/adcd.1

dist :
	ln -sf . $(DISTNAME)
	tar -cvf $(DISTNAME).tar \
	  $(DISTNAME)/COPYING \
	  $(DISTNAME)/ChangeLog \
	  $(DISTNAME)/INSTALL \
	  $(DISTNAME)/LEEME \
	  $(DISTNAME)/Makefile \
	  $(DISTNAME)/README \
	  $(DISTNAME)/adcd.1 \
	  $(DISTNAME)/*.cc \
	  $(DISTNAME)/*.h
	rm -f $(DISTNAME)
	bzip2 -v $(DISTNAME).tar

clean :
	-rm -f adcd $(objs)

distclean : clean
	-rm -f *.tar *.bz2
