Support for linking with different types of a library.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/tools/make/trunk@2477 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Ovidiu Predescu 1997-10-03 21:12:56 +00:00
parent 23588b47e8
commit b152a7a0c7
15 changed files with 867 additions and 67 deletions

View file

@ -1,3 +1,29 @@
Fri Oct 3 13:43:18 1997 Ovidiu Predescu <ovidiu@net-community.com>
* Added support for linking with different types of a library,
depending on the flags you specify at the make time.
* which_lib.c: New file.
* config.h.in: New file.
* Makefile.in: Added rule to build and install the which_lib program.
* common.make: Added definition for WHICH_LIB_SCRIPT.
* rules.make: Added rules to process the libraries list and obtain a
new one based upon the debug, profile and shared variables.
* configure.in: Added checks for various header files needed to compile
the which_lib program.
* library.make: Added new variable LIBRARY_FILE_EXT.
* application.make: Replaced foreach with :.something=.someotherthing.
* bundle.make: Likewise.
* test.make: Likewise.
* tool.make: Likewise.
* config.make.in: Changed the hard-coded definition of ld to be $(CC).
Added definitions for INSTALL programs.
* configure.in: Added check for the INSTALL program.
* library.make: New target internal-distclean.
* rules.make: internal-distclean does not make first the clean target.
* target.make: Shared libraries under OS 4.x have the .so extension.
Thu Oct 2 14:56:08 1997 Scott Christley <scottc@stetson.net-community.com>
* ld_lib_path.sh: New file.
@ -15,6 +41,11 @@ Thu Oct 2 14:56:08 1997 Scott Christley <scottc@stetson.net-community.com>
* rules.make: Add test building and check rules.
* Makefile.in: Install test.make.
Thu Oct 2 10:21:41 1997 Ovidiu Predescu <ovidiu@net-community.com>
* common.make.in: Remove the default library combo for OPENSTEP 4.x.
* configure.in: Add a default library combo for OS 4.x here.
Wed Oct 1 18:04:25 1997 Ovidiu Predescu <ovidiu@net-community.com>
* configure.in: Added the --with-library-combo to support specifying a

View file

@ -46,13 +46,10 @@ GNUSTEP_TARGET_OS := $(shell ./clean_os.sh $(GNUSTEP_TARGET_OS))
makedir = $(prefix)/Makefiles
GNUSTEP_TARGET_DIR = $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)
INSTALL = ./install-sh -c
INSTALL_DATA = $(INSTALL) -m 644
INSTALL_PROGRAM = $(INSTALL)
all: which_lib
all:
@echo Nothing needs to be made, just install with
@echo make install
which_lib: which_lib.c
$(CC) -O2 -Wall -o $@ $^
install:
$(srcdir)/mkinstalldirs $(prefix) $(makedir) \
@ -68,6 +65,7 @@ install:
$(INSTALL_DATA) $$f $(makedir); \
done
$(INSTALL_DATA) config.site $(prefix)/share
$(INSTALL_PROGRAM) which_lib $(makedir)/$(GNUSTEP_TARGET_DIR)
$(INSTALL_DATA) config.make $(makedir)/$(GNUSTEP_TARGET_DIR)
uninstall:

View file

@ -28,7 +28,7 @@ include $(GNUSTEP_SYSTEM_ROOT)/Makefiles/rules.make
# The name of the application is in the APP_NAME variable.
#
APP_DIR_NAME := $(foreach app,$(APP_NAME),$(app).app)
APP_DIR_NAME := $(APP_NAME:=.app)
APP_FILE = $(APP_DIR_NAME)/$(GNUSTEP_TARGET_DIR)/$(LIBRARY_COMBO)/$(APP_NAME)$(EXEEXT)
APP_STAMPS := $(foreach app,$(APP_NAME),stamp-app-$(app))
APP_STAMPS := $(addprefix $(GNUSTEP_OBJ_DIR)/,$(APP_STAMPS))

View file

@ -30,7 +30,7 @@ include $(GNUSTEP_SYSTEM_ROOT)/Makefiles/rules.make
# where xxx is the bundle name
#
BUNDLE_DIR_NAME := $(foreach bundle,$(BUNDLE_NAME),$(bundle)$(BUNDLE_EXTENSION))
BUNDLE_DIR_NAME := $(BUNDLE_NAME:=.$(BUNDLE_EXTENSION))
BUNDLE_FILE := $(BUNDLE_DIR_NAME)/$(GNUSTEP_TARGET_DIR)/$(LIBRARY_COMBO)/$(BUNDLE_NAME)
BUNDLE_STAMPS := $(foreach bundle,$(BUNDLE_NAME),stamp-bundle-$(bundle))
BUNDLE_STAMPS := $(addprefix $(GNUSTEP_OBJ_DIR)/,$(BUNDLE_STAMPS))

View file

@ -35,7 +35,7 @@ CONFIG_OS_SCRIPT = $(GNUSTEP_SYSTEM_ROOT)/Makefiles/os.sh
CLEAN_CPU_SCRIPT = $(GNUSTEP_SYSTEM_ROOT)/Makefiles/clean_cpu.sh
CLEAN_VENDOR_SCRIPT = $(GNUSTEP_SYSTEM_ROOT)/Makefiles/clean_vendor.sh
CLEAN_OS_SCRIPT = $(GNUSTEP_SYSTEM_ROOT)/Makefiles/clean_os.sh
WHICH_LIB_SCRIPT = $(GNUSTEP_SYSTEM_ROOT)/Makefiles/which_lib
LD_LIB_PATH_SCRIPT = $(GNUSTEP_SYSTEM_ROOT)/Makefiles/ld_lib_path.sh
#

32
config.h.in Normal file
View file

@ -0,0 +1,32 @@
#ifndef __config_h__
#define __config_h__
/* Define if you have the <sys/param.h> header file */
#undef HAVE_SYS_PARAM_H
/* Define if you have the <sys/file.h> header file */
#undef HAVE_SYS_FILE_H
/* Define if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define if you have the <sys/stat.h> header file */
#undef HAVE_SYS_STAT_H
/* Define if you have the <sys/errno.h> header file */
#undef HAVE_SYS_ERRNO_H
/* The following macros deal with directory entries. */
#undef HAVE_DIRENT_H
#undef HAVE_SYS_NDIR_H
#undef HAVE_SYS_DIR_H
#undef HAVE_NDIR_H
#undef HAVE_DIR_H
#endif /* __config_h__ */

View file

@ -33,7 +33,7 @@ RCEXT = .rc
LN_S = @LN_S@
LD = gcc
LD = $(CC)
LDOUT =
LDFLAGS = @LDFLAGS@ -o
@ -45,13 +45,13 @@ RANLIB = @RANLIB@
RC = @RC@
DLLTOOL = @DLLTOOL@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
# The default library combination
library_combo = @ac_cv_library_combo@
ifeq ($(GNUSTEP_TARGET_OS),nextstep4)
library_combo = nx_nx_nx_nil
endif
#
# X Window System headers and libraries
#

415
configure vendored
View file

@ -555,6 +555,8 @@ fi
# If not, write to the Free Software Foundation,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#--------------------------------------------------------------------
# The GNUstep root directory.
# The user should have the GNUSTEP_SYSTEM_ROOT environment variable
@ -612,7 +614,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
fi
echo $ac_n "checking host system type""... $ac_c" 1>&6
echo "configure:616: checking host system type" >&5
echo "configure:618: checking host system type" >&5
host_alias=$host
case "$host_alias" in
@ -633,7 +635,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
echo "$ac_t""$host" 1>&6
echo $ac_n "checking target system type""... $ac_c" 1>&6
echo "configure:637: checking target system type" >&5
echo "configure:639: checking target system type" >&5
target_alias=$target
case "$target_alias" in
@ -651,7 +653,7 @@ target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
echo "$ac_t""$target" 1>&6
echo $ac_n "checking build system type""... $ac_c" 1>&6
echo "configure:655: checking build system type" >&5
echo "configure:657: checking build system type" >&5
build_alias=$build
case "$build_alias" in
@ -680,7 +682,7 @@ test "$host_alias" != "$target_alias" &&
# Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:684: checking for $ac_word" >&5
echo "configure:686: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -709,7 +711,7 @@ if test -z "$CC"; then
# Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:713: checking for $ac_word" >&5
echo "configure:715: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -757,7 +759,7 @@ fi
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
echo "configure:761: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
echo "configure:763: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
@ -767,11 +769,11 @@ ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS
cross_compiling=$ac_cv_prog_cc_cross
cat > conftest.$ac_ext <<EOF
#line 771 "configure"
#line 773 "configure"
#include "confdefs.h"
main(){return(0);}
EOF
if { (eval echo configure:775: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
if { (eval echo configure:777: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
ac_cv_prog_cc_works=yes
# If we can't run a trivial program, we are probably using a cross compiler.
if (./conftest; exit) 2>/dev/null; then
@ -791,12 +793,12 @@ if test $ac_cv_prog_cc_works = no; then
{ echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
echo "configure:795: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
echo "configure:797: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
cross_compiling=$ac_cv_prog_cc_cross
echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
echo "configure:800: checking whether we are using GNU C" >&5
echo "configure:802: checking whether we are using GNU C" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -805,7 +807,7 @@ else
yes;
#endif
EOF
if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:809: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:811: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
ac_cv_prog_gcc=yes
else
ac_cv_prog_gcc=no
@ -820,7 +822,7 @@ if test $ac_cv_prog_gcc = yes; then
ac_save_CFLAGS="$CFLAGS"
CFLAGS=
echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
echo "configure:824: checking whether ${CC-cc} accepts -g" >&5
echo "configure:826: checking whether ${CC-cc} accepts -g" >&5
if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -848,7 +850,7 @@ else
fi
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
echo "configure:852: checking how to run the C preprocessor" >&5
echo "configure:854: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
@ -863,13 +865,13 @@ else
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
#line 867 "configure"
#line 869 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:873: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:875: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
:
@ -880,13 +882,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
#line 884 "configure"
#line 886 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:890: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:892: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
:
@ -911,7 +913,7 @@ echo "$ac_t""$CPP" 1>&6
# Extract the first word of "ranlib", so it can be a program name with args.
set dummy ranlib; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:915: checking for $ac_word" >&5
echo "configure:917: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -937,8 +939,68 @@ else
echo "$ac_t""no" 1>&6
fi
# Find a good install program. We prefer a C program (faster),
# so one script is as good as another. But avoid the broken or
# incompatible versions:
# SysV /etc/install, /usr/sbin/install
# SunOS /usr/etc/install
# IRIX /sbin/install
# AIX /bin/install
# AFS /usr/afsws/bin/install, which mishandles nonexistent args
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
echo "configure:954: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="${IFS}:"
for ac_dir in $PATH; do
# Account for people who put trailing slashes in PATH elements.
case "$ac_dir/" in
/|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
*)
# OSF1 and SCO ODT 3.0 have their own names for install.
for ac_prog in ginstall installbsd scoinst install; do
if test -f $ac_dir/$ac_prog; then
if test $ac_prog = install &&
grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
# AIX install. It has an incompatible calling convention.
# OSF/1 installbsd also uses dspmsg, but is usable.
:
else
ac_cv_path_install="$ac_dir/$ac_prog -c"
break 2
fi
fi
done
;;
esac
done
IFS="$ac_save_IFS"
fi
if test "${ac_cv_path_install+set}" = set; then
INSTALL="$ac_cv_path_install"
else
# As a last resort, use the slow shell script. We don't cache a
# path for INSTALL within a source directory, because that will
# break other packages using the cache if that directory is
# removed, or if the path is relative.
INSTALL="$ac_install_sh"
fi
fi
echo "$ac_t""$INSTALL" 1>&6
# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
# It thinks the first close brace ends the variable substitution.
test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
echo "configure:942: checking whether ln -s works" >&5
echo "configure:1004: checking whether ln -s works" >&5
if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -967,7 +1029,7 @@ fi
# Uses ac_ vars as temps to allow command line to override cache and checks.
# --without-x overrides everything else, but does not touch the cache.
echo $ac_n "checking for X""... $ac_c" 1>&6
echo "configure:971: checking for X" >&5
echo "configure:1033: checking for X" >&5
# Check whether --with-x or --without-x was given.
if test "${with_x+set}" = set; then
@ -1029,12 +1091,12 @@ if test "$ac_x_includes" = NO; then
# First, try using that file with no special directory specified.
cat > conftest.$ac_ext <<EOF
#line 1033 "configure"
#line 1095 "configure"
#include "confdefs.h"
#include <$x_direct_test_include>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1038: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1100: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
@ -1103,14 +1165,14 @@ if test "$ac_x_libraries" = NO; then
ac_save_LIBS="$LIBS"
LIBS="-l$x_direct_test_library $LIBS"
cat > conftest.$ac_ext <<EOF
#line 1107 "configure"
#line 1169 "configure"
#include "confdefs.h"
int main() {
${x_direct_test_function}()
; return 0; }
EOF
if { (eval echo configure:1114: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
if { (eval echo configure:1176: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
LIBS="$ac_save_LIBS"
# We can link X programs with no special library path.
@ -1208,6 +1270,172 @@ fi
ac_header_dirent=no
for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6
echo "configure:1279: checking for $ac_hdr that defines DIR" >&5
if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1284 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <$ac_hdr>
int main() {
DIR *dirp = 0;
; return 0; }
EOF
if { (eval echo configure:1292: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
eval "ac_cv_header_dirent_$ac_safe=yes"
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
eval "ac_cv_header_dirent_$ac_safe=no"
fi
rm -f conftest*
fi
if eval "test \"`echo '$ac_cv_header_dirent_'$ac_safe`\" = yes"; then
echo "$ac_t""yes" 1>&6
ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
cat >> confdefs.h <<EOF
#define $ac_tr_hdr 1
EOF
ac_header_dirent=$ac_hdr; break
else
echo "$ac_t""no" 1>&6
fi
done
# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
if test $ac_header_dirent = dirent.h; then
echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6
echo "configure:1317: checking for opendir in -ldir" >&5
ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_save_LIBS="$LIBS"
LIBS="-ldir $LIBS"
cat > conftest.$ac_ext <<EOF
#line 1325 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char opendir();
int main() {
opendir()
; return 0; }
EOF
if { (eval echo configure:1336: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=no"
fi
rm -f conftest*
LIBS="$ac_save_LIBS"
fi
if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
echo "$ac_t""yes" 1>&6
LIBS="$LIBS -ldir"
else
echo "$ac_t""no" 1>&6
fi
else
echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6
echo "configure:1358: checking for opendir in -lx" >&5
ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_save_LIBS="$LIBS"
LIBS="-lx $LIBS"
cat > conftest.$ac_ext <<EOF
#line 1366 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char opendir();
int main() {
opendir()
; return 0; }
EOF
if { (eval echo configure:1377: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=no"
fi
rm -f conftest*
LIBS="$ac_save_LIBS"
fi
if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
echo "$ac_t""yes" 1>&6
LIBS="$LIBS -lx"
else
echo "$ac_t""no" 1>&6
fi
fi
for ac_hdr in sys/param.h sys/file.h dir.h string.h stdlib.h sys/types.h sys/stat.h sys/errno.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:1403: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1408 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1413: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
eval "ac_cv_header_$ac_safe=yes"
else
echo "$ac_err" >&5
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
eval "ac_cv_header_$ac_safe=no"
fi
rm -f conftest*
fi
if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
echo "$ac_t""yes" 1>&6
ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
cat >> confdefs.h <<EOF
#define $ac_tr_hdr 1
EOF
else
echo "$ac_t""no" 1>&6
fi
done
#--------------------------------------------------------------------
# Setup the library combination
#--------------------------------------------------------------------
@ -1222,7 +1450,11 @@ fi
if test "$ac_cv_library_combo" = ""; then
ac_cv_library_combo=gnu_gnu_gnu_xdp
if test $host_os = nextstep4; then
ac_cv_library_combo=nx_nx_nx_nil
else
ac_cv_library_combo=gnu_gnu_gnu_xdp
fi
fi
@ -1292,19 +1524,7 @@ fi
trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
# Transform confdefs.h into DEFS.
# Protect against shell expansion while executing Makefile rules.
# Protect against Makefile macro expansion.
cat > conftest.defs <<\EOF
s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g
s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g
s%\[%\\&%g
s%\]%\\&%g
s%\$%$$%g
EOF
DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '`
rm -f conftest.defs
DEFS=-DHAVE_CONFIG_H
# Without the "./", some shells look in PATH for config.status.
: ${CONFIG_STATUS=./config.status}
@ -1340,8 +1560,9 @@ do
done
ac_given_srcdir=$srcdir
ac_given_INSTALL="$INSTALL"
trap 'rm -fr `echo "config.make Makefile GNUstep.sh" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
trap 'rm -fr `echo "config.h config.make Makefile GNUstep.sh config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
EOF
cat >> $CONFIG_STATUS <<EOF
@ -1389,6 +1610,8 @@ s%@build_os@%$build_os%g
s%@CC@%$CC%g
s%@CPP@%$CPP%g
s%@RANLIB@%$RANLIB%g
s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
s%@INSTALL_DATA@%$INSTALL_DATA%g
s%@LN_S@%$LN_S%g
s%@X_INCLUDE@%$X_INCLUDE%g
s%@X_LIBS@%$X_LIBS%g
@ -1434,7 +1657,7 @@ EOF
cat >> $CONFIG_STATUS <<EOF
CONFIG_FILES=\${CONFIG_FILES-"config.make Makefile GNUstep.sh"}
CONFIG_FILES=\${CONFIG_FILES-"config.h config.make Makefile GNUstep.sh"}
EOF
cat >> $CONFIG_STATUS <<\EOF
for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
@ -1469,6 +1692,10 @@ for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
top_srcdir="$ac_dots$ac_given_srcdir" ;;
esac
case "$ac_given_INSTALL" in
[/$]*) INSTALL="$ac_given_INSTALL" ;;
*) INSTALL="$ac_dots$ac_given_INSTALL" ;;
esac
echo creating "$ac_file"
rm -f "$ac_file"
@ -1484,10 +1711,118 @@ for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
s%@configure_input@%$configure_input%g
s%@srcdir@%$srcdir%g
s%@top_srcdir@%$top_srcdir%g
s%@INSTALL@%$INSTALL%g
" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
fi; done
rm -f conftest.s*
# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
# NAME is the cpp macro being defined and VALUE is the value it is being given.
#
# ac_d sets the value in "#define NAME VALUE" lines.
ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)'
ac_dB='\([ ][ ]*\)[^ ]*%\1#\2'
ac_dC='\3'
ac_dD='%g'
# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
ac_uB='\([ ]\)%\1#\2define\3'
ac_uC=' '
ac_uD='\4%g'
# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
ac_eB='$%\1#\2define\3'
ac_eC=' '
ac_eD='%g'
if test "${CONFIG_HEADERS+set}" != set; then
EOF
cat >> $CONFIG_STATUS <<EOF
CONFIG_HEADERS="config.h"
EOF
cat >> $CONFIG_STATUS <<\EOF
fi
for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then
# Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
case "$ac_file" in
*:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
*) ac_file_in="${ac_file}.in" ;;
esac
echo creating $ac_file
rm -f conftest.frag conftest.in conftest.out
ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
cat $ac_file_inputs > conftest.in
EOF
# Transform confdefs.h into a sed script conftest.vals that substitutes
# the proper values into config.h.in to produce config.h. And first:
# Protect against being on the right side of a sed subst in config.status.
# Protect against being in an unquoted here document in config.status.
rm -f conftest.vals
cat > conftest.hdr <<\EOF
s/[\\&%]/\\&/g
s%[\\$`]%\\&%g
s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp
s%ac_d%ac_u%gp
s%ac_u%ac_e%gp
EOF
sed -n -f conftest.hdr confdefs.h > conftest.vals
rm -f conftest.hdr
# This sed command replaces #undef with comments. This is necessary, for
# example, in the case of _POSIX_SOURCE, which is predefined and required
# on some systems where configure will not decide to define it.
cat >> conftest.vals <<\EOF
s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
EOF
# Break up conftest.vals because some shells have a limit on
# the size of here documents, and old seds have small limits too.
rm -f conftest.tail
while :
do
ac_lines=`grep -c . conftest.vals`
# grep -c gives empty output for an empty file on some AIX systems.
if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi
# Write a limited-size here document to conftest.frag.
echo ' cat > conftest.frag <<CEOF' >> $CONFIG_STATUS
sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS
echo 'CEOF
sed -f conftest.frag conftest.in > conftest.out
rm -f conftest.in
mv conftest.out conftest.in
' >> $CONFIG_STATUS
sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail
rm -f conftest.vals
mv conftest.tail conftest.vals
done
rm -f conftest.vals
cat >> $CONFIG_STATUS <<\EOF
rm -f conftest.frag conftest.h
echo "/* $ac_file. Generated automatically by configure. */" > conftest.h
cat conftest.in >> conftest.h
rm -f conftest.in
if cmp -s $ac_file conftest.h 2>/dev/null; then
echo "$ac_file is unchanged"
rm -f conftest.h
else
# Remove last slash and all that follows it. Not all systems have dirname.
ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
# The file is in a subdirectory.
test ! -d "$ac_dir" && mkdir "$ac_dir"
fi
rm -f $ac_file
mv conftest.h $ac_file
fi
fi; done
EOF
cat >> $CONFIG_STATUS <<EOF

View file

@ -19,6 +19,8 @@ AC_INIT(application.make)
# If not, write to the Free Software Foundation,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
AC_CONFIG_HEADER(config.h)
#--------------------------------------------------------------------
# The GNUstep root directory.
# The user should have the GNUSTEP_SYSTEM_ROOT environment variable
@ -41,6 +43,7 @@ AC_CANONICAL_SYSTEM
AC_PROG_CC
AC_PROG_CPP
AC_PROG_RANLIB
AC_PROG_INSTALL
AC_LN_S
#--------------------------------------------------------------------
@ -59,6 +62,10 @@ fi
AC_SUBST(X_INCLUDE)
AC_SUBST(X_LIBS)
AC_HEADER_DIRENT
AC_HAVE_HEADERS(sys/param.h sys/file.h dir.h string.h stdlib.h sys/types.h dnl
sys/stat.h sys/errno.h)
#--------------------------------------------------------------------
# Setup the library combination
#--------------------------------------------------------------------
@ -76,11 +83,15 @@ ac_cv_library_combo=$withval
)
if test "$ac_cv_library_combo" = ""; then
ac_cv_library_combo=gnu_gnu_gnu_xdp
if test $host_os = nextstep4; then
ac_cv_library_combo=nx_nx_nx_nil
else
ac_cv_library_combo=gnu_gnu_gnu_xdp
fi
fi
AC_SUBST(ac_cv_library_combo)
#--------------------------------------------------------------------
# Produce the output files
#--------------------------------------------------------------------
AC_OUTPUT(config.make Makefile GNUstep.sh)
AC_OUTPUT(config.h config.make Makefile GNUstep.sh)

View file

@ -30,8 +30,10 @@ include $(GNUSTEP_SYSTEM_ROOT)/Makefiles/rules.make
ifeq ($(shared), yes)
LIBRARY_FILE = $(LIBRARY_NAME)$(SHARED_LIBEXT)
LIBRARY_FILE_EXT=$(SHARED_LIBEXT)
else
LIBRARY_FILE = $(LIBRARY_NAME)$(LIBEXT)
LIBRARY_FILE_EXT=$(LIBEXT)
endif
VERSION_LIBRARY_FILE = $(LIBRARY_FILE).$(VERSION)
@ -111,6 +113,11 @@ internal-uninstall-import-lib::
internal-clean::
rm -rf $(GNUSTEP_OBJ_PREFIX)
internal-distclean::
rm -rf shared_obj static_obj shared_debug_obj shared_profile_obj \
static_debug_obj static_profile_obj shared_profile_debug_obj \
static_profile_debug_obj
#
# Testing targets
#

View file

@ -48,6 +48,21 @@ ALL_TOOL_LIBS = $(ADDITIONAL_TOOL_LIBS) $(FND_LIBS) $(OBJC_LIBS) \
ALL_GUI_LIBS = $(ADDITIONAL_GUI_LIBS) $(BACKEND_LIBS) $(GUI_LIBS) \
$(FND_LIBS) $(OBJC_LIBS) $(SYSTEM_LIBS) $(TARGET_SYSTEM_LIBS)
LIB_DIRS_NO_SYSTEM = $(ADDITIONAL_LIB_DIRS) -L$(GNUSTEP_LIBRARIES) \
-L$(GNUSTEP_TARGET_LIBRARIES)
ALL_TOOL_LIBS := \
$(shell TARGET_LIB_DIR=$(GNUSTEP_TARGET_DIR)/$(LIBRARY_COMBO) \
$(WHICH_LIB_SCRIPT) $(LIB_DIRS_NO_SYSTEM) $(ALL_TOOL_LIBS) \
debug=$(debug) profile=$(profile) shared=$(shared) libext=$(LIBEXT) \
shared_libext=$(SHARED_LIBEXT))
ALL_GUI_LIBS := \
$(shell TARGET_LIB_DIR=$(GNUSTEP_TARGET_DIR)/$(LIBRARY_COMBO) \
$(WHICH_LIB_SCRIPT) $(LIB_DIRS_NO_SYSTEM) $(ALL_GUI_LIBS) \
debug=$(debug) profile=$(profile) shared=$(shared) libext=$(LIBEXT) \
shared_libext=$(SHARED_LIBEXT))
VPATH = .
.SUFFIXES: .m .c .psw
@ -263,7 +278,7 @@ after-clean::
before-distclean::
internal-distclean:: clean
internal-distclean::
after-distclean::

View file

@ -123,7 +123,7 @@ LDFLAGS += -Wl,-read_only_relocs,suppress
AFTER_INSTALL_STATIC_LIB_COMMAND =
SHARED_CFLAGS += -dynamic
SHARED_LIBEXT = .a
SHARED_LIBEXT = .so
HAVE_BUNDLES = yes
BUNDLE_CFLAGS =

View file

@ -69,23 +69,23 @@ include $(GNUSTEP_SYSTEM_ROOT)/Makefiles/rules.make
# should check when loading a shared library.
#
TEST_LIBRARY_LIST := $(foreach lib,$(TEST_LIBRARY_NAME),$(lib).testlib)
CHECK_LIBRARY_LIST := $(foreach lib,$(TEST_LIBRARY_NAME),$(lib).checklib)
TEST_LIBRARY_LIST := $(TEST_LIBRARY_NAME:=.testlib)
CHECK_LIBRARY_LIST := $(TEST_LIBRARY_NAME:=.checklib)
TEST_LIBRARY_STAMPS := $(foreach lib,$(TEST_LIBRARY_NAME),stamp-testlib-$(lib))
TEST_LIBRARY_STAMPS := $(addprefix $(GNUSTEP_OBJ_DIR)/,$(TEST_LIBRARY_STAMPS))
TEST_BUNDLE_LIST := $(foreach b,$(TEST_BUNDLE_NAME),$(b).testbundle)
CHECK_BUNDLE_LIST := $(foreach b,$(TEST_BUNDLE_NAME),$(b).checkbundle)
TEST_BUNDLE_LIST := $(TEST_BUNDLE_NAME:=.testbundle)
CHECK_BUNDLE_LIST := $(TEST_BUNDLE_NAME:=.checkbundle)
TEST_BUNDLE_STAMPS := $(foreach b,$(TEST_BUNDLE_NAME),stamp-testbundle-$(b))
TEST_BUNDLE_STAMPS := $(addprefix $(GNUSTEP_OBJ_DIR)/,$(TEST_BUNDLE_STAMPS))
TEST_TOOL_LIST := $(foreach tool,$(TEST_TOOL_NAME),$(tool).testtool)
CHECK_TOOL_LIST := $(foreach tool,$(TEST_TOOL_NAME),$(tool).checktool)
TEST_TOOL_LIST := $(TEST_TOOL_NAME:=.testtool)
CHECK_TOOL_LIST := $(TEST_TOOL_NAME:=.checktool)
TEST_TOOL_STAMPS := $(foreach tool,$(TEST_TOOL_NAME),stamp-testtool-$(tool))
TEST_TOOL_STAMPS := $(addprefix $(GNUSTEP_OBJ_DIR)/,$(TEST_TOOL_STAMPS))
TEST_APP_LIST := $(foreach app,$(TEST_APP_NAME),$(app).testapp)
CHECK_APP_LIST := $(foreach app,$(TEST_APP_NAME),$(app).checkapp)
TEST_APP_LIST := $(TEST_APP_NAME:=.testapp)
CHECK_APP_LIST := $(TEST_APP_NAME:=.checkapp)
TEST_APP_STAMPS := $(foreach app,$(TEST_APP_NAME),stamp-testapp-$(app))
TEST_APP_STAMPS := $(addprefix $(GNUSTEP_OBJ_DIR)/,$(TEST_APP_STAMPS))

View file

@ -29,7 +29,7 @@ include $(GNUSTEP_SYSTEM_ROOT)/Makefiles/rules.make
#
# xxx We need to prefix the target name when cross-compiling
#
TOOL_LIST := $(foreach tool,$(TOOL_NAME),$(tool).tool)
TOOL_LIST := $(TOOL_NAME:=.tool)
TOOL_FILE = $(TOOL_LIST)
TOOL_STAMPS := $(foreach tool,$(TOOL_NAME),stamp-tool-$(tool))
TOOL_STAMPS := $(addprefix $(GNUSTEP_OBJ_DIR)/,$(TOOL_STAMPS))

371
which_lib.c Normal file
View file

@ -0,0 +1,371 @@
/*
which_lib.c
Copyright (C) 1997 Free Software Foundation, Inc.
Author: Ovidiu Predescu <ovidiu@net-community.com>
Date: October 1997
This file is part of the GNUstep Makefile Package.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
You should have received a copy of the GNU General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*
Takes the name of the library, a list of search paths in the gcc notation
(using -Lpath) and the type of the library needed using the debug, profile,
static and shared variables.
It searches into the list of directories for a library matching the name and
the type required. If a library of that type is not found in a directory,
a similar one is tried. If no library is found at all then the next directory
will be searched. If no library is found in the list of libraries passed as
arguments, the user, then the local and finally the system GNUstep libraries
are searched.
*/
#include "config.h"
#include <stdio.h>
#include <errno.h>
#if HAVE_SYS_ERRNO_H
# include <sys/errno.h>
#endif
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif
#if HAVE_STRING_H
# include <string.h>
#endif
#if defined(HAVE_DIRENT_H)
# include <dirent.h>
#elif defined(HAVE_SYS_DIR_H)
# include <sys/dir.h>
#elif defined(HAVE_SYS_NDIR_H)
# include <sys/ndir.h>
#elif defined(HAVE_NDIR_H)
# include <ndir.h>
#elif defined(HAVE_DIR_H)
# include <dir.h>
#endif
#if !defined(_POSIX_VERSION)
# if defined(NeXT)
# define DIR_enum_item struct direct
# endif
#endif
#if !defined(DIR_enum_item)
# define DIR_enum_item struct dirent
#endif
#define DIR_enum_state DIR
/* determine filesystem max path length */
#ifdef _POSIX_VERSION
# include <limits.h> /* for PATH_MAX */
# include <utime.h>
#else
#if HAVE_SYS_PARAM_H
# include <sys/param.h> /* for MAXPATHLEN */
#endif
#endif
#ifndef PATH_MAX
# ifdef _POSIX_VERSION
# define PATH_MAX _POSIX_PATH_MAX
# else
# ifdef MAXPATHLEN
# define PATH_MAX MAXPATHLEN
# else
# define PATH_MAX 1024
# endif
# endif
#endif
#if HAVE_SYS_FILE_H
#include <sys/file.h>
#endif
#if HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
#include <fcntl.h>
#define PATH_SEP "/"
/* Array of strings that are the library paths passed to compiler */
int paths_no = 0;
char** library_paths = NULL;
/* The list of libraries */
int libraries_no = 0;
char** all_libraries = NULL;
int library_name_len;
char* library_name = NULL;
char *libname_suffix;
int debug = 0;
int profile = 0;
int shared = 0;
char* libext = ".a";
char* shared_libext = ".so";
char* extension;
void get_arguments (int argc, char** argv)
{
int i;
for (i = 0; i < argc; i++) {
if (!strncmp (argv[i], "-l", 2)) {
all_libraries = realloc (all_libraries,
(libraries_no + 1) * sizeof (char*));
all_libraries[libraries_no] = malloc (strlen (argv[i]) - 1);
strcpy (all_libraries[libraries_no], argv[i] + 2);
libraries_no++;
}
else if (!strncmp (argv[i], "-L", 2)) {
library_paths = realloc (library_paths, (paths_no + 1) * sizeof (char*));
library_paths[paths_no] = malloc (strlen (argv[i]) - 1);
strcpy (library_paths[paths_no], argv[i] + 2);
paths_no++;
}
else if (!strncmp (argv[i], "shared=", 7)) {
shared = !strncmp (argv[i] + 7, "yes", 3);
}
else if (!strncmp (argv[i], "debug=", 6)) {
debug = !strncmp (argv[i] + 6, "yes", 3);
}
else if (!strncmp (argv[i], "profile=", 8)) {
profile = !strncmp (argv[i] + 8, "yes", 3);
}
else if (!strncmp (argv[i], "libext=", 7)) {
libext = malloc (strlen (argv[i] + 7) + 1);
strcpy (libext, argv[i] + 7);
}
else if (!strncmp (argv[i], "shared_libext=", 14)) {
shared_libext = malloc (strlen (argv[i] + 14) + 1);
strcpy (shared_libext, argv[i] + 14);
}
}
/* Setup the exact prefix of the library we are looking for */
libname_suffix = malloc (5);
*libname_suffix = 0;
if (!shared)
strcat (libname_suffix, "s");
if (profile)
strcat (libname_suffix, "p");
if (debug)
strcat (libname_suffix, "d");
if (*libname_suffix) {
char tmp[5];
strcpy (tmp, libname_suffix);
strcpy (libname_suffix, "_");
strcat (libname_suffix, tmp);
}
/* Setup the extension */
extension = shared ? shared_libext : libext;
}
void show_all (void)
{
int i;
printf ("shared = %d\n", shared);
printf ("debug = %d\n", debug);
printf ("profile = %d\n", profile);
printf ("libext = %s\n", libext);
printf ("shared_libext = %s\n", shared_libext);
printf ("library name = %s\n", library_name);
puts ("library paths:");
for (i = 0; i < paths_no; i++)
printf (" %s\n", library_paths[i]);
}
/* Search for a library whose type is defined in 'type' as
'd' for debug
'p' for profile
's' for static
0 for the first library that matches library_name
Return 1 if a library with this type matches in 'path' and print to stdout
the name of the library. */
int search_for_library_with_type_in_directory(char type, char* path, char* ext)
{
DIR_enum_state* dir;
DIR_enum_item* dirbuf;
int i, found = 0;
dir = opendir (path);
while ((dirbuf = readdir (dir))) {
int filelen, extlen;
/* Skip "." and ".." directory entries */
if (strcmp(dirbuf->d_name, ".") == 0
|| strcmp(dirbuf->d_name, "..") == 0)
continue;
/* Skip it if the prefix does not match the library name. */
if (strncmp (dirbuf->d_name + 3, library_name, library_name_len))
continue;
filelen = strlen (dirbuf->d_name);
/* Now check if the extension matches */
if (ext && (extlen = strlen (ext)) && filelen - extlen > 0) {
if (strcmp (dirbuf->d_name + filelen - extlen, ext))
/* No luck, skip this file */
continue;
/* If we only need the first library found then just return */
if (!type)
found = 1;
else {
/* The extension matches. Do a check to see if the suffix of the
library matches the library type we are looking for. */
for (i = library_name_len; i < filelen - extlen; i++) {
if (dirbuf->d_name[i] == '_')
continue;
if (type == dirbuf->d_name[i]) {
found = 1;
break;
}
}
}
if (found) {
char filename[PATH_MAX + 1];
/* Copy the name of the library without the "lib" prefix and the
extension. */
strncpy (filename, dirbuf->d_name + 3, filelen - extlen - 3);
filename[filelen - extlen - 3] = 0;
printf (" -l%s", filename);
break;
}
}
}
closedir (dir);
return found;
}
/* Returns 1 if found the library in path and prints to stdout the name of the
library. */
int search_for_library_in_directory (char* path)
{
struct stat statbuf;
char full_filename[PATH_MAX + 1];
if (stat (path, &statbuf) < 0) /* An error occured or the dir doesn't exist */
return 0;
else if ((statbuf.st_mode & S_IFMT) != S_IFDIR) /* Not a directory */
return 0;
strcpy (full_filename, path);
strcat (full_filename, PATH_SEP);
strcat (full_filename, "lib");
strcat (full_filename, library_name);
strcat (full_filename, libname_suffix);
strcat (full_filename, extension);
if (stat (full_filename, &statbuf) < 0 && errno != ENOENT) /* Error */
return 0;
if ((statbuf.st_mode & S_IFMT) == S_IFREG) { /* Found it! */
printf (" -l%s", library_name);
if (*libname_suffix)
printf ("%s", libname_suffix);
return 1;
}
/* The library was not found. If the library needed is a debug version try
to find a library with debugging info. */
if (debug && search_for_library_with_type_in_directory('d', path, extension))
return 1;
/* The library was still not found. If the library needed is a profile
version try to find one that has profile info in it. */
if (profile && search_for_library_with_type_in_directory('p',path,extension))
return 1;
/* The library was still not found. Try to get whatever library we have
there. */
/* If a shared library is needed try to find a shared one first. */
if (shared
&& search_for_library_with_type_in_directory (0, path, shared_libext))
return 1;
/* Return a static library that matches the 'library_name' */
if (search_for_library_with_type_in_directory (0, path, libext))
return 1;
return 0;
}
int main(int argc, char** argv)
{
int i, j, found;
if (argc == 1) {
printf ("usage: %s [-Lpath ...] -llibrary shared=yes|no debug=yes|no "
"profile=yes|no libext=string shared_libext=string\n", argv[0]);
exit (1);
}
get_arguments (argc, argv);
if (!libraries_no)
exit (0);
/* show_all ();*/
for (i = 0; i < libraries_no; i++) {
library_name = all_libraries[i];
library_name_len = strlen (library_name);
found = 0;
for (j = 0; j < paths_no; j++)
if (search_for_library_in_directory (library_paths[j])) {
found = 1;
break;
}
if (!found) {
/* The library was not found. Assume there is somewhere else in the
linker library path and it will find the library. Otherwise a linking
error will happen but this is not our fault ;-). */
printf (" -l%s", library_name);
}
}
puts ("");
exit (0);
return 0;
}