
.EXPORT_ALL_VARIABLES:


#####################################################################
# Set this to the destination-directory for Purp
#####################################################################
BINDIR = /usr/sbin

#####################################################################
# Uncomment -DDEBUG_TO_TERM to enable functions that send debug-info 
# to a term-device. The device is selected by the --debug <device>
# argument on the commandline.
#####################################################################
DEBUG        = #-DDEBUG_TO_TERM #-ggdb

DEFINES      = ${DEBUG}

CC           = c++
LINK	     = $(CC)
O            = -O2 -pipe

INCPATHS     = -I/usr/include -I/usr/include/ncurses
INCLUDES     =

LIBPATHS     = -L/lib -L/usr/local/lib -L/usr/lib
LIBS         = -lrpm -lbsd -lncurses -lz -ldb 

CFLAGS       = $(O) $(DEFINES) $(INCPATHS) $(INCLUDES)
LFLAGS       = $(LIBPATHS) $(LIBS)


## Objects ################################################

OBJECTS = main.o \
          mainloop.o \
          table.o \
          tools.o \
          linklist.o \
          dir.o \
          textwindow.o \
          install.o \
	  pwindow.o \
	  progresswin.o \
          cmdwin.o \
	  pathwin.o \
	  list.o
       
TARGET =  purp


## Implicit rules #########################################

.SUFFIXES: .cpp .c

.cpp.o:
	$(CC) -c $(CFLAGS) -o $@ $<

.c.o:
	$(CC) -c $(CFLAGS) $(INCPATHS) -o $@ $<


## Build rules ############################################

all: $(TARGET) 


$(TARGET): $(OBJECTS)
	$(CC) $(OBJECTS) -o $(TARGET) $(LFLAGS)


clean:
	rm -f *.o *.bak *BAK *~ *% #* 
	rm -f $(TARGET)


install:
	install -o root -m 755 -s $(TARGET) $(BINDIR)	
	install -o root -m 644 purp.8 /usr/man/man8

count:
	@echo -n "        Header files (lines): "; cat *.h | wc -l;
	@echo -n "Implementation files (lines): "; cat *.c* | wc -l
