#
#
VERSION=0.4

#
# Your favorite compiler (you'll need an ANSI C Compiler).
#
CC=gcc
CPP=gcc -E

#
# Installation directories
#
prefix=/usr/local
bindir=$(prefix)/bin
libdir=$(prefix)/lib
mandir=$(prefix)/man/man1
NC_HLP=-DHELPFILE=\""$(libdir)/nc.hlp"\"
NC_PROFILE=-DPROFILE=\""$(libdir)/nc.ini"\"
NC_MENU=-DMENU=\""$(libdir)/nc.menu"\"
VARS=$(NC_HLP) $(NC_PROFILE) $(NC_MENU)

#NC_HLP=-DHELPFILE=\""nc.hlp"\"

#
# The directory where you installed the ncurses include files.
# On some Linux machines it's on /usr/include/ncurses, if you don't
# change this you will get another ncurses.h and get plenty of error
# messages when compiling main.c.
#
NCURSES=/usr/local/include
#NCURSES=/usr/include/ncurses

#
# The directory where the libncurses.a file resides.
#
LIBPATH=/usr/local/lib

CFLAGS=-g -O -I$(NCURSES) $(COPTS) -fwritable-strings $(VARS)

# 
# Use V=n for the production version.
# Use V=d for the debugging version.
V=n
#V=d

# Rules
.c.o:
	$(CC) $(CFLAGS) -c $<

#
# The files that made up the MouseLess Commander
#
OBJS = dir.o util.o main.o screen.o dialog.o key.o input.o menu.o\
       file.o win.o color.o help.o find.o profile.o user.o $(GNU_OBJS)

LIBS = -ltermcap -L$(LIBPATH)
PROGS = dir

ifeq (Make.local,$(wildcard Make.local))
include Make.local
endif
all: nc

nc: $(OBJS)
	$(CC) $(CFLAGS) $(OBJS) -o nc $(LIBS) -l$(V)curses

#
# Debugging target
ncd: $(OBJS)
	$(CC) $(CFLAGS) $(OBJS) -o ncd $(LIBS) -ldcurses -DTRACE


depend dep:
	$(CPP) -M -I$(NCURSES) *.c > .depend

install:
	-mkdir $(bindir)
	-mkdir $(libdir)
	-mkdir $(mandir)
	install nc $(bindir)
	install nc.hlp $(libdir)
	install nc.1 $(mandir)

clean: 
	rm -f *.o 
	rm -f *~
	rm -f TAGS
	rm -f a.out core nc
	rm -f $(PROGS)
	rm -f .depend

dist:
	-mkdir ../mc-$(VERSION)
	cp *.c *.h README Makefile COPYING TODO nc.hlp \
	INSTALL nc.1 ChangeLog NEWS ../mc-$(VERSION) 
	(cd ..; tar cvf mc-$(VERSION).tar mc-$(VERSION))

caca:
#        mkdir mc-`cat nc/.version`
#	cp nc/*.c nc/*.h nc/README nc/Makefile nc/COPYING nc/TODO 
#	nc/nc nc/nc.hlp mc-`cat nc/.version`
#	tar cvf mc-`cat nc/.version
#	)

#
# Include dependencies.
#
ifeq (.depend,$(wildcard .depend))
include .depend
endif