Browse Source

Build and use shared libraries

mvp
Andrew Waterman 13 years ago
parent
commit
4a2f98e35f
  1. 30
      Makefile.in
  2. 56
      configure
  3. 4
      riscv/riscv.ac

30
Makefile.in

@ -61,7 +61,7 @@ else
endif endif
install_hdrs_dir := $(DESTDIR)/include/$(project_name) install_hdrs_dir := $(DESTDIR)/include/$(project_name)
install_libs_dir := $(DESTDIR)/lib/$(project_name) install_libs_dir := $(DESTDIR)/lib
install_exes_dir := $(DESTDIR)/bin install_exes_dir := $(DESTDIR)/bin
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -84,21 +84,22 @@ VPATH := $(addprefix $(src_dir)/, $(sprojs_enabled))
CC := @CC@ CC := @CC@
CXX := @CXX@ CXX := @CXX@
CFLAGS += @CFLAGS@ CFLAGS += @CFLAGS@ -DPREFIX=\"$(prefix)\"
CPPFLAGS += @CPPFLAGS@ CPPFLAGS += @CPPFLAGS@
CXXFLAGS += @CXXFLAGS@ CXXFLAGS += @CXXFLAGS@ -DPREFIX=\"$(prefix)\"
COMPILE := $(CXX) -MMD -MP $(CPPFLAGS) $(CFLAGS) $(CXXFLAGS) \ COMPILE := $(CXX) -fPIC -MMD -MP $(CPPFLAGS) $(CFLAGS) $(CXXFLAGS) \
$(sprojs_include) $(sprojs_include)
COMPILE_C := $(CC) -MMD -MP $(CPPFLAGS) $(CFLAGS) \ COMPILE_C := $(CC) -fPIC -MMD -MP $(CPPFLAGS) $(CFLAGS) \
$(sprojs_include) $(sprojs_include)
# Linker # Linker
# - LDFLAGS : Flags for the linker (eg. -L) # - LDFLAGS : Flags for the linker (eg. -L)
# - LIBS : Library flags (eg. -l) # - LIBS : Library flags (eg. -l)
comma := ,
LD := $(CXX) LD := $(CXX)
LDFLAGS := @LDFLAGS@ LDFLAGS := @LDFLAGS@
LIBS := @LIBS@ LIBS := @LIBS@
LINK := $(LD) $(LDFLAGS) LINK := $(LD) $(LDFLAGS) -Wl,-rpath,$(install_libs_dir) $(patsubst -L%,-Wl$(comma)-rpath$(comma)%,$(filter -L%,$(LDFLAGS)))
# Library creation # Library creation
@ -196,11 +197,10 @@ $(2)_junk += $$($(2)_objs) $$($(2)_c_objs) $$($(2)_deps) $$($(2)_c_deps) $$($(2)
# Build a library for this subproject # Build a library for this subproject
lib$(1).a : $$($(2)_objs) $$($(2)_c_objs) lib$(1).so : $$($(2)_objs) $$($(2)_c_objs)
$(AR) rcv $$@ $$^ $(CXX) -shared -o $$@ $$^
$(RANLIB) $$@
$(2)_junk += lib$(1).a $(2)_junk += lib$(1).so
# Reverse the dependency list so that a given subproject only depends on # Reverse the dependency list so that a given subproject only depends on
# subprojects listed to its right. This is the correct order for linking # subprojects listed to its right. This is the correct order for linking
@ -215,7 +215,7 @@ $(2)_test_deps := $$(patsubst %.o, %.d, $$($(2)_test_objs))
$(2)_test_exes := $$(patsubst %.t.cc, %-utst, $$($(2)_test_srcs)) $(2)_test_exes := $$(patsubst %.t.cc, %-utst, $$($(2)_test_srcs))
$(2)_test_outs := $$(patsubst %, %.out, $$($(2)_test_exes)) $(2)_test_outs := $$(patsubst %, %.out, $$($(2)_test_exes))
$(2)_test_libs := $(1) $$($(2)_reverse_deps) utst $(2)_test_libs := $(1) $$($(2)_reverse_deps) utst
$(2)_test_libnames := $$(patsubst %, lib%.a, $$($(2)_test_libs)) $(2)_test_libnames := $$(patsubst %, lib%.so, $$($(2)_test_libs))
$(2)_test_libarg := -L. $$(patsubst %, -l%, $$($(2)_test_libs)) $(2)_test_libarg := -L. $$(patsubst %, -l%, $$($(2)_test_libs))
$$($(2)_test_objs) : %.o : %.cc $$($(2)_test_objs) : %.o : %.cc
@ -242,7 +242,7 @@ $(2)_prog_objs := $$(patsubst %.cc, %.o, $$($(2)_prog_srcs))
$(2)_prog_deps := $$(patsubst %.o, %.d, $$($(2)_prog_objs)) $(2)_prog_deps := $$(patsubst %.o, %.d, $$($(2)_prog_objs))
$(2)_prog_exes := $$(patsubst %.cc, %, $$($(2)_prog_srcs)) $(2)_prog_exes := $$(patsubst %.cc, %, $$($(2)_prog_srcs))
$(2)_prog_libs := $(1) $$($(2)_reverse_deps) $(2)_prog_libs := $(1) $$($(2)_reverse_deps)
$(2)_prog_libnames := $$(patsubst %, lib%.a, $$($(2)_prog_libs)) $(2)_prog_libnames := $$(patsubst %, lib%.so, $$($(2)_prog_libs))
$(2)_prog_libarg := -L. $$(patsubst %, -l%, $$($(2)_prog_libs)) $(2)_prog_libarg := -L. $$(patsubst %, -l%, $$($(2)_prog_libs))
$$($(2)_prog_objs) : %.o : %.cc $$($(2)_prog_objs) : %.o : %.cc
@ -273,7 +273,7 @@ $(2)_junk += \
# Subproject specific targets # Subproject specific targets
all-$(1) : lib$(1).a $$($(2)_install_prog_exes) all-$(1) : lib$(1).so $$($(2)_install_prog_exes)
check-$(1) : $$($(2)_test_outs) check-$(1) : $$($(2)_test_outs)
echo; grep -h -e'Unit Tests' -e'FAILED' -e'Segementation' $$^; echo echo; grep -h -e'Unit Tests' -e'FAILED' -e'Segementation' $$^; echo
@ -285,7 +285,7 @@ clean-$(1) :
# Update running variables # Update running variables
libs += lib$(1).a libs += lib$(1).so
objs += $$($(2)_objs) objs += $$($(2)_objs)
srcs += $$(addprefix $(src_dir)/$(1)/, $$($(2)_srcs)) srcs += $$(addprefix $(src_dir)/$(1)/, $$($(2)_srcs))
hdrs += $$(addprefix $(src_dir)/$(1)/, $$($(2)_hdrs)) $$($(2)_gen_hdrs) hdrs += $$(addprefix $(src_dir)/$(1)/, $$($(2)_hdrs)) $$($(2)_gen_hdrs)
@ -295,7 +295,7 @@ deps += $$($(2)_deps)
test_outs += $$($(2)_test_outs) test_outs += $$($(2)_test_outs)
install_hdrs += $$(addprefix $(src_dir)/$(1)/, $$($(2)_hdrs)) $$($(2)_gen_hdrs) install_hdrs += $$(addprefix $(src_dir)/$(1)/, $$($(2)_hdrs)) $$($(2)_gen_hdrs)
install_libs += lib$(1).a install_libs += lib$(1).so
install_exes += $$($(2)_install_prog_exes) install_exes += $$($(2)_install_prog_exes)
endef endef

56
configure

@ -4081,13 +4081,13 @@ if test "${with_fesvr+set}" = set; then :
fi fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libfesvr_is_present in -lfesvr" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -lpthread" >&5
$as_echo_n "checking for libfesvr_is_present in -lfesvr... " >&6; } $as_echo_n "checking for pthread_create in -lpthread... " >&6; }
if ${ac_cv_lib_fesvr_libfesvr_is_present+:} false; then : if ${ac_cv_lib_pthread_pthread_create+:} false; then :
$as_echo_n "(cached) " >&6 $as_echo_n "(cached) " >&6
else else
ac_check_lib_save_LIBS=$LIBS ac_check_lib_save_LIBS=$LIBS
LIBS="-lfesvr $LIBS" LIBS="-lpthread $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */ /* end confdefs.h. */
@ -4097,45 +4097,45 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
#endif #endif
char libfesvr_is_present (); char pthread_create ();
int int
main () main ()
{ {
return libfesvr_is_present (); return pthread_create ();
; ;
return 0; return 0;
} }
_ACEOF _ACEOF
if ac_fn_c_try_link "$LINENO"; then : if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_fesvr_libfesvr_is_present=yes ac_cv_lib_pthread_pthread_create=yes
else else
ac_cv_lib_fesvr_libfesvr_is_present=no ac_cv_lib_pthread_pthread_create=no
fi fi
rm -f core conftest.err conftest.$ac_objext \ rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS LIBS=$ac_check_lib_save_LIBS
fi fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_fesvr_libfesvr_is_present" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_create" >&5
$as_echo "$ac_cv_lib_fesvr_libfesvr_is_present" >&6; } $as_echo "$ac_cv_lib_pthread_pthread_create" >&6; }
if test "x$ac_cv_lib_fesvr_libfesvr_is_present" = xyes; then : if test "x$ac_cv_lib_pthread_pthread_create" = xyes; then :
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
#define HAVE_LIBFESVR 1 #define HAVE_LIBPTHREAD 1
_ACEOF _ACEOF
LIBS="-lfesvr $LIBS" LIBS="-lpthread $LIBS"
else else
as_fn_error $? "libfesvr is required" "$LINENO" 5 as_fn_error $? "libpthread is required" "$LINENO" 5
fi fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -lpthread" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libfesvr_is_present in -lfesvr" >&5
$as_echo_n "checking for pthread_create in -lpthread... " >&6; } $as_echo_n "checking for libfesvr_is_present in -lfesvr... " >&6; }
if ${ac_cv_lib_pthread_pthread_create+:} false; then : if ${ac_cv_lib_fesvr_libfesvr_is_present+:} false; then :
$as_echo_n "(cached) " >&6 $as_echo_n "(cached) " >&6
else else
ac_check_lib_save_LIBS=$LIBS ac_check_lib_save_LIBS=$LIBS
LIBS="-lpthread $LIBS" LIBS="-lfesvr $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */ /* end confdefs.h. */
@ -4145,35 +4145,35 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
#endif #endif
char pthread_create (); char libfesvr_is_present ();
int int
main () main ()
{ {
return pthread_create (); return libfesvr_is_present ();
; ;
return 0; return 0;
} }
_ACEOF _ACEOF
if ac_fn_c_try_link "$LINENO"; then : if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_pthread_pthread_create=yes ac_cv_lib_fesvr_libfesvr_is_present=yes
else else
ac_cv_lib_pthread_pthread_create=no ac_cv_lib_fesvr_libfesvr_is_present=no
fi fi
rm -f core conftest.err conftest.$ac_objext \ rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS LIBS=$ac_check_lib_save_LIBS
fi fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_create" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_fesvr_libfesvr_is_present" >&5
$as_echo "$ac_cv_lib_pthread_pthread_create" >&6; } $as_echo "$ac_cv_lib_fesvr_libfesvr_is_present" >&6; }
if test "x$ac_cv_lib_pthread_pthread_create" = xyes; then : if test "x$ac_cv_lib_fesvr_libfesvr_is_present" = xyes; then :
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
#define HAVE_LIBPTHREAD 1 #define HAVE_LIBFESVR 1
_ACEOF _ACEOF
LIBS="-lpthread $LIBS" LIBS="-lfesvr $LIBS"
else else
as_fn_error $? "libpthread is required" "$LINENO" 5 as_fn_error $? "libfesvr is required" "$LINENO" 5
fi fi

4
riscv/riscv.ac

@ -7,10 +7,10 @@ AC_ARG_WITH([fesvr],
] ]
) )
AC_CHECK_LIB(fesvr, libfesvr_is_present, [], [AC_MSG_ERROR([libfesvr is required])])
AC_CHECK_LIB(pthread, pthread_create, [], [AC_MSG_ERROR([libpthread is required])]) AC_CHECK_LIB(pthread, pthread_create, [], [AC_MSG_ERROR([libpthread is required])])
AC_CHECK_LIB(fesvr, libfesvr_is_present, [], [AC_MSG_ERROR([libfesvr is required])])
AC_ARG_ENABLE([fpu], AS_HELP_STRING([--disable-fpu], [Disable floating-point])) AC_ARG_ENABLE([fpu], AS_HELP_STRING([--disable-fpu], [Disable floating-point]))
AS_IF([test "x$enable_fpu" != "xno"], [ AS_IF([test "x$enable_fpu" != "xno"], [
AC_DEFINE([RISCV_ENABLE_FPU],,[Define if floating-point instructions are supported]) AC_DEFINE([RISCV_ENABLE_FPU],,[Define if floating-point instructions are supported])

Loading…
Cancel
Save