Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Add support for building libelf in a host-tool environment.



details:   https://anonhg.NetBSD.org/src/rev/0359b8fba879
branches:  trunk
changeset: 750236:0359b8fba879
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Mon Dec 21 18:21:17 2009 +0000

description:
Add support for building libelf in a host-tool environment.

XXX Makefile.disklabel is really mis-named, but I'm not going to tackle
that problem right now.

diffstat:

 external/bsd/libelf/dist/libelf.h |  18 +++++--
 tools/Makefile                    |   3 +-
 tools/Makefile.disklabel          |   5 +-
 tools/libelf/Makefile             |  79 +++++++++++++++++++++++++++++++++++++++
 tools/libelf/libelf.inc           |   4 +
 5 files changed, 100 insertions(+), 9 deletions(-)

diffs (173 lines):

diff -r a1a10219e60a -r 0359b8fba879 external/bsd/libelf/dist/libelf.h
--- a/external/bsd/libelf/dist/libelf.h Mon Dec 21 16:40:58 2009 +0000
+++ b/external/bsd/libelf/dist/libelf.h Mon Dec 21 18:21:17 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: libelf.h,v 1.4 2009/12/20 05:52:15 thorpej Exp $       */
+/*     $NetBSD: libelf.h,v 1.5 2009/12/21 18:21:17 thorpej Exp $       */
 
 /*-
  * Copyright (c) 2006 Joseph Koshy
@@ -33,17 +33,23 @@
 
 #include <sys/types.h>
 #include <sys/queue.h>
+#include <inttypes.h>
 
-#if defined(__NetBSD__)
+#if HAVE_NBTOOL_CONFIG_H
+# include <nbinclude/sys/exec_elf.h>
+# define __LIBELF_HAVE_ELF_CAP          1
+# define __LIBELF_HAVE_ELF_MOVE         1
+# define __LIBELF_HAVE_ELF_NOTE         1
+# define __LIBELF_HAVE_ELF_SYMINFO      1
+# define __LIBELF_HAVE_ELF_VERS         1
+#elif defined(__NetBSD__)
 # include <sys/exec_elf.h>
 # define __LIBELF_HAVE_ELF_CAP         1
 # define __LIBELF_HAVE_ELF_MOVE                1
 # define __LIBELF_HAVE_ELF_NOTE                1
 # define __LIBELF_HAVE_ELF_SYMINFO     1
 # define __LIBELF_HAVE_ELF_VERS                1
-#endif /* __NetBSD__ */
-
-#if defined(__FreeBSD__)
+#elif defined(__FreeBSD__)
 # include <sys/elf32.h>
 # include <sys/elf64.h>
 # include <osreldate.h>
@@ -56,7 +62,7 @@
 # if __FreeBSD_version >= 700009
 #  define __LIBELF_HAVE_ELF_VERS       1
 # endif /* __FreeBSD_version >= 700009 */
-#endif /* __FreeBSD__ */
+#endif
 
 /* Library private data structures */
 typedef struct _Elf Elf;
diff -r a1a10219e60a -r 0359b8fba879 tools/Makefile
--- a/tools/Makefile    Mon Dec 21 16:40:58 2009 +0000
+++ b/tools/Makefile    Mon Dec 21 18:21:17 2009 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.129 2009/10/29 13:07:12 christos Exp $
+#      $NetBSD: Makefile,v 1.130 2009/12/21 18:21:17 thorpej Exp $
 
 .include <bsd.own.mk>
 
@@ -43,6 +43,7 @@
        yacc .WAIT \
        awk .WAIT \
        lex .WAIT \
+       libelf .WAIT \
        ${TOOLCHAIN_BITS} \
                asn1_compile atf-compile cat cksum compile_et config db \
                file lint1 \
diff -r a1a10219e60a -r 0359b8fba879 tools/Makefile.disklabel
--- a/tools/Makefile.disklabel  Mon Dec 21 16:40:58 2009 +0000
+++ b/tools/Makefile.disklabel  Mon Dec 21 18:21:17 2009 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.disklabel,v 1.13 2009/09/14 13:44:05 he Exp $
+#      $NetBSD: Makefile.disklabel,v 1.14 2009/12/21 18:21:17 thorpej Exp $
 
 # NOxxx definitions are copied from Makefile.host, and are
 # required before .include <bsd.own.mk>.   The include of bsd.own.mk
@@ -29,7 +29,8 @@
 _INCS=         disktab.h
 _SYSINCS=      bootblock.h \
                disklabel.h disklabel_acorn.h disklabel_gpt.h disklabel_rdb.h \
-               dkbad.h
+               dkbad.h \
+               exec_elf.h
 
 HOST_CPPFLAGS+=        -I${TOOLDIR}/include
 
diff -r a1a10219e60a -r 0359b8fba879 tools/libelf/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libelf/Makefile     Mon Dec 21 18:21:17 2009 +0000
@@ -0,0 +1,79 @@
+#      $NetBSD: Makefile,v 1.1 2009/12/21 18:21:18 thorpej Exp $
+
+HOSTLIB=       elf
+
+SRCS=          elf_begin.c                                             \
+               elf_cntl.c                                              \
+               elf_end.c elf_errmsg.c elf_errno.c                      \
+               elf_data.c                                              \
+               elf_fill.c elf_flag.c                                   \
+               elf_getarhdr.c elf_getarsym.c elf_getbase.c             \
+                   elf_getident.c                                      \
+               elf_hash.c                                              \
+               elf_kind.c                                              \
+               elf_memory.c                                            \
+               elf_next.c                                              \
+               elf_rand.c elf_rawfile.c                                \
+               elf_phnum.c                                             \
+               elf_shnum.c elf_shstrndx.c elf_scn.c elf_strptr.c       \
+               elf_update.c                                            \
+               elf_version.c                                           \
+               gelf_cap.c                                              \
+               gelf_checksum.c                                         \
+               gelf_dyn.c                                              \
+               gelf_ehdr.c                                             \
+               gelf_getclass.c                                         \
+               gelf_fsize.c                                            \
+               gelf_move.c                                             \
+               gelf_phdr.c                                             \
+               gelf_rel.c gelf_rela.c                                  \
+               gelf_shdr.c gelf_sym.c gelf_syminfo.c gelf_symshndx.c   \
+               gelf_xlate.c                                            \
+               libelf.c                                                \
+               libelf_align.c libelf_allocate.c libelf_ar.c            \
+               libelf_checksum.c                                       \
+               libelf_data.c                                           \
+               libelf_ehdr.c libelf_extended.c                         \
+               libelf_phdr.c                                           \
+               libelf_shdr.c                                           \
+               libelf_xlate.c                                          \
+               ${LIBELF_GENSRCS}
+
+LIBELF_GENSRCS=        libelf_fsize.c libelf_msize.c libelf_convert.c
+
+LIBELF_DIR=    ${.CURDIR}/../../external/bsd/libelf/dist
+
+CLEANFILES+=   ${LIBELF_GENSRCS}
+CPPFLAGS+=     -I${.CURDIR}/../compat -I${LIBELF_DIR}
+
+CPPFLAGS+=     -DLIBELF_TEST_HOOKS
+
+libelf_convert.c:      elf_types.m4 libelf_convert.m4
+libelf_fsize.c:                elf_types.m4 libelf_fsize.m4
+libelf_msize.c:                elf_types.m4 libelf_msize.m4
+
+BUILD_OSTYPE!=  uname -s
+
+# Disable use of pre-compiled headers on Darwin.
+.if ${BUILD_OSTYPE} == "Darwin"
+CPPFLAGS+=     -no-cpp-precomp
+.endif
+
+# -D_FILE_OFFSET_BITS=64 produces a much more amenable `struct stat', and
+# other file ops, on many systems, without changing function names.
+
+CPPFLAGS+=     -DHAVE_NBTOOL_CONFIG_H=1 -D_FILE_OFFSET_BITS=64
+
+.PATH:         ${LIBELF_DIR}
+
+HOST_CPPFLAGS:=        ${CPPFLAGS}
+CPPFLAGS:=     # empty
+
+.include "${.CURDIR}/../Makefile.disklabel"
+.include <bsd.hostlib.mk>
+
+# Keep the .SUFFIXES line after the include of bsd.hostlib.mk
+M4OBJDIR!=     cd ${.CURDIR}/../m4 && ${PRINTOBJDIR}
+.SUFFIXES:     .m4 .c
+.m4.c:
+       ${M4OBJDIR}/m4 -D SRCDIR=${LIBELF_DIR} ${.IMPSRC} > ${.TARGET}
diff -r a1a10219e60a -r 0359b8fba879 tools/libelf/libelf.inc
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libelf/libelf.inc   Mon Dec 21 18:21:17 2009 +0000
@@ -0,0 +1,4 @@
+#      $NetBSD: libelf.inc,v 1.1 2009/12/21 18:21:18 thorpej Exp $
+
+LIBELFSRCDIR=  ${.CURDIR}/../../external/bsd/libelf/dist
+LIBELFOBJDIR!= cd ${.CURDIR}/../libelf && ${PRINTOBJDIR}



Home | Main Index | Thread Index | Old Index