+
+ test "$system_malloc" != "yes" && RALLOC_OBJ=ralloc.o
+fi
+AC_SUBST(RALLOC_OBJ)
+
+if test "$opsys" = "cygwin"; then
+ CYGWIN_OBJ="sheap.o"
+ ## Cygwin differs because of its unexec().
+ PRE_ALLOC_OBJ=
+ POST_ALLOC_OBJ=lastfile.o
+else
+ CYGWIN_OBJ=
+ PRE_ALLOC_OBJ=lastfile.o
+ POST_ALLOC_OBJ=
+fi
+AC_SUBST(CYGWIN_OBJ)
+AC_SUBST(PRE_ALLOC_OBJ)
+AC_SUBST(POST_ALLOC_OBJ)
+
+# Configure gnulib here, now that we know LIBS.
+gl_ASSERT_NO_GNULIB_POSIXCHECK
+gl_ASSERT_NO_GNULIB_TESTS
+gl_INIT
+
+case "$opsys" in
+ aix4-2) LD_SWITCH_SYSTEM_TEMACS="-Wl,-bnodelcsect" ;;
+
+ darwin)
+ ## The -headerpad option tells ld (see man page) to leave room at the
+ ## end of the header for adding load commands. Needed for dumping.
+ ## 0x690 is the total size of 30 segment load commands (at 56
+ ## each); under Cocoa 31 commands are required.
+ if test "$HAVE_NS" = "yes"; then
+ libs_nsgui="-framework AppKit"
+ headerpad_extra=6C8
+ else
+ libs_nsgui=
+ headerpad_extra=690
+ fi
+ LD_SWITCH_SYSTEM_TEMACS="-fno-pie -prebind $libs_nsgui -Xlinker -headerpad -Xlinker $headerpad_extra"
+
+ ## This is here because src/Makefile.in did some extra fiddling around
+ ## with LD_SWITCH_SYSTEM. The cpp logic was:
+ ## #ifndef LD_SWITCH_SYSTEM
+ ## #if !defined (__GNUC__) && ((defined (BSD_SYSTEM) && !defined (COFF)))
+ ## Since all the *bsds define LD_SWITCH_SYSTEM, this simplifies to:
+ ## not using gcc, darwin system not on an alpha (ie darwin, since
+ ## darwin + alpha does not occur).
+ ## Because this was done in src/Makefile.in, the resulting part of
+ ## LD_SWITCH_SYSTEM was not used in configure (ie, in ac_link).
+ ## It therefore seems cleaner to put this in LD_SWITCH_SYSTEM_TEMACS,
+ ## rather than LD_SWITCH_SYSTEM.
+ test "x$LD_SWITCH_SYSTEM" = "x" && test "x$GCC" != "xyes" && \
+ LD_SWITCH_SYSTEM_TEMACS="-X $LD_SWITCH_SYSTEM_TEMACS"
+ ;;
+
+ ## LD_SWITCH_X_SITE_RPATH is a -rpath option saying where to
+ ## find X at run-time.
+ ## When handled by cpp, this was in LD_SWITCH_SYSTEM. However, at the
+ ## point where configure sourced the s/*.h file, LD_SWITCH_X_SITE_RPATH
+ ## had not yet been defined and was expanded to null. Hence LD_SWITCH_SYSTEM
+ ## had different values in configure (in ac_link) and src/Makefile.in.
+ ## It seems clearer therefore to put this piece in LD_SWITCH_SYSTEM_TEMACS.
+ gnu*) LD_SWITCH_SYSTEM_TEMACS="\$(LD_SWITCH_X_SITE_RPATH)" ;;
+
+ *) LD_SWITCH_SYSTEM_TEMACS= ;;
+esac
+
+if test "$NS_IMPL_GNUSTEP" = "yes"; then
+ LD_SWITCH_SYSTEM_TEMACS="${LD_SWITCH_SYSTEM_TEMACS} -L${GNUSTEP_SYSTEM_LIBRARIES} ${GNUSTEP_LOCAL_LIBRARIES} -lgnustep-gui -lgnustep-base -lobjc -lpthread"
+fi
+
+AC_SUBST(LD_SWITCH_SYSTEM_TEMACS)
+
+
+LD_FIRSTFLAG=
+ORDINARY_LINK=
+case "$opsys" in
+ ## gnu: GNU needs its own crt0.
+ aix4-2|cygwin|darwin|gnu|hpux*|irix6-5|sol2*|unixware) ORDINARY_LINK=yes ;;
+
+ ## On post 1.3 releases of NetBSD, gcc -nostdlib also clears the
+ ## library search parth, i.e. it won't search /usr/lib for libc and
+ ## friends. Using -nostartfiles instead avoids this problem, and
+ ## will also work on earlier NetBSD releases.
+ netbsd|openbsd) LD_FIRSTFLAG="-nostartfiles" ;;
+
+ ## macpcc: NAKAJI Hiroyuki <nakaji@tutrp.tut.ac.jp> says
+ ## MkLinux/LinuxPPC needs this.
+ ## ibms390x only supports opsys = gnu-linux so it can be added here.
+ gnu-*)
+ case "$machine" in
+ macppc|ibms390x) LD_FIRSTFLAG="-nostdlib" ;;
+ esac
+ ;;
+esac
+
+
+if test "x$ORDINARY_LINK" = "xyes"; then
+
+ LD_FIRSTFLAG=""
+ AC_DEFINE(ORDINARY_LINK, 1, [Define if the C compiler is the linker.])
+
+## The system files defining neither ORDINARY_LINK nor LD_FIRSTFLAG are:
+## freebsd, gnu-* not on macppc|ibms390x.
+elif test "x$GCC" = "xyes" && test "x$LD_FIRSTFLAG" = "x"; then
+
+ ## Versions of GCC >= 2.0 put their library, libgcc.a, in obscure
+ ## places that are difficult to figure out at make time. Fortunately,
+ ## these same versions allow you to pass arbitrary flags on to the
+ ## linker, so there is no reason not to use it as a linker.
+ ##
+ ## Well, it is not quite perfect. The "-nostdlib" keeps GCC from
+ ## searching for libraries in its internal directories, so we have to
+ ## ask GCC explicitly where to find libgcc.a (LIB_GCC below).
+ LD_FIRSTFLAG="-nostdlib"
+fi
+
+## FIXME? What setting of EDIT_LDFLAGS should this have?
+test "$NS_IMPL_GNUSTEP" = "yes" && LD_FIRSTFLAG="-rdynamic"
+
+AC_SUBST(LD_FIRSTFLAG)
+
+
+## FIXME? The logic here is not precisely the same as that above.
+## There is no check here for a pre-defined LD_FIRSTFLAG.
+## Should we only be setting LIB_GCC if LD ~ -nostdlib?
+LIB_GCC=
+if test "x$GCC" = "xyes" && test "x$ORDINARY_LINK" != "xyes"; then
+
+ case "$opsys" in
+ freebsd|netbsd|openbsd) LIB_GCC= ;;
+
+ gnu-*)
+ ## armin76@gentoo.org reported that the lgcc_s flag is necessary to
+ ## build on ARM EABI under GNU/Linux. (Bug#5518)
+ case $host_cpu in
+ arm*)
+ LIB_GCC="-lgcc_s"
+ ;;
+ *)
+ ## FIXME? s/gnu-linux.h used to define LIB_GCC as below, then
+ ## immediately undefine it again and redefine it to empty.
+ ## Was the C_SWITCH_X_SITE part really necessary?
+## LIB_GCC=`$CC $C_SWITCH_X_SITE -print-libgcc-file-name`
+ LIB_GCC=
+ ;;
+ esac
+ ;;
+
+ ## Ask GCC where to find libgcc.a.
+ *) LIB_GCC=`$CC -print-libgcc-file-name 2> /dev/null` ;;
+ esac
+fi dnl if $GCC
+AC_SUBST(LIB_GCC)
+
+
+## If we're using X11/GNUstep, define some consequences.
+if test "$HAVE_X_WINDOWS" = "yes" || test "$HAVE_NS" = "yes"; then
+ AC_DEFINE(HAVE_WINDOW_SYSTEM, 1, [Define if you have a window system.])
+ AC_DEFINE(HAVE_MOUSE, 1, [Define if you have mouse support.])