######################
# Makefile for ntape #
######################

VERSION = 0.20

### Defines ###

# Uncomment this if you want to have debug output to stderr. But beware!!
# The output can be incredible huge!!
#DEBUG = -DDEBUG

# If you have to uncomment the following two defines you should contact me
# to fix the problems in the code. Enabling them is not the clean way.

# Uncomment this if you have problems with weird "tape is offline" messages.
# This may cause some strange behaviour.
#OFFLINE = -DNO_OFFLINE

# Uncomment this if you have problems with weird "tape is write protected"
# messages. This may cause some trouble if you try to add an archive on
# a write protected tape. So please uncomment this only if it is really
# necessary.
#WRITE_PROTECTED = -DNO_WRITE_PROTECTED

# where do you want the binary and the man page to be installed
BINDIR  = /usr/local/bin
MANDIR  = /usr/local/man/man1
#BINDIR  = /home/matze/bin

# the C compiler
CC      = gcc

# where are your ncurses includes
CURSDIR = /usr/include/ncurses

PRGNAME = ntape
INCFLAG = -I$(CURSDIR) -I.
WFLAGS  = -Wall -Wstrict-prototypes -Wmissing-prototypes #\
#          -Wuninitialized -Wcast-qual -Wbad-function-cast \
#          -Wpointer-arith -Wmissing-declarations -Wtraditional -Wconversion \
#          -Wcomment -Wenum-clash -Wcast-align -Winline -Wshadow \
#          -Wid-clash-31

DEFINES = $(DEBUG) $(OFFLINE) $(WRITE_PROTECTED)
CFLAGS  = $(DEFINES) $(WFLAGS) -O3 -fomit-frame-pointer $(INCFLAG)
SRCS    = color.c entryfld.c exit.c filedlg.c footer.c init.c initscr.c \
          list.c menu.c msgbox.c mt.c ntape.c options.c scroll.c statusline.c \
          tape.c tapelist.c tarlist.c tools.c utils.c version.c watch.c win.c
OBJS    = color.o entryfld.o exit.o filedlg.o footer.o init.o initscr.o \
          list.o menu.o msgbox.o mt.o ntape.o options.o scroll.o statusline.o \
          tape.o tapelist.o tarlist.o tools.o utils.o version.o watch.o win.o
LDFLAGS = -lncurses

all:	Version version.h $(PRGNAME)

Version:
	@rm -f version.h

version.h:
	@echo \#define VERSION \"$(VERSION)\" > version.h
	@echo \#define COMPILE_TIME \"`date`\" >> version.h

$(PRGNAME): $(OBJS)
	$(CC) $(OBJS) -o $(PRGNAME) $(LDFLAGS)

install: all
	install -c -s $(PRGNAME) $(BINDIR)
	install -c $(PRGNAME).man $(MANDIR)/$(PRGNAME).1
clean:	
	rm -f version.h $(OBJS) $(PRGNAME) *~ "#"* *.bak

mrproper: clean
	rm -f debug .depend

depend:
	touch version.h
	$(CPP) $(INCFLAG) -M $(SRCS) >.depend
	rm -f version.h
#
# include a dependency file if one exists
#

ifeq (.depend,$(wildcard .depend))
include .depend
endif
