# Linux Makefile for Groovy console CD player
# 
export CFLAGS
srcdir	:= .
CC	:= gcc

# Some CD players require an extra call to get them to start spinning.
# If the CD player doesn't play a CD, or is slow in doing so, try uncommenting
# this and rebuilding the binary.
#DEFINES := -DKICKSTART

CFLAGS	:= -O2 -fomit-frame-pointer $(DEFINES) $(machine)
LIBS	:= -lncurses
LDFLAGS	:= -s $(LIBS)
WARN	:= -Wall
# bindir is your installation dir
bindir	:= /usr/local/bin
binmode := 0755
mandir	:= /usr/man/man1
mangrp	:= daemon
manown	:= daemon

##kernver := $(basename $(shell uname -r))
##ifeq ($(kernver),1.0)
##CFLAGS := $(CFLAGS) -DKVER_10
##endif

.c.o:
	$(CC) $(WARN) $(CFLAGS) -c $*.c

all: groovycd

lazy:
	$(MAKE) all CFLAGS:='$(CFLAGS) -DWBLAZY'

groovycd: main.o hardware.o init.o cddb.o ncurses.o help.o
	$(CC) -o $@ $^ $(LDFLAGS)

install: groovycd
	cp groovycd $(bindir)
	chmod $(binmode) $(bindir)/groovycd
	ln -sf $(bindir)/groovycd $(bindir)/gcd
	@echo "***************************"
	@echo groovycd linked to gcd 
	@echo "***************************"

clean:
	rm -f groovycd *.o core *~ erro *.bak

# Miroslav Vasko (vasko@ies.sk) - uninstall is a good thing

uninstall:
	if [ -f $(bindir)/groovycd ] ; then
	  rm $(bindir)/groovycd
	fi
	if [ -L $(bindir)/gcd ] ; then
	  rm $(bindir)/gcd
	fi
