From 83fe9fdeb3aeba897bb266ee96cd4b9e3fa2577d Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Nov 22 2010 13:55:06 +0000 Subject: fix building and installing on Mac OS X (#652479) Patch by Tilghman Lesher. --- diff --git a/Makefile.in b/Makefile.in index f15de20..e764e61 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,12 +1,13 @@ -LIBS = -lslang -LIBTCL = -ltcl8.4 +LIBS = -lslang @LIBS@ +LIBTCL = @TCL_LIB_FLAG@ CC = @CC@ CPP = @CPP@ CFLAGS = @CFLAGS@ +LDFLAGS = @LDFLAGS@ CPPFLAGS = -D_GNU_SOURCE -I/usr/include/slang @CPPFLAGS@ +GNU_LD = @GNU_LD@ -SHLIBFLAGS= -Wl,--version-script,newt.0.52.ver VERSION = @VERSION@ TAG = r$(subst .,-,$(VERSION)) SONAME = @SONAME@ @@ -25,6 +26,12 @@ 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 +ifneq ($(GNU_LD),) +SHLIBFLAGS= -Wl,--version-script,newt.0.52.ver -Wl,-soname,$(LIBNEWTSONAME) +else +SHLIBFLAGS= +endif + SHCFLAGS = -fPIC prefix = @prefix@ @@ -33,6 +40,7 @@ exec_prefix = @exec_prefix@ libdir = @libdir@ bindir = @bindir@ datadir = @datadir@ +datarootdir = @datarootdir@ mandir = @mandir@ man1dir = $(mandir)/man1 pkgconfigdir = $(libdir)/pkgconfig @@ -54,33 +62,37 @@ endif all: $(TARGET) _snackmodule.so test: test.o $(LIBNEWT) - $(CC) -g -o test test.o $(LIBNEWT) $(LIBS) + $(CC) -g -o test test.o $(LIBNEWT) $(LDFLAGS) $(LIBS) testgrid: testgrid.o $(LIBNEWT) - $(CC) -g -o testgrid testgrid.o $(LIBNEWT) $(LIBS) + $(CC) -g -o testgrid testgrid.o $(LIBNEWT) $(LDFLAGS) $(LIBS) testtree: testtree.o $(LIBNEWT) - $(CC) -g -o testtree testtree.o $(LIBNEWT) $(LIBS) + $(CC) -g -o testtree testtree.o $(LIBNEWT) $(LDFLAGS) $(LIBS) showchars: showchars.o $(LIBNEWT) - $(CC) -g -o showchars showchars.o $(LIBNEWT) $(LIBS) + $(CC) -g -o showchars showchars.o $(LIBNEWT) $(LDFLAGS) $(LIBS) showkey: showkey.o $(LIBNEWT) - $(CC) -g -o showkey showkey.o $(LIBNEWT) $(LIBS) + $(CC) -g -o showkey showkey.o $(LIBNEWT) $(LDFLAGS) $(LIBS) _snackmodule.so: snackmodule.c $(LIBNEWTSH) for ver in $(PYTHONVERS) ; do \ mkdir -p $$ver ;\ - $(CC) $(CFLAGS) -I/usr/include/$$ver $(SHCFLAGS) -c -o $$ver/snackmodule.o snackmodule.c ;\ - $(CC) --shared $(SHCFLAGS) -o $$ver/_snackmodule.so $$ver/snackmodule.o -L . -lnewt ;\ + PCFLAGS=`$$ver-config --cflags`; \ + PIFLAGS=`$$ver-config --includes`; \ + PLDFLAGS=`$$ver-config --ldflags`; \ + PLFLAGS=`$$ver-config --libs`; \ + $(CC) $(CPPFLAGS) $$PIFLAGS $$PCFLAGS -c -o $$ver/snackmodule.o snackmodule.c ;\ + $(CC) --shared $$PLDFLAGS $$PLFLAGS $(LDFLAGS) -o $$ver/_snackmodule.so $$ver/snackmodule.o -L. -lnewt $(LIBS);\ done touch $@ whiptail: $(NDIALOGOBJS) $(LIBNEWTSH) - $(CC) -g -o whiptail $(NDIALOGOBJS) -L . -lnewt $(LIBS) -lpopt + $(CC) -g -o whiptail $(NDIALOGOBJS) -L. $(LDFLAGS) -lnewt $(LIBS) -lpopt whiptcl.so: $(WHIPTCLOBJS) $(LIBNEWTSH) - $(CC) -shared $(SHCFLAGS) -o whiptcl.so $(WHIPTCLOBJS) -L . -lnewt $(LIBTCL) -lpopt + $(CC) -shared $(SHCFLAGS) $(LDFLAGS) -o whiptcl.so $(WHIPTCLOBJS) -L. -lnewt $(LIBTCL) -lpopt $(LIBS) $(LIBNEWT): $(LIBOBJS) ar rv $@ $^ @@ -103,7 +115,7 @@ $(SHAREDDIR): sharedlib: $(LIBNEWTSH) $(LIBNEWTSH): $(SHAREDDIR) $(SHAREDOBJS) - $(CC) -shared -o $(LIBNEWTSH) $(SHLIBFLAGS) -Wl,-soname,$(LIBNEWTSONAME) $(SHAREDOBJS) $(LIBS) + $(CC) -shared -o $(LIBNEWTSH) $(SHLIBFLAGS) $(SHAREDOBJS) $(LDFLAGS) $(LIBS) ln -fs $(LIBNEWTSONAME) libnewt.so ln -fs $(LIBNEWTSH) $(LIBNEWTSONAME) diff --git a/configure.ac b/configure.ac index a09bf6d..7bc381a 100644 --- a/configure.ac +++ b/configure.ac @@ -13,9 +13,45 @@ AC_SUBST([SONAME]) AC_PROG_CC AC_PROG_INSTALL AC_PROG_LN_S +AC_PROG_GREP + +# Are we using GNU ld? +AC_MSG_CHECKING([for GNU ld]) +LD=`$CC -print-prog-name=ld 2>&5` + +if test `$LD -v 2>&1 | $ac_cv_path_GREP -c "GNU ld"` = 0; then + # Not + GNU_LD="" + AC_MSG_RESULT([no]) +else + GNU_LD="$LD" + AC_MSG_RESULT([yes]) + AC_SUBST([GNU_LD]) +fi AC_CHECK_HEADERS([sys/select.h alloca.h]) -AC_CHECK_HEADERS([slang.h]) +AC_CHECK_HEADER([slang.h], [], [ + old_CPPFLAGS=${CPPFLAGS} + CPPFLAGS="${CPPFLAGS} -I/opt/local/include" + unset ac_cv_header_slang_h + AC_CHECK_HEADER([slang.h]) + if test x$ac_cv_header_slang_h = x; then + CPPFLAGS="${old_CPPFLAGS}" + else + LDFLAGS="${LDFLAGS} -L/opt/local/lib" + fi +]) +if test x$ac_cv_header_slang_h = x; then + old_CPPFLAGS=${CPPFLAGS} + CPPFLAGS="${CPPFLAGS} -I/sw/include" + AC_CHECK_HEADER([slang.h]) + if test x$ac_cv_header_slang_h = x; then + CPPFLAGS=${old_CPPFLAGS} + else + LDFLAGS="${LDFLAGS} -L/sw/lib" + fi +fi +AC_CHECK_HEADERS([popt.h libintl.h]) AC_MSG_CHECKING([for python versions]) PYTHONVERS=$(echo /usr/include/python*/Python.h | sed "s|/usr/include/||g"| sed "s|/Python.h||g" 2> /dev/null) @@ -26,7 +62,37 @@ AC_ARG_WITH([tcl], [ --without-tcl do not compile whiptcl.so]) if test "x$with_tcl" = "xno"; then WHIPTCLSO= else - AC_CHECK_HEADER([tcl.h], [WHIPTCLSO=whiptcl.so], [WHIPTCLSO=]) + AC_MSG_CHECKING([for tcl configuration]) + + # check in a few common install locations + if test x"${ac_cv_c_tclconfig}" = x ; then + for i in `ls -d ${libdir} 2>/dev/null` \ + `ls -d /usr/lib 2>/dev/null` \ + `ls -d /usr/lib64 2>/dev/null` \ + `ls -d /usr/local/lib 2>/dev/null` \ + `ls -d /usr/contrib/lib 2>/dev/null` \ + `ls -d /usr/pkg/lib 2>/dev/null` \ + `ls -d /usr/local/lib/tcl8.5 2>/dev/null` \ + `ls -d /usr/local/lib/tcl8.4 2>/dev/null` \ + `ls -d /usr/lib/tcl8.5 2>/dev/null` \ + `ls -d /usr/lib/tcl8.4 2>/dev/null` \ + `ls -d /opt/local/lib 2>/dev/null` \ + ; do + if test -f "$i/tclConfig.sh" ; then + ac_cv_c_tclconfig=`(cd $i; pwd)` + break + fi + done + fi + + if test x"${ac_cv_c_tclconfig}" != x ; then + AC_MSG_RESULT([found]) + . ${ac_cv_c_tclconfig}/tclConfig.sh + AC_SUBST([TCL_LIB_FLAG]) + WHIPTCLSO=whiptcl.so + else + AC_MSG_RESULT([NOT found]) + fi fi AC_SUBST([WHIPTCLSO]) @@ -39,7 +105,20 @@ fi AC_ARG_ENABLE([nls], [ --disable-nls compile without NLS support]) if test "x$enable_nls" != "xno"; then - AC_DEFINE([ENABLE_NLS], 1, [Define to 1 if NLS support is enabled]) + AC_CHECK_LIB([c], [gettext], [ ], [ + AC_CHECK_LIB([intl], [gettext], [ + LIBS="-lintl" + AC_SUBST([LIBS])], [ + if test "x$enable_nls" != "xcheck"; then + AC_MSG_FAILURE([--enable-nls was specified, but the configure check failed]) + else + enable_nls=no + fi + ]) + ]) + if test "x$enable_nls" != "xno"; then + AC_DEFINE([ENABLE_NLS], 1, [Define to 1 if NLS support is enabled]) + fi fi AC_CONFIG_FILES([Makefile libnewt.pc]) diff --git a/whiptail.c b/whiptail.c index 09eca15..a0da6e1 100644 --- a/whiptail.c +++ b/whiptail.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "nls.h" #include "dialogboxes.h"