# 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

# 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

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.6z\"
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

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

all: libdialog.a dialog

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

dialog: dialog.o

clean:
	rm -f core *.o *~ dialog .depend libdialog.a dialog.1 dialog.in
	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_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
	install -m 644 dialog.1 $(MANDIR)
#	install -m 644 libdialog.a /usr/lib/

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

