From: Petr Ovtchenkov <ptr@void-ptr.info> (by way of Petr Ovtchenkov <ptr@void-ptr.info>)
To: elfutils-devel@sourceware.org
Subject: [PATCH 1/2] support cross compilation
Date: Fri, 24 Jun 2022 04:29:07 -0000 [thread overview]
Message-ID: <20220506174504.10952-2-ptr@void-ptr.info> (raw)
Message-ID: <20220624042907.trszykEhOUt_Jw3ROeuDeOvqywlJj6gjypL1FVypetw@z> (raw)
In-Reply-To: <20220506174504.10952-1-ptr@void-ptr.info>
Possible problem with out-of-tree build expected
---
Makefile.am | 2 +-
configure.ac | 6 ++++++
lib-host/Makefile.am | 47 ++++++++++++++++++++++++++++++++++++++++++++
libcpu/Makefile.am | 11 +++++++++++
4 files changed, 65 insertions(+), 1 deletion(-)
create mode 100644 lib-host/Makefile.am
diff --git a/Makefile.am b/Makefile.am
index 8643312a..a9c6c1d9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -26,7 +26,7 @@ AM_MAKEFLAGS = --no-print-directory
pkginclude_HEADERS = version.h
-SUBDIRS = config lib libelf libcpu backends libebl libdwelf libdwfl libdw \
+SUBDIRS = config lib lib-host libelf libcpu backends libebl libdwelf libdwfl libdw \
libasm debuginfod src po doc tests
EXTRA_DIST = elfutils.spec GPG-KEY NOTES CONTRIBUTING \
diff --git a/configure.ac b/configure.ac
index 11d1cf82..d0ad4678 100644
--- a/configure.ac
+++ b/configure.ac
@@ -90,6 +90,7 @@ AH_TEMPLATE([USE_LOCKS], [Defined if libraries should be thread-safe.])
AC_PROG_CC_C99
AC_PROG_CXX
+AX_PROG_CC_FOR_BUILD
AC_PROG_RANLIB
AC_PROG_YACC
AM_PROG_LEX
@@ -98,6 +99,8 @@ m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
AC_CHECK_TOOL([READELF], [readelf])
AC_CHECK_TOOL([NM], [nm])
+AM_CONDITIONAL([CROSS], [test "x$cross_compiling" = xyes])
+
AC_CACHE_CHECK([whether gcc supports __attribute__((visibility()))],
ac_cv_visibility, [dnl
save_CFLAGS="$CFLAGS"
@@ -608,6 +611,9 @@ AC_CONFIG_FILES([doc/Makefile])
dnl Support library.
AC_CONFIG_FILES([lib/Makefile])
+dnl Support library.
+AC_CONFIG_FILES([lib-host/Makefile])
+
dnl ELF library.
AC_CONFIG_FILES([libelf/Makefile])
diff --git a/lib-host/Makefile.am b/lib-host/Makefile.am
new file mode 100644
index 00000000..9316c8ed
--- /dev/null
+++ b/lib-host/Makefile.am
@@ -0,0 +1,47 @@
+## Process this file with automake to create Makefile.in
+##
+## Copyright (C) 1996-2011 Red Hat, Inc.
+## This file is part of elfutils.
+##
+## This file is free software; you can redistribute it and/or modify
+## it under the terms of either
+##
+## * the GNU Lesser General Public License as published by the Free
+## Software Foundation; either version 3 of the License, or (at
+## your option) any later version
+##
+## or
+##
+## * 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
+##
+## or both in parallel, as here.
+##
+## elfutils is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## General Public License for more details.
+##
+## You should have received copies of the GNU General Public License and
+## the GNU Lesser General Public License along with this program. If
+## not, see <http://www.gnu.org/licenses/>.
+##
+if CROSS
+
+include $(top_srcdir)/config/eu.am
+AM_CFLAGS += $(fpic_CFLAGS)
+AM_CPPFLAGS += -D_GNU_SOURCE -I$(srcdir)/../lib -I$(srcdir)/../libelf
+
+noinst_LIBRARIES = libeu.a
+
+$(libeu_a_OBJECTS): CC=${CC_FOR_BUILD}
+
+libeu_a_SOURCES = ../lib/xstrdup.c ../lib/xstrndup.c ../lib/xmalloc.c ../lib/next_prime.c \
+ ../lib/crc32.c ../lib/crc32_file.c \
+ ../lib/color.c ../lib/printversion.c
+
+if !GPROF
+xmalloc_CFLAGS = -ffunction-sections
+endif
+endif
diff --git a/libcpu/Makefile.am b/libcpu/Makefile.am
index 57d0a164..8da743d4 100644
--- a/libcpu/Makefile.am
+++ b/libcpu/Makefile.am
@@ -27,6 +27,13 @@
## the GNU Lesser General Public License along with this program. If
## not, see <http://www.gnu.org/licenses/>.
##
+
+if CROSS
+i386_gendis_LINK = ${CC_FOR_BUILD} ${LDFLAGS} -o $@
+
+$(i386_gendis_OBJECTS): CC=${CC_FOR_BUILD}
+endif
+
include $(top_srcdir)/config/eu.am
AM_CPPFLAGS += -I$(srcdir)/../libelf -I$(srcdir)/../libebl \
-I$(srcdir)/../libdw -I$(srcdir)/../libasm
@@ -87,7 +94,11 @@ endif
i386_lex_no_Werror = yes
+if CROSS
+libeu = ../lib-host/libeu.a
+else
libeu = ../lib/libeu.a
+endif
i386_lex_CFLAGS = -Wno-unused-label -Wno-unused-function -Wno-sign-compare \
-Wno-implicit-fallthrough
--
2.35.1.1.ge5a6898900
next prev parent reply other threads:[~2022-06-24 4:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-06 17:45 [PATCH 0/2] cross-build support, updated Petr Ovtchenkov
2022-05-06 17:45 ` Petr Ovtchenkov [this message]
2022-06-24 4:29 ` [PATCH 1/2] support cross compilation Petr Ovtchenkov
2022-05-06 17:45 ` [PATCH 2/2] drop _FORTIFY_SOURCE for host build Petr Ovtchenkov
2022-06-24 4:30 ` Petr Ovtchenkov
2022-06-24 4:28 ` [PATCH 0/2] cross-build support, updated Petr Ovtchenkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220506174504.10952-2-ptr@void-ptr.info \
--to=ptr@void-ptr.info \
--cc=elfutils-devel@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).