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

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

DISTNAME = adcd-0.5

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

objs = msf_time.o cd.o main.o

.PHONY : all doc 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) : Makefile msf_time.h cd.h


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

uninstall :
	-rm -f $(DESTDIR)$(bindir)/adcd
	-rm -f $(DESTDIR)$(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
