#============================================================#
#                                                            #
# SADP version 1.1.4 - Make file.             Jun-99  A.C.E. #
#                                                            #
#============================================================#
# Select one of two following combinations to enable or disable
# mouse support through GPM

GPM_SUPPORT = 1   # GPM support included
GPM_LIB = -lgpm

#GPM_SUPPORT=0   # No GPM support
#GPM_LIB =
#
#------------------------------------------------------------------
# Select a directories for binaries and man pages
BINDIR = /usr/bin
MANDIR = /usr/man/man1

# BINDIR = /usr/local/bin
# MANDIR = /usr/local/man/man1

#-------------------------------------------------------------
# Select compressed/uncompressed format of man page
# By default the Makefile script will try to guess

#ZIPPED_MAN = 1
#ZIPPED_MAN = 0

#-------------------------------------------------------------
# Compiler name and compilation flags
CC = gcc
CFLAGS = -Wall -O2 -m486
#CFLAGS = -Wall -g -O2 -m486

#-------------------------------------------------------------
# Path to the libraries need for binding
CURS_LIBDIR =  -L /usr/local/lib  -L /usr/lib

#============================================================#
#                                                            #
# You probably shouldn't change anything below this line ... #
#                                                            #
#============================================================#
CURS_LIBS = -lncurses -lm

COMMON_MODULES =  sadp_cdaudio.o sadp_sound.o sadp_dbase.o
CURS_MODULES =    sadp_main.o sadp_args.o sadp_info.o sadp_text.o \
                  sadp_curses.o sadp_cursext.o sadp_gpm.o

all: sadp 

.depend.src:  
	make  warn
	@echo '# SADP dependencies' >>.depend.src
	$(CC) -MM $(patsubst %.o,%.c,$(COMMON_MODULES) $(CURS_MODULES)) >>.depend.src

warn:
	@echo ""
	@echo "###########################################################"
	@echo "#   IMPORTANT! If you get compilation or link errors,     #"
	@echo "#   refer to TROUBLESHOOTING section in Readme.install    #"
	@echo "###########################################################"
	@echo ""

dep:   .depend.src .depend.xsrc Makefile

sad.h:	Makefile

sadp_gpm_support.h:  Makefile
	echo "#define GPM_SUPPORT $(GPM_SUPPORT)" > sadp_gpm_support.h

sadp:   .depend.src Makefile $(COMMON_MODULES) $(CURS_MODULES)
	$(CC)  -o sadp $(CFLAGS) $(CURS_LIBDIR) $(CURS_LIBS) $(GPM_LIB) $(COMMON_MODULES) $(CURS_MODULES)

clean:
	rm   *.o .depend.src .depend.xsrc

install: install.bin install.man

install.bin: sadp
	install -d $(BINDIR)
	install sadp $(BINDIR)

ifndef ZIPPED_MAN
ifeq ($(shell echo /usr/man/man?/*.gz), /usr/man/man?/*.gz)
        ZIPPED_MAN=0
else
        ZIPPED_MAN=1
endif
endif

install.man:
	install -d $(MANDIR)
ifeq ($(ZIPPED_MAN), 1)
	gzip -c sadp.1 > $(MANDIR)/sadp.1.gz
else
	install sadp.1 $(MANDIR)
endif

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


