diff mbox series

configure: Use system installed libfdt if available

Message ID 20180813080136.610368-1-amitay@ozlabs.org
State Changes Requested
Headers show
Series configure: Use system installed libfdt if available | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success master/apply_patch Successfully applied
snowpatch_ozlabs/build-multiarch success Test build-multiarch on branch master

Commit Message

Amitay Isaacs Aug. 13, 2018, 8:01 a.m. UTC
Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
---
 Makefile.am  | 17 ++++++++++++++++-
 configure.ac | 11 +++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)

Comments

Alistair Popple Aug. 16, 2018, 6:36 a.m. UTC | #1
Actually for some projects it would be useful if we could explicitly point to
particular libfdt installation to use. Would this be hard to add? Eg.
./configure --with-libfdt=<path to libfdt>

Thanks.

- Alistair

On Monday, 13 August 2018 6:01:36 PM AEST Amitay Isaacs wrote:
> Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
> ---
>  Makefile.am  | 17 ++++++++++++++++-
>  configure.ac | 11 +++++++++++
>  2 files changed, 27 insertions(+), 1 deletion(-)
> 
> diff --git a/Makefile.am b/Makefile.am
> index 571660d..215f997 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -78,17 +78,26 @@ pdbg_SOURCES = \
>  	src/parsers.h \
>  	src/progress.h
>  
> +if LIBFDT_INTERNAL
>  pdbg_LDADD = $(DT_objects) libpdbg.la libfdt.la libccan.a \
>  	-L.libs -lrt
> +else
> +pdbg_LDADD = $(DT_objects) libpdbg.la libccan.a \
> +	-L.libs -lrt -lfdt
> +endif
>  
>  pdbg_LDFLAGS = -Wl,--whole-archive,-lpdbg,--no-whole-archive
>  pdbg_CFLAGS = -I$(top_srcdir)/libpdbg -Wall -Werror -DGIT_SHA1=\"${GIT_SHA1}\" \
>  	      $(ARCH_FLAGS)
>  
> +if LIBFDT_INTERNAL
>  lib_LTLIBRARIES = libpdbg.la libfdt.la
> +else
> +lib_LTLIBRARIES = libpdbg.la
> +endif
>  
> +if LIBFDT_INTERNAL
>  libfdt_la_CFLAGS = -I$(top_srcdir)/libfdt -DHAVE_LITTLE_ENDIAN
> -libpdbg_la_CFLAGS = -I$(top_srcdir)/libfdt -DHAVE_LITTLE_ENDIAN -Wall -Werror
>  
>  libfdt_la_SOURCES = \
>  	libfdt/fdt.c \
> @@ -104,6 +113,12 @@ libfdt_la_SOURCES = \
>  	libfdt/libfdt_env.h \
>  	libfdt/libfdt.h \
>  	libfdt/libfdt_internal.h
> +endif
> +
> +libpdbg_la_CFLAGS = -DHAVE_LITTLE_ENDIAN -Wall -Werror
> +if LIBFDT_INTERNAL
> +libpdbg_la_CFLAGS += -I$(top_srcdir)/libfdt
> +endif
>  
>  libpdbg_la_SOURCES = \
>  	libpdbg/libpdbg.c \
> diff --git a/configure.ac b/configure.ac
> index e48e80f..6d910ab 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -17,6 +17,17 @@ if test x"$ac_cv_path_DTC" = x ; then
>  fi
>  AC_SUBST([DTC])
>  
> +AC_CHECK_HEADER([libfdt.h])
> +AC_CHECK_LIB([fdt], [fdt_check_header])
> +if test x"$ac_cv_header_libfdt_h" = "xno" || \
> +   test x"$ac_cv_lib_fdt_fdt_check_header" = "xno" ; then
> +	AC_MSG_NOTICE([Using in-tree fdt library])
> +	AM_CONDITIONAL([LIBFDT_INTERNAL], [true])
> +else
> +	AC_MSG_NOTICE([Using system-installed fdt library])
> +	AM_CONDITIONAL([LIBFDT_INTERNAL], [false])
> +fi
> +
>  AC_CONFIG_MACRO_DIR([m4])
>  AC_CONFIG_HEADERS([config.h])
>  AC_CONFIG_FILES([Makefile])
>
Amitay Isaacs Aug. 16, 2018, 6:50 a.m. UTC | #2
On Thu, 2018-08-16 at 16:36 +1000, Alistair Popple wrote:
> Actually for some projects it would be useful if we could explicitly
> point to
> particular libfdt installation to use. Would this be hard to add? Eg.
> ./configure --with-libfdt=<path to libfdt>

That's not hard.  However, autoconf doesn't have a nice way of defining
a library which is either external or in-tree.  So we will end up with
lots of ifdef in Makefile.am, specially with all the tests I am adding
which link against libpdbg and libfdt.

I would really like a way to create symlinks to external libfdt if it
was specified, then the ifdef logic is only in one place.

Let me think on this one a little more.


> 
> Thanks.
> 
> - Alistair
> 
> On Monday, 13 August 2018 6:01:36 PM AEST Amitay Isaacs wrote:
> > Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
> > ---
> >  Makefile.am  | 17 ++++++++++++++++-
> >  configure.ac | 11 +++++++++++
> >  2 files changed, 27 insertions(+), 1 deletion(-)
> > 
> > diff --git a/Makefile.am b/Makefile.am
> > index 571660d..215f997 100644
> > --- a/Makefile.am
> > +++ b/Makefile.am
> > @@ -78,17 +78,26 @@ pdbg_SOURCES = \
> >  	src/parsers.h \
> >  	src/progress.h
> >  
> > +if LIBFDT_INTERNAL
> >  pdbg_LDADD = $(DT_objects) libpdbg.la libfdt.la libccan.a \
> >  	-L.libs -lrt
> > +else
> > +pdbg_LDADD = $(DT_objects) libpdbg.la libccan.a \
> > +	-L.libs -lrt -lfdt
> > +endif
> >  
> >  pdbg_LDFLAGS = -Wl,--whole-archive,-lpdbg,--no-whole-archive
> >  pdbg_CFLAGS = -I$(top_srcdir)/libpdbg -Wall -Werror
> > -DGIT_SHA1=\"${GIT_SHA1}\" \
> >  	      $(ARCH_FLAGS)
> >  
> > +if LIBFDT_INTERNAL
> >  lib_LTLIBRARIES = libpdbg.la libfdt.la
> > +else
> > +lib_LTLIBRARIES = libpdbg.la
> > +endif
> >  
> > +if LIBFDT_INTERNAL
> >  libfdt_la_CFLAGS = -I$(top_srcdir)/libfdt -DHAVE_LITTLE_ENDIAN
> > -libpdbg_la_CFLAGS = -I$(top_srcdir)/libfdt -DHAVE_LITTLE_ENDIAN
> > -Wall -Werror
> >  
> >  libfdt_la_SOURCES = \
> >  	libfdt/fdt.c \
> > @@ -104,6 +113,12 @@ libfdt_la_SOURCES = \
> >  	libfdt/libfdt_env.h \
> >  	libfdt/libfdt.h \
> >  	libfdt/libfdt_internal.h
> > +endif
> > +
> > +libpdbg_la_CFLAGS = -DHAVE_LITTLE_ENDIAN -Wall -Werror
> > +if LIBFDT_INTERNAL
> > +libpdbg_la_CFLAGS += -I$(top_srcdir)/libfdt
> > +endif
> >  
> >  libpdbg_la_SOURCES = \
> >  	libpdbg/libpdbg.c \
> > diff --git a/configure.ac b/configure.ac
> > index e48e80f..6d910ab 100644
> > --- a/configure.ac
> > +++ b/configure.ac
> > @@ -17,6 +17,17 @@ if test x"$ac_cv_path_DTC" = x ; then
> >  fi
> >  AC_SUBST([DTC])
> >  
> > +AC_CHECK_HEADER([libfdt.h])
> > +AC_CHECK_LIB([fdt], [fdt_check_header])
> > +if test x"$ac_cv_header_libfdt_h" = "xno" || \
> > +   test x"$ac_cv_lib_fdt_fdt_check_header" = "xno" ; then
> > +	AC_MSG_NOTICE([Using in-tree fdt library])
> > +	AM_CONDITIONAL([LIBFDT_INTERNAL], [true])
> > +else
> > +	AC_MSG_NOTICE([Using system-installed fdt library])
> > +	AM_CONDITIONAL([LIBFDT_INTERNAL], [false])
> > +fi
> > +
> >  AC_CONFIG_MACRO_DIR([m4])
> >  AC_CONFIG_HEADERS([config.h])
> >  AC_CONFIG_FILES([Makefile])
> > 
> 
> 

Amitay.
Alistair Popple Sept. 7, 2018, 3:41 a.m. UTC | #3
Amitay,

gcc: error: /home/alistair/Source/pdbg/.libs/libfdt.so: No such file or directory
Makefile:981: recipe for target 'libpdbg.la' failed
make[1]: *** [libpdbg.la] Error 1
Makefile:805: recipe for target 'all' failed
make: *** [all] Error 2

I get the above error when trying to build after a "make clean". I'm guessing
you must have had an old .libs/libfdt.* floating around when it was tested.

- Alistair

On Monday, 13 August 2018 6:01:36 PM AEST Amitay Isaacs wrote:
> Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
> ---
>  Makefile.am  | 17 ++++++++++++++++-
>  configure.ac | 11 +++++++++++
>  2 files changed, 27 insertions(+), 1 deletion(-)
> 
> diff --git a/Makefile.am b/Makefile.am
> index 571660d..215f997 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -78,17 +78,26 @@ pdbg_SOURCES = \
>  	src/parsers.h \
>  	src/progress.h
>  
> +if LIBFDT_INTERNAL
>  pdbg_LDADD = $(DT_objects) libpdbg.la libfdt.la libccan.a \
>  	-L.libs -lrt
> +else
> +pdbg_LDADD = $(DT_objects) libpdbg.la libccan.a \
> +	-L.libs -lrt -lfdt
> +endif
>  
>  pdbg_LDFLAGS = -Wl,--whole-archive,-lpdbg,--no-whole-archive
>  pdbg_CFLAGS = -I$(top_srcdir)/libpdbg -Wall -Werror -DGIT_SHA1=\"${GIT_SHA1}\" \
>  	      $(ARCH_FLAGS)
>  
> +if LIBFDT_INTERNAL
>  lib_LTLIBRARIES = libpdbg.la libfdt.la
> +else
> +lib_LTLIBRARIES = libpdbg.la
> +endif
>  
> +if LIBFDT_INTERNAL
>  libfdt_la_CFLAGS = -I$(top_srcdir)/libfdt -DHAVE_LITTLE_ENDIAN
> -libpdbg_la_CFLAGS = -I$(top_srcdir)/libfdt -DHAVE_LITTLE_ENDIAN -Wall -Werror
>  
>  libfdt_la_SOURCES = \
>  	libfdt/fdt.c \
> @@ -104,6 +113,12 @@ libfdt_la_SOURCES = \
>  	libfdt/libfdt_env.h \
>  	libfdt/libfdt.h \
>  	libfdt/libfdt_internal.h
> +endif
> +
> +libpdbg_la_CFLAGS = -DHAVE_LITTLE_ENDIAN -Wall -Werror
> +if LIBFDT_INTERNAL
> +libpdbg_la_CFLAGS += -I$(top_srcdir)/libfdt
> +endif
>  
>  libpdbg_la_SOURCES = \
>  	libpdbg/libpdbg.c \
> diff --git a/configure.ac b/configure.ac
> index e48e80f..6d910ab 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -17,6 +17,17 @@ if test x"$ac_cv_path_DTC" = x ; then
>  fi
>  AC_SUBST([DTC])
>  
> +AC_CHECK_HEADER([libfdt.h])
> +AC_CHECK_LIB([fdt], [fdt_check_header])
> +if test x"$ac_cv_header_libfdt_h" = "xno" || \
> +   test x"$ac_cv_lib_fdt_fdt_check_header" = "xno" ; then
> +	AC_MSG_NOTICE([Using in-tree fdt library])
> +	AM_CONDITIONAL([LIBFDT_INTERNAL], [true])
> +else
> +	AC_MSG_NOTICE([Using system-installed fdt library])
> +	AM_CONDITIONAL([LIBFDT_INTERNAL], [false])
> +fi
> +
>  AC_CONFIG_MACRO_DIR([m4])
>  AC_CONFIG_HEADERS([config.h])
>  AC_CONFIG_FILES([Makefile])
>
diff mbox series

Patch

diff --git a/Makefile.am b/Makefile.am
index 571660d..215f997 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -78,17 +78,26 @@  pdbg_SOURCES = \
 	src/parsers.h \
 	src/progress.h
 
+if LIBFDT_INTERNAL
 pdbg_LDADD = $(DT_objects) libpdbg.la libfdt.la libccan.a \
 	-L.libs -lrt
+else
+pdbg_LDADD = $(DT_objects) libpdbg.la libccan.a \
+	-L.libs -lrt -lfdt
+endif
 
 pdbg_LDFLAGS = -Wl,--whole-archive,-lpdbg,--no-whole-archive
 pdbg_CFLAGS = -I$(top_srcdir)/libpdbg -Wall -Werror -DGIT_SHA1=\"${GIT_SHA1}\" \
 	      $(ARCH_FLAGS)
 
+if LIBFDT_INTERNAL
 lib_LTLIBRARIES = libpdbg.la libfdt.la
+else
+lib_LTLIBRARIES = libpdbg.la
+endif
 
+if LIBFDT_INTERNAL
 libfdt_la_CFLAGS = -I$(top_srcdir)/libfdt -DHAVE_LITTLE_ENDIAN
-libpdbg_la_CFLAGS = -I$(top_srcdir)/libfdt -DHAVE_LITTLE_ENDIAN -Wall -Werror
 
 libfdt_la_SOURCES = \
 	libfdt/fdt.c \
@@ -104,6 +113,12 @@  libfdt_la_SOURCES = \
 	libfdt/libfdt_env.h \
 	libfdt/libfdt.h \
 	libfdt/libfdt_internal.h
+endif
+
+libpdbg_la_CFLAGS = -DHAVE_LITTLE_ENDIAN -Wall -Werror
+if LIBFDT_INTERNAL
+libpdbg_la_CFLAGS += -I$(top_srcdir)/libfdt
+endif
 
 libpdbg_la_SOURCES = \
 	libpdbg/libpdbg.c \
diff --git a/configure.ac b/configure.ac
index e48e80f..6d910ab 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,6 +17,17 @@  if test x"$ac_cv_path_DTC" = x ; then
 fi
 AC_SUBST([DTC])
 
+AC_CHECK_HEADER([libfdt.h])
+AC_CHECK_LIB([fdt], [fdt_check_header])
+if test x"$ac_cv_header_libfdt_h" = "xno" || \
+   test x"$ac_cv_lib_fdt_fdt_check_header" = "xno" ; then
+	AC_MSG_NOTICE([Using in-tree fdt library])
+	AM_CONDITIONAL([LIBFDT_INTERNAL], [true])
+else
+	AC_MSG_NOTICE([Using system-installed fdt library])
+	AM_CONDITIONAL([LIBFDT_INTERNAL], [false])
+fi
+
 AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_FILES([Makefile])