# 1/9/97
# Changed for 0.6z by John Gatewood Ham, zappaman@alphabox.buu.ac.th
# install is different due to need to remove parts of the manual page
# conditionally based on the values of HAVE_GUAGE and HAVE_RC_FILES.
# Change clean target to include dialog.1, since dialog.man is now the
# real, unprocessed man page.  It will remove dialog.in just in case it
# gets left around. Set defaults for HAVE_RC_FILE and HAVE_GUAGE to true

# 2000-02-28
# Changed for 0.7 by Thomas G. Spahni, thomas@spahni.ch
# configuration part of the Makefile

# gpm mouse support
HAVE_GPM_SUPPORT=false
# ncurses or just normal curses?
HAVE_NCURSES=true
# support of a configuration file
HAVE_RC_FILE=true
# can be disabled to make dialog a bit smaller (could be done for more things)
HAVE_GUAGE=true
# can be disabled to match original functions
HAVE_PASSWORD=true

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

CC = gcc
CPP = gcc -E
OPTIM = -O2 -Wall -Wstrict-prototypes -fomit-frame-pointer -pipe
#OPTIM = -O -Wall -Wstrict-prototypes -g -pipe

# end of the configuration part
#----------------------------------------------------------------------------
# do not edit below this line

CFLAGS = $(OPTIM) -DLOCALE -DVERSION=\"0.7\"
LDFLAGS = -L .
LDLIBS = -ldialog

OBJS = checklist.o inputbox.o menubox.o msgbox.o \
	 textbox.o util.o yesno.o

ifeq ($(HAVE_GPM_SUPPORT), true)
LDLIBS+=-lgpm
CFLAGS+=-DHAVE_LIBGPM
OBJS+=mouse.o
endif
ifeq ($(HAVE_NCURSES), true)
CFLAGS+=-DHAVE_NCURSES -I/usr/include/ncurses
LDLIBS+=-lncurses
endif
ifeq ($(HAVE_RC_FILE), true)
CFLAGS+=-DHAVE_RC_FILE
OBJS+=rc.o
endif
ifeq ($(HAVE_GUAGE), true)
OBJS+=guage.o
CFLAGS+=-DHAVE_GUAGE
endif
ifeq ($(HAVE_PASSWORD), true)
OBJS+=passwd.o
CFLAGS+=-DHAVE_PASSWORD
endif

SRCS = $(OBJS:.o=.c)

all: libdialog.a dialog
	strip dialog

libdialog.a: $(OBJS)
	ar rcs libdialog.a $(OBJS)

dialog: dialog.o

.PHONY: proper
proper:
	rm -f core *.o *~ DEADJOE libdialog.a dialog.1 dialog.1.gz dialog.in

.PHONY: clean
clean: proper
	rm -f dialog .depend
	touch .depend

include .depend

install: dialog libdialog.a
	install -s dialog $(BINDIR)
	cp dialog.man dialog.1
ifeq ($(HAVE_RC_FILE),false)
	mv dialog.1 dialog.in
	sed -e "/NOHAVERC/,/NOHAVERC/d" dialog.in >dialog.1
endif
ifeq ($(HAVE_PASSWORD),false)
	mv dialog.1 dialog.in
	sed -e "/NOHAVEPASSWORD/,/NOHAVEPASSWORD/d" dialog.in >dialog.1
endif
ifeq ($(HAVE_GUAGE),false)
	mv dialog.1 dialog.in
	sed -e "/NOHAVEGUAGE/,/NOHAVEGUAGE/d" dialog.in >dialog.1
endif
	mv dialog.1 dialog.in
	sed -e "/COMMENTSTART/,/COMMENTEND/d" dialog.in >dialog.1
	gzip -f9 dialog.1
	install -m 644 dialog.1.gz $(MANDIR)
#	install -m 644 libdialog.a /usr/lib/

depend:
	$(CPP) -M $(CFLAGS) $(SRCS) > .depend

distrib: clean
	cd .. && tar -cf - dialog-0.7 | gzip -9 > dialog-0.7.tar.gz

uninstall:
	rm -f $(BINDIR)/dialog
	rm -f $(MANDIR)/dialog.1.gz
