[weston,V2,1/2] Check for math (m) and real time (rt) libraries

Submitted by Javier Jardón on Oct. 30, 2014, 2:23 p.m.

Details

Message ID 1414679031-3105-1-git-send-email-jjardon@gnome.org
State Rejected
Headers show

Not browsing as part of any series.

Commit Message

Javier Jardón Oct. 30, 2014, 2:23 p.m.
---
 Makefile.am  | 19 +++++++++----------
 configure.ac |  6 ++++++
 2 files changed, 15 insertions(+), 10 deletions(-)

Patch hide | download patch | download mbox

diff --git a/Makefile.am b/Makefile.am
index 1e7cc81..1557953 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -44,7 +44,7 @@  weston_LDFLAGS = -export-dynamic
 weston_CPPFLAGS = $(AM_CPPFLAGS) -DIN_WESTON
 weston_CFLAGS = $(GCC_CFLAGS) $(COMPOSITOR_CFLAGS) $(LIBUNWIND_CFLAGS)
 weston_LDADD = $(COMPOSITOR_LIBS) $(LIBUNWIND_LIBS) \
-	$(DLOPEN_LIBS) -lm libshared.la
+	$(DLOPEN_LIBS) libshared.la
 
 weston_SOURCES =					\
 	src/git-version.h				\
@@ -211,7 +211,7 @@  drm_backend_la_LIBADD =				\
 	$(COMPOSITOR_LIBS)			\
 	$(DRM_COMPOSITOR_LIBS)			\
 	$(INPUT_BACKEND_LIBS)			\
-	libshared.la -lrt			\
+	libshared.la				\
 	libsession-helper.la
 drm_backend_la_CFLAGS =				\
 	$(COMPOSITOR_CFLAGS)			\
@@ -348,7 +348,7 @@  endif
 
 noinst_PROGRAMS += spring-tool
 spring_tool_CFLAGS = $(GCC_CFLAGS) $(COMPOSITOR_CFLAGS)
-spring_tool_LDADD = $(COMPOSITOR_LIBS) -lm
+spring_tool_LDADD = $(COMPOSITOR_LIBS)
 spring_tool_SOURCES =				\
 	src/spring-tool.c			\
 	src/animation.c				\
@@ -429,7 +429,7 @@  weston_presentation_shm_LDADD = $(SIMPLE_CLIENT_LIBS) libshared.la -lm
 
 weston_multi_resource_SOURCES = clients/multi-resource.c
 weston_multi_resource_CFLAGS = $(AM_CFLAGS) $(SIMPLE_CLIENT_CFLAGS)
-weston_multi_resource_LDADD = $(SIMPLE_CLIENT_LIBS) libshared.la -lm
+weston_multi_resource_LDADD = $(SIMPLE_CLIENT_LIBS) libshared.la
 endif
 
 if BUILD_SIMPLE_EGL_CLIENTS
@@ -439,7 +439,7 @@  nodist_weston_simple_egl_SOURCES =		\
 	protocol/xdg-shell-protocol.c		\
 	protocol/xdg-shell-client-protocol.h
 weston_simple_egl_CFLAGS = $(AM_CFLAGS) $(SIMPLE_EGL_CLIENT_CFLAGS)
-weston_simple_egl_LDADD = $(SIMPLE_EGL_CLIENT_LIBS) -lm
+weston_simple_egl_LDADD = $(SIMPLE_EGL_CLIENT_LIBS)
 endif
 
 noinst_LTLIBRARIES += libtoytoolkit.la
@@ -466,7 +466,7 @@  BUILT_SOURCES += $(nodist_libtoytoolkit_la_SOURCES)
 libtoytoolkit_la_LIBADD =			\
 	$(CLIENT_LIBS)				\
 	$(CAIRO_EGL_LIBS)			\
-	libshared-cairo.la -lrt -lm
+	libshared-cairo.la
 libtoytoolkit_la_CFLAGS = $(AM_CFLAGS) $(CLIENT_CFLAGS) $(CAIRO_EGL_CFLAGS)
 
 weston_flower_SOURCES = clients/flower.c
@@ -520,7 +520,7 @@  weston_nested_LDADD = libtoytoolkit.la $(SERVER_LIBS)
 weston_nested_CFLAGS = $(AM_CFLAGS) $(CLIENT_CFLAGS)
 
 weston_nested_client_SOURCES = clients/nested-client.c
-weston_nested_client_LDADD = $(SIMPLE_EGL_CLIENT_LIBS) -lm
+weston_nested_client_LDADD = $(SIMPLE_EGL_CLIENT_LIBS)
 weston_nested_client_CFLAGS = $(AM_CFLAGS) $(CLIENT_CFLAGS)
 endif
 
@@ -560,7 +560,7 @@  weston_subsurfaces_CFLAGS =			\
 	$(AM_CFLAGS)				\
 	$(SIMPLE_EGL_CLIENT_CFLAGS)		\
 	$(CLIENT_CFLAGS)
-weston_subsurfaces_LDADD = libtoytoolkit.la $(SIMPLE_EGL_CLIENT_LIBS) -lm
+weston_subsurfaces_LDADD = libtoytoolkit.la $(SIMPLE_EGL_CLIENT_LIBS)
 endif
 
 if HAVE_PANGO
@@ -916,7 +916,7 @@  vertex_clip_test_SOURCES =			\
 	tests/vertex-clip-test.c		\
 	src/vertex-clipping.c			\
 	src/vertex-clipping.h
-vertex_clip_test_LDADD = libtest-runner.la -lm -lrt
+vertex_clip_test_LDADD = libtest-runner.la
 
 libtest_client_la_SOURCES =			\
 	tests/weston-test-client-helper.c	\
@@ -984,7 +984,6 @@  matrix_test_SOURCES =				\
 	shared/matrix.c				\
 	shared/matrix.h
 matrix_test_CPPFLAGS = -DUNIT_TEST
-matrix_test_LDADD = -lm -lrt
 
 if BUILD_SETBACKLIGHT
 noinst_PROGRAMS += setbacklight
diff --git a/configure.ac b/configure.ac
index 9377774..e78f6c8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -46,6 +46,12 @@  AC_CHECK_FUNC([dlopen], [],
               AC_CHECK_LIB([dl], [dlopen], DLOPEN_LIBS="-ldl"))
 AC_SUBST(DLOPEN_LIBS)
 
+AC_SEARCH_LIBS([sqrt], [m], [],
+               [AC_MSG_FAILURE([Math library missing])])
+
+AC_SEARCH_LIBS([clock_gettime], [rt], [],
+               [AC_MSG_FAILURE([Real time library missing])])
+
 AC_CHECK_DECL(SFD_CLOEXEC,[],
 	      [AC_MSG_ERROR("SFD_CLOEXEC is needed to compile weston")],
 	      [[#include <sys/signalfd.h>]])

Comments

On 2014-10-30 15:23, Javier Jardón wrote:
> ---
>   Makefile.am  | 19 +++++++++----------
>   configure.ac |  6 ++++++
>   2 files changed, 15 insertions(+), 10 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index 9377774..e78f6c8 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -46,6 +46,12 @@ AC_CHECK_FUNC([dlopen], [],
>                 AC_CHECK_LIB([dl], [dlopen], DLOPEN_LIBS="-ldl"))
>   AC_SUBST(DLOPEN_LIBS)
>
> +AC_SEARCH_LIBS([sqrt], [m], [],
> +               [AC_MSG_FAILURE([Math library missing])])
> +
> +AC_SEARCH_LIBS([clock_gettime], [rt], [],
> +               [AC_MSG_FAILURE([Real time library missing])])
> +
>   AC_CHECK_DECL(SFD_CLOEXEC,[],
>   	      [AC_MSG_ERROR("SFD_CLOEXEC is needed to compile weston")],
>   	      [[#include <sys/signalfd.h>]])
>

That will add stuff to $(LIBS) directly, which should be avoided as much 
as possible. The use of $(LIBS) leads to overlinking most of the time.
I would recommend adding
AM_SUBST_NOTMAKE(LIBS)
to configure.ac, and add all the appropriate *_LIBS and *_CFLAGS 
variables everywhere needed.
On Fri, 31 Oct 2014 16:43:02 +0100
sardemff7+wayland@sardemff7.net wrote:

> On 2014-10-30 15:23, Javier Jardón wrote:
> > ---
> >   Makefile.am  | 19 +++++++++----------
> >   configure.ac |  6 ++++++
> >   2 files changed, 15 insertions(+), 10 deletions(-)
> >
> > diff --git a/configure.ac b/configure.ac
> > index 9377774..e78f6c8 100644
> > --- a/configure.ac
> > +++ b/configure.ac
> > @@ -46,6 +46,12 @@ AC_CHECK_FUNC([dlopen], [],
> >                 AC_CHECK_LIB([dl], [dlopen], DLOPEN_LIBS="-ldl"))
> >   AC_SUBST(DLOPEN_LIBS)
> >
> > +AC_SEARCH_LIBS([sqrt], [m], [],
> > +               [AC_MSG_FAILURE([Math library missing])])
> > +
> > +AC_SEARCH_LIBS([clock_gettime], [rt], [],
> > +               [AC_MSG_FAILURE([Real time library missing])])
> > +
> >   AC_CHECK_DECL(SFD_CLOEXEC,[],
> >   	      [AC_MSG_ERROR("SFD_CLOEXEC is needed to compile weston")],
> >   	      [[#include <sys/signalfd.h>]])
> >
> 
> That will add stuff to $(LIBS) directly, which should be avoided as much 
> as possible. The use of $(LIBS) leads to overlinking most of the time.
> I would recommend adding
> AM_SUBST_NOTMAKE(LIBS)
> to configure.ac, and add all the appropriate *_LIBS and *_CFLAGS 
> variables everywhere needed.

Yeah. We build lots of different binaries in the weston project, and
each have slightly different libraries they need. Especially I'd hate to
see e.g. weston-launch linking to anything unnecessary, since it is a
suid-root binary.

Let's try to link as little as possible, so I'm not taking these two
patches. Sorry.

Instead, as an immediate fix for Javier's original problem, I'll push
the first version of the patch.


Thanks,
pq