RE: Creating a project from scratch



Shane, all:

On Tue, 2003-01-21 at 06:59, Clancy, Shane W. wrote:
neil,
it would be easier to address this problem if we could see your makefile.

thanks,
shane


Here are the three primary independent files needed for a build (as far
as I know), plus the Makefile.am for the src directory.  Let me know
what you think.  Thanks.

Neil

###########################################################################
autogen.sh
###########################################################################
#!/bin/sh
# Run this to generate all the initial makefiles, etc.

srcdir=`dirname $0`
test -z "$srcdir" && srcdir=.

ORIGDIR=`pwd`
cd $srcdir
PROJECT=gnoii2
TEST_TYPE=-d
FILE=src

DIE=0

(autoconf --version) < /dev/null > /dev/null 2>&1 || {
        echo
        echo "You must have autoconf installed to compile $PROJECT."
        echo "libtool the appropriate package for your distribution,"
        echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/";
        DIE=1
}

have_automake=false
if automake-1.4 --version < /dev/null > /dev/null 2>&1 ; then
        automake_version=`automake-1.4 --version | grep 'automake (GNU
automake)' | sed 's/^[^0-9]*\(.*\)/\1/'`
        case $automake_version in
                1.2*|1.3*|1.4) 
                        ;;
                *)
                have_automake=true
                        ;;
        esac
fi

if $have_automake ; then : ; else
        echo
        echo "You must have automake 1.4-p1 installed to compile $PROJECT."
        echo "Get ftp://ftp.gnu.org/pub/gnu/automake/automake-1.4-p1.tar.gz";
        echo "(or a newer version if it is available)"
        DIE=1
fi

have_gettext=false
if xgettext --version 2>/dev/null | grep 'GNU' > /dev/null ; then 
        have_gettext=true
fi

if $have_gettext ; then : ; else
        echo
        echo "GNU gettext must be installed to build GLib from CVS"
        echo "GNU gettext is available from
http://www.gnu.org/software/gettext/";
        DIE=1
fi

if test "$DIE" -eq 1; then
        exit 1
fi

test $TEST_TYPE $FILE || {
        echo "You must run this script in the top-level $PROJECT directory"
        exit 1
}

if test -z "$AUTOGEN_SUBDIR_MODE"; then
        if test -z "$*"; then
                echo "I am going to run ./configure with no arguments - if you wish "
                echo "to pass any to it, please specify them on the $0 command line."
        fi
fi

case $CC in
        *xlc | *xlc\ * | *lcc | *lcc\ *) am_opt=--include-deps;;
esac

gettextize -f -c --intl

aclocal-1.4 $ACLOCAL_FLAGS

# optionally feature autoheader
(autoheader --version)  < /dev/null > /dev/null 2>&1 && autoheader

automake-1.4 -a -c $am_opt
autoconf
cd $ORIGDIR

if test -z "$AUTOGEN_SUBDIR_MODE"; then
        CFLAGS="-Wall -ansi -D_GNU_SOURCE -O -g" $srcdir/configure
--enable-maintainer-mode "$@"
        echo 
        echo "Now type 'make' to compile $PROJECT."
fi

###########################################################################
configure.in
###########################################################################
dnl Process this file with autoconf to produce a configure script.

AC_INIT(src/main.c)

AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(gnoii2,0.2)

AC_ARG_ENABLE(gtk20, 
        [  --disable-gtk20          Don't look for GTK+ 2.0 libraries], 
        enable_gtk20=$enableval, 
        enable_gtk20="yes")

AC_ARG_ENABLE(gtkport, 
        [  --disable-gtkport        Disable compiling the GTK+ port], 
        enable_gtkport=$enableval, 
        enable_gtkport="yes")

AC_ARG_ENABLE(textport, 
        [  --disable-textport       Disable compiling the text port], 
        enable_textport=$enableval, 
        enable_textport="yes")

AC_SUBST(PACKAGE)
AC_SUBST(VERSION)
AC_SUBST(PREFIX)

ALL_LINGUAS="es"

AC_DEFINE(_GNU_SOURCE, 1, [Define for setting a GNU environment])

AC_CANONICAL_HOST
AC_PROG_CC
AC_AIX
AC_MINIX
AC_EXEEXT
AC_PROG_RANLIB
AC_SYS_LARGEFILE
dnl AC_ISC_POSIX
AM_C_PROTOTYPES
AC_C_CONST
AC_C_INLINE

AM_MAINTAINER_MODE

AC_PROG_AWK
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET

AC_HEADER_DIRENT
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(fcntl.h limits.h malloc.h strings.h sys/ioctl.h
sys/time.h unistd.h)

AC_TYPE_MODE_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_STRUCT_TM

AC_FUNC_ALLOCA
AC_PROG_GCC_TRADITIONAL
AC_FUNC_MMAP
AC_TYPE_SIGNAL
AC_FUNC_STRFTIME
AC_FUNC_UTIME_NULL
AC_CHECK_FUNCS(gai_strerror getaddrinfo getcwd gettimeofday getwd mkdir
mktime putenv rmdir select socket strdup strstr strtod strtol uname
grantpt)

if test "x$enable_gtk20" = "xyes" ; then
        PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.0.0, found_glib20=1,
found_glib20=0)
else
        found_glib20=0;
fi

if test "x$GFTP_TEXT" = "x" -a $found_glib20 = 0 ; then
        AM_PATH_GLIB(1.2.3, , AC_MSG_ERROR(gFTP needs GLIB 1.2.3 or higher))
fi

AC_CHECK_LIB(socket, socket, EXTRA_LIBS="-lsocket")

AC_CHECK_LIB(nsl, gethostbyname, EXTRA_LIBS="$EXTRA_LIBS -lnsl")

GFTP_TEXT=""
EXTRA_LIBS=""
USE_READLINE="yes"
READLINE_LIBS=""
if test "x$enable_textport" = "xyes" ; then
        AC_MSG_CHECKING([whether to use readline])
        AC_ARG_WITH(readline,
        [  --with-readline         turn on readline [default=yes, default tries
-lncurses, -lcurses, -ltermcap]],
                [case "${withval}" in
                        yes) USE_READLINE="yes" ; AC_MSG_RESULT([yes]) ;;
                        no) USE_READLINE="no" ; AC_MSG_RESULT([no]) ;;
                        only) USE_READLINE="yes"
                                EXTRA_LIBREADLINE_DEPS=" "
                                AC_MSG_RESULT([yes (using only readline)]) ;;
                        *) USE_READLINE="yes"
                                EXTRA_LIBREADLINE_DEPS="${withval}"
                                AC_MSG_RESULT([yes (using extra libraries ${withval})]) ;;
                esac],[AC_MSG_RESULT([${USE_READLINE}])])

        dnl Checks for libraries.
        dnl When checking readline, check using extra libraries first.
        dnl We want to protect against the link somehow succeeding, but only
        dnl failing at runtime, as seems to happen on some BSD systems.
        if test "$USE_READLINE" = yes ; then
                if test "$EXTRA_LIBREADLINE_DEPS" = "" ; then
                        unset ac_cv_lib_readline_readline
                        AC_CHECK_LIB(readline, readline, HAVE_LIBREADLINE=true,
                                HAVE_LIBREADLINE=false, -lncurses)
                        if test x${HAVE_LIBREADLINE} = xtrue ; then
                                echo "  Using -lreadline -lncurses"
                                EXTRA_LIBREADLINE_DEPS=-lncurses
                                AC_DEFINE(HAVE_LIBREADLINE, [1], [Define if the text port uses
readline])
                        else
                                unset ac_cv_lib_readline_readline
                                AC_CHECK_LIB(readline, readline, HAVE_LIBREADLINE=true,
                                        HAVE_LIBREADLINE=false, -lcurses)
                                if test x${HAVE_LIBREADLINE} = xtrue ; then
                                        echo "  Using -lreadline -lcurses"
                                        EXTRA_LIBREADLINE_DEPS=-lcurses
                                        AC_DEFINE(HAVE_LIBREADLINE, [1], [Define if the text port uses
readline])
                                else
                                        unset ac_cv_lib_readline_readline
                                        AC_CHECK_LIB(readline, readline, HAVE_LIBREADLINE=true,
                                        HAVE_LIBREADLINE=false, -ltermcap)
                                        if test x${HAVE_LIBREADLINE} = xtrue ; then
                                                echo "  Using -lreadline -ltermcap"
                                                EXTRA_LIBREADLINE_DEPS=-ltermcap
                                                AC_DEFINE(HAVE_LIBREADLINE, [1], [Define if the text port uses
readline])
                                        else
                                                unset ac_cv_lib_readline_readline
                                                AC_CHECK_LIB(readline, readline, HAVE_LIBREADLINE=true,
                                                HAVE_LIBREADLINE=false)
                                                if test x${HAVE_LIBREADLINE} = xtrue ; then
                                                        AC_DEFINE(HAVE_LIBREADLINE, [1], [Define if the text 
port uses
readline])
                                                else
                                                        AC_DEFINE(HAVE_LIBREADLINE, [0], [Define if the text 
port uses
readline])
                                                fi
                                        fi
                                fi
                        fi
                else
                        unset ac_cv_lib_readline_readline
                        AC_CHECK_LIB(readline, readline, HAVE_LIBREADLINE=true,
                                HAVE_LIBREADLINE=false, ${EXTRA_LIBREADLINE_DEPS})
                        if test x${HAVE_LIBREADLINE} = xtrue ; then
                                echo "  Using -lreadline ${EXTRA_LIBREADLINE_DEPS}"
                                AC_DEFINE(HAVE_LIBREADLINE, [1], [Define if the text port uses
readline])
                        else
                                AC_DEFINE(HAVE_LIBREADLINE, [0], [Define if the text port uses
readline])
                        fi
                fi
        else
                HAVE_LIBREADLINE=false
                AC_DEFINE(HAVE_LIBREADLINE, [0], [Define if the text port uses
readline])
        fi
        if test x${HAVE_LIBREADLINE} = xtrue; then
                READLINE_LIBS="-lreadline ${EXTRA_LIBREADLINE_DEPS}"
                GFTP_TEXT="gftp-text"
        fi
fi

AC_CHECK_LIB(m, log10, EXTRA_LIBS="$EXTRA_LIBS -lm")

AM_WITH_DMALLOC

AC_SUBST(EXTRA_LIBS)
AC_SUBST(READLINE_LIBS)
AC_SUBST(GFTP_TEXT)

GFTP_GTK=""
PTHREAD_CFLAGS=""
PTHREAD_LIBS=""

# I don't have PKG_CHECK_MODULES or AM_PATH_GLIB check for gthread
because
# the text port doesn't need to be compiled against the thread libraries
GTHREAD_LIBS=""

if test "x$enable_gtkport" = "xyes" ; then
        if test $found_glib20 = 1 -a "x$enable_gtk20" = "xyes" ; then
                PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.0.0, GFTP_GTK=gftp-gtk,
AC_MSG_ERROR(You have GLIB 2.0 installed but I cannot find GTK+ 2.0. Run
configure with --disable-gtk20 or install GTK+ 2.0))
        fi

        if test "x$GFTP_GTK" = "x" ; then
                AM_PATH_GTK(1.2.3, GFTP_GTK=gftp-gtk, AC_MSG_WARN(gFTP needs GTK+
1.2.3 or higher for the graphical version. Only building the text
version))
                GTHREAD_LIBS="-lgthread"
        else
                GTHREAD_LIBS="-lgthread-2.0"
        fi

        if test "x$GFTP_GTK" = xgftp-gtk; then
                AC_CHECK_LIB(pthread, pthread_create, PTHREAD_LIBS="-lpthread")

                if test "x$PTHREAD_LIBS" = x ; then
                        AC_CHECK_LIB(pthreads, pthread_create, PTHREAD_LIBS="-lpthreads")
                fi

                if test "x$PTHREAD_LIBS" = x ; then
                        AC_CHECK_LIB(c_r, pthread_create, PTHREAD_LIBS="-lc_r")
                fi

                if test "x$PTHREAD_LIBS" = x ; then
                        echo ;
                        echo "Error: Cannot find the pthread libraries. If you don't have
them installed," ; 
                        echo "your X libraries probably aren't thread safe either. You can
download the" ; 
                        echo "pthread library and the thread safe X libraries from my webpage
at" ;
                        echo "http://www.gftp.org/. Note the pthread library and the thread
safe" ;
                        echo "X libraries on my webpage are for Linux libc5 machines ONLY" ;
                        echo ;
                exit
        fi

        PTHREAD_CFLAGS="-D_REENTRANT"

        # I took some of these from the glib 1.3.3 configure.in
        case $host in
                *-hpux*)
                        # From H.Merijn Brand <h m brand hccnet nl>
                        echo '#define pthread_attr_init(x) __pthread_attr_init_system(x)'
                        +>>confdefs.h
                ;;
                *-aix*)
                        PTHREAD_CFLAGS="$PTHREAD_CFLAGS -D_THREAD_SAFE"
                        if test x"$GCC" = xyes; then
                                PTHREAD_CFLAGS="$PTHREAD_CFLAGS -mthreads"
                        fi
                ;;
                *-freebsd*)
                        PTHREAD_CFLAGS="$PTHREAD_CFLAGS -D_THREAD_SAFE"

                        # FreeBSD 2.2.x shiped with gcc 2.7.2.x, which doesn't support
                        # -mthreads flag.
                ;;
                *-openbsd*)
                        PTHREAD_CFLAGS="$PTHREAD_CFLAGS -D_THREAD_SAFE"
                        if test "x$PTHREAD_LIBS" = "x-lc_r"; then
                                PTHREAD_LIBS="-pthread"
                        fi
                ;;
                *-sysv5uw7*)  # UnixWare 7
                        if test "$GCC" != "yes"; then
                                PTHREAD_CFLAGS="$PTHREAD_CFLAGS -Kthread"
                        else
                                PTHREAD_CFLAGS="$PTHREAD_CFLAGS -pthread"
                        fi
                        ;;
                        *-dg-dgux*)  # DG/UX
                        PTHREAD_CFLAGS="$PTHREAD_CFLAGS -D_POSIX4A_DRAFT10_SOURCE"
                esac
        fi
fi

AC_SUBST(PTHREAD_CFLAGS)
AC_SUBST(PTHREAD_LIBS)
AC_SUBST(GTHREAD_LIBS)
AC_SUBST(GFTP_GTK)

AM_GNU_GETTEXT

AC_OUTPUT([
Makefile
docs/Makefile
intl/Makefile
po/Makefile.in
src/Makefile
gnoii2.spec
])

###########################################################################
Makefile.am
###########################################################################
SUBDIRS = intl docs po src

ACLOCAL_AMFLAGS = -I m4

## We dist autogen.sh since this is an example program
## Real-world programs do not need to distribute autogen.sh
EXTRA_DIST = config.rpath mkinstalldirs autogen.sh

###########################################################################
src/Makefile.am
###########################################################################
INCLUDES = \
        -I$(top_srcdir) \
        -I$(includedir) \
        $(GNOME_INCLUDEDIR) \
        -DG_LOG_DOMAIN=\"gnoii2\" \
        -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
        -I../intl \
        -I$(top_srcdir)/intl

bin_PROGRAMS = gnoii2

gnoii2_SOURCES = \
        main.c \
        gnoii.h

#gnoii2_LDADD = $(GNOMEUI_LIBS) $(GNOME_LIBDIR) $(INTLLIBS)
gnoii2_LDADD = $(INTLLIBS)





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]