From c7dc133cff3db7336bb97fcb57c2dec559942518 Mon Sep 17 00:00:00 2001 From: Pierre-Marc Fournier Date: Thu, 11 Mar 2010 18:38:27 -0500 Subject: [PATCH] make libustcomm into a static lib --- Makefile.am | 2 +- configure.ac | 1 + libust/Makefile.am | 10 ++++++++-- libust/buffers.c | 32 +++++++++++++++----------------- libustcomm/Makefile.am | 8 ++++++++ ustctl/Makefile.am | 12 ++++++++++-- ustd/Makefile.am | 9 +++++++-- 7 files changed, 50 insertions(+), 24 deletions(-) create mode 100644 libustcomm/Makefile.am diff --git a/Makefile.am b/Makefile.am index de22e0d..e3a4bbd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,7 +5,7 @@ ACLOCAL_AMFLAGS = -I m4 # libust and '.' (that contains the linker script). However, '.' # must be installed after libust so it can overwrite libust.so with # the linker script. -SUBDIRS = snprintf libust . tests libmallocwrap ustd ustctl libinterfork include +SUBDIRS = snprintf libustcomm libust . tests libmallocwrap ustd ustctl libinterfork include EXTRA_DIST = doc libust.ldscript.in libust-initializer.c dist_bin_SCRIPTS = usttrace diff --git a/configure.ac b/configure.ac index e428a49..b1fb068 100644 --- a/configure.ac +++ b/configure.ac @@ -125,6 +125,7 @@ AC_CONFIG_FILES([ libinterfork/Makefile ustd/Makefile ustctl/Makefile + libustcomm/Makefile snprintf/Makefile ]) AC_OUTPUT diff --git a/libust/Makefile.am b/libust/Makefile.am index e38956a..cb5dc12 100644 --- a/libust/Makefile.am +++ b/libust/Makefile.am @@ -1,6 +1,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/libustcomm lib_LTLIBRARIES = libust.la + libust_la_SOURCES = \ marker.c \ tracepoint.c \ @@ -16,9 +17,14 @@ libust_la_SOURCES = \ tracercore.h \ serialize.c \ tracectl.c \ - $(top_builddir)/libustcomm/ustcomm.c \ tracerconst.h \ header-inline.h + libust_la_LDFLAGS = -no-undefined -version-info 0:0:0 -libust_la_LIBADD = -lpthread $(top_builddir)/snprintf/libustsnprintf.la + +libust_la_LIBADD = \ + -lpthread \ + $(top_builddir)/snprintf/libustsnprintf.la \ + $(top_builddir)/libustcomm/libustcomm.la + libust_la_CFLAGS = -DUST_COMPONENT="libust" diff --git a/libust/buffers.c b/libust/buffers.c index 9651beb..776823e 100644 --- a/libust/buffers.c +++ b/libust/buffers.c @@ -49,26 +49,24 @@ static int get_n_cpus(void) int result; static int n_cpus = 0; - if(n_cpus) { - return n_cpus; - } + if(!n_cpus) { + /* On Linux, when some processors are offline + * _SC_NPROCESSORS_CONF counts the offline + * processors, whereas _SC_NPROCESSORS_ONLN + * does not. If we used _SC_NPROCESSORS_ONLN, + * getcpu() could return a value greater than + * this sysconf, in which case the arrays + * indexed by processor would overflow. + */ + result = sysconf(_SC_NPROCESSORS_CONF); + if(result == -1) { + return -1; + } - /* On Linux, when some processors are offline - * _SC_NPROCESSORS_CONF counts the offline - * processors, whereas _SC_NPROCESSORS_ONLN - * does not. If we used _SC_NPROCESSORS_ONLN, - * getcpu() could return a value greater than - * this sysconf, in which case the arrays - * indexed by processor would overflow. - */ - result = sysconf(_SC_NPROCESSORS_CONF); - if(result == -1) { - return -1; + n_cpus = result; } - n_cpus = result; - - return result; + return n_cpus; } /* _ust_buffers_write() diff --git a/libustcomm/Makefile.am b/libustcomm/Makefile.am new file mode 100644 index 0000000..fa24cfb --- /dev/null +++ b/libustcomm/Makefile.am @@ -0,0 +1,8 @@ +AM_CPPFLAGS = -I$(top_srcdir)/include + +lib_LTLIBRARIES = libustcomm.la +libustcomm_la_SOURCES = \ + ustcomm.h \ + ustcomm.c +libustcomm_la_LDFLAGS = -no-undefined -version-info 0:0:0 -static +libustcomm_la_CFLAGS = -DUST_COMPONENT="libustcomm" -fPIC diff --git a/ustctl/Makefile.am b/ustctl/Makefile.am index 91966f0..4b8100f 100644 --- a/ustctl/Makefile.am +++ b/ustctl/Makefile.am @@ -2,6 +2,14 @@ AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/libustcomm \ -I$(top_srcdir)/libustcmd $(KCOMPAT_CFLAGS) bin_PROGRAMS = ustctl -ustctl_SOURCES = ustctl.c $(top_srcdir)/libustcomm/ustcomm.c $(top_srcdir)/libustcomm/ustcomm.h $(top_srcdir)/libustcmd/ustcmd.c $(top_srcdir)/libustcmd/ustcmd.h + +ustctl_SOURCES = \ + ustctl.c \ + $(top_srcdir)/libustcmd/ustcmd.c \ + $(top_srcdir)/libustcmd/ustcmd.h + ustctl_CFLAGS = -DUST_COMPONENT=ustctl -ustctl_LDADD = $(top_builddir)/snprintf/libustsnprintf.la + +ustctl_LDADD = \ + $(top_builddir)/snprintf/libustsnprintf.la \ + $(top_builddir)/libustcomm/libustcomm.la diff --git a/ustd/Makefile.am b/ustd/Makefile.am index 6adad64..96f167b 100644 --- a/ustd/Makefile.am +++ b/ustd/Makefile.am @@ -2,7 +2,12 @@ AM_CPPFLAGS = -I$(top_srcdir)/libust -I$(top_srcdir)/libustcomm \ -I$(top_srcdir)/include bin_PROGRAMS = ustd -ustd_SOURCES = lowlevel.c ustd.c ustd.h $(top_srcdir)/libustcomm/ustcomm.c $(top_srcdir)/libustcomm/ustcomm.h -ustd_LDADD = $(top_builddir)/snprintf/libustsnprintf.la + +ustd_SOURCES = lowlevel.c ustd.c ustd.h + +ustd_LDADD = \ + $(top_builddir)/snprintf/libustsnprintf.la \ + $(top_builddir)/libustcomm/libustcomm.la + ustd_LDFLAGS = -lpthread ustd_CFLAGS = -DUST_COMPONENT=ustd -- 2.34.1