# Generated automatically from Makefile.in by configure.
LIBS = -lslang -lm -lpopt -lncurses #-lefence
SHLIBS = -lslang -lm -lc -lpopt -lncurses

GPM_SUPPORT=@gpm_support@

CFLAGS += -I/usr/include -I${LOCALBASE}/include -I${PREFIX}/include
LDFLAGS += -L/usr/lib -L${LOCALBASE}/lib -L${PREFIX}/lib

VERSION = 0.51.0
CVSTAG = r$(subst .,-,$(VERSION))
SONAME = 51

#PYTHONVERS = $(shell ls -d /usr/include/python* | sed "s|/usr/include/||g")

.if defined(WITH_TCL)
WHIPTCLSO=whiptcl.so
CFLAGS += -I${LOCALBASE}/include/${TCLVERSION}
LDFLAGS += -L${LOCALBASE}/lib/${TCLVERSION}
SHLIBS += -l${TCLVERSION:S,.,,}
.endif
TARGET=${LIBNEWT} ${PROGS} ${WHIPTCLSO}

PROGS = test whiptail testgrid testtree
TESTOBJS = test.o
NDIALOGOBJS = whiptail.o dialogboxes.o
WHIPTCLOBJS = whiptcl.o dialogboxes.o
LIBNEWT = libnewt.a
LIBNEWTSH = libnewt.so.$(SONAME)
LIBNEWTSONAME = libnewt.so.$(SONAME)
LIBOBJS = newt.o button.o form.o checkbox.o entry.o label.o listbox.o \
          scrollbar.o textbox.o scale.o grid.o windows.o buttonbar.o \
	  checkboxtree.o

LIBSHOBJS = newt.So button.So form.So checkbox.So entry.So label.So listbox.So \
          scrollbar.So textbox.So scale.So grid.So windows.So buttonbar.So \
	  checkboxtree.So

SHCFLAGS = ${CFLAGS} -fPIC

prefix = ${PREFIX}
includedir = $(prefix)/include
libdir = $(prefix)/lib
bindir = $(prefix)/bin
ARCHNAME = $(shell uname -m | sed 's/i.86/i386/')

#--------------------------------------

SOURCES = $(subst .o,.c,$(TESTOBJS) $(NDIALOGOBJS) $(LIBOBJS)) $(subst .So,.c,$(LIBSHOBJS))

.SUFFIXES: .o .So

SHAREDOBJS = ${LIBSHOBJS}

all:	$(TARGET)

test:	$(TESTOBJS) $(LIBNEWT)
	${CC} -g ${LDFLAGS} -o test $(TESTOBJS) $(LIBNEWT) $(LIBS) -static

testgrid:	testgrid.o $(LIBNEWT)
	${CC} -g ${LDFLAGS} -o testgrid testgrid.o $(LIBNEWT) $(LIBS)

testtree:	testtree.o $(LIBNEWT)
	${CC} -g ${LDFLAGS} -o testtree testtree.o $(LIBNEWT) $(LIBS)

_snackmodule.so:   snackmodule.c $(LIBNEWTSH)
	for ver in $(PYTHONVERS) ; do \
	    if [ ! -f "$$ver/_snackmodule.so" -o $(LIBNEWTSH) -nt "$$ver/_snackmodule.so" ]; then \
	    	mkdir -p $$ver ;\
	        ${CC} $(CFLAGS) -I/usr/include/$$ver -fPIC -c -o $$ver/snackmodule.o snackmodule.c ;\
		${CC} --shared $(SHCFLAGS) -o $$ver/_snackmodule.so $$ver/snackmodule.o -L . $(LIBNEWTSH) ;\
	    fi ; \
	done

whiptail: $(NDIALOGOBJS) $(LIBNEWTSH)
	${CC} -g ${LDFLAGS} -o whiptail $(NDIALOGOBJS) -L . $(LIBNEWTSH) $(LIBS) -lpopt

whiptcl.so: $(WHIPTCLOBJS) $(LIBNEWTSH)
	${CC} -shared ${LDFLAGS} $(SHCFLAGS) -o whiptcl.so $(WHIPTCLOBJS) -L . $(LIBNEWTSH) ${LIBS}

$(LIBNEWT): $(LIBOBJS)
	ar q ${LIBNEWT} ${LIBOBJS}
	ranlib ${LIBNEWT}

newt.o: newt.c Makefile
	$(CC) $(CFLAGS) -DVERSION=\"$(VERSION)\" -c -o $@ $<

veryclean: clean
	rm -f .depend

clean:
	rm -f $(PROGS) *.o $(LIBNEWT) core $(LIBNEWTSH)  \
		$(SHAREDOBJS) *.so*

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

sharedlib: $(LIBNEWTSH)

$(LIBNEWTSH): $(SHAREDOBJS)
	${CC} -shared ${LDFLAGS} -o $(LIBNEWTSH) -Wl,-soname,$(LIBNEWTSONAME) $(SHAREDOBJS) $(SHLIBS)

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

newt.So: newt.c Makefile
	$(CC) $(SHCFLAGS) -DVERSION=\"$(VERSION)\" -c -o $@ $<

install: $(LIBNEWT) install-sh whiptail
	[ -d $(instroot)/$(bindir) ] || install -m 755 -d $(instroot)/$(bindir)
	[ -d $(instroot)/$(libdir) ] || install -m 755 -d $(instroot)/$(libdir)
	[ -d $(instroot)/$(includedir) ] || install -m 755 -d $(instroot)/$(includedir)
	install -m 644 newt.h $(instroot)/$(includedir)
	install -m 644 $(LIBNEWT) $(instroot)/$(libdir)
	install -s -m 755 whiptail $(instroot)/$(bindir)

install-sh: sharedlib $(WHIPTCLSO)
	[ -d $(instroot)/$(libdir) ] || install -m 755 -d $(instroot)/$(libdir)
	install -s -m 755 $(LIBNEWTSH) $(instroot)/$(libdir)
	ln -sf $(LIBNEWTSH) $(instroot)/$(libdir)/libnewt.so
	[ -n "$(WHIPTCLSO)" ] && install -s -m 755 whiptcl.so $(instroot)/$(libdir) || :

configure:  configure.in
	autoconf
	echo "You need to rerun ./configure before continuing"
	exit 1

archive:    configure
	@cvs tag -F $(CVSTAG)
	@rm -rf /tmp/newt-$(VERSION) /tmp/newt
	@cd /tmp; cvs export -r$(CVSTAG) newt; mv newt newt-$(VERSION)
	@cd /tmp/newt-$(VERSION); autoconf
	@cd /tmp; tar czSpf newt-$(VERSION).tar.gz newt-$(VERSION)
	@rm -rf /tmp/newt-$(VERSION)
	@cp /tmp/newt-$(VERSION).tar.gz .
	@rm -f /tmp/newt-$(VERSION).tar.gz
	@echo " "
	@echo "The final archive is ./newt-$(VERSION).tar.gz."


syntax highlighted by Code2HTML, v. 0.9.1