From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by sourceware.org (Postfix) with ESMTPS id 4B1C13858028 for ; Tue, 20 Sep 2022 08:43:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4B1C13858028 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-x42e.google.com with SMTP id b75so2088264pfb.7 for ; Tue, 20 Sep 2022 01:43:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=KPpI3MM/ptSbbT/IfScB6MhifL9VYT60niWWLIwMoAk=; b=OSageDRZGuwJkzHNW4paP74ut/tp4Armqlls0IPpQM6J8KXMtHSVCjkNJfTHcha8e9 x8zWE90lmHOlu3nY9SmelogmltlYoSw2CCqPYgTBwPLXDMLT5caRle/Z36RKrZdb441C WGYhJr+X0Qf47hpL6uN0WrJVZHJuzm4U0tz0/Ysxc/6MTMhxv0WnOjZgRRs6SuxZ8Vkj w/DrKWxDZHVYZwM1GAo8yWeMbONvZ9PAW0PWmgXoCinrp6OmoAI2S2O9W13OXJLc8398 D4O1wADAfYCWyr/AFokrmjg6c5yCI1IGBt35ZH19Lhe7CN33PUvOytu8l8Qp85iDr6DH moyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=KPpI3MM/ptSbbT/IfScB6MhifL9VYT60niWWLIwMoAk=; b=H5fngzl/3ShN6cbib94mZGWU6wfqg56y/PDu9uhvYwyCKOKX+sMpnjVNdY0BVKFNrZ lNdWG1OWUXaQBzlsndYJGiehYQTpNKO4UeQCRfvmAyidkdFPE0cEuwxWUZ/BTUQpILtZ uo3teFzNwPFE+eb3vZGjPnZHrM+lvbdkebdCm5HFm0ggXs56mbRfmtxaPSYKYI/21Ybr R3OMtWdZ3a3wCjnCeXswatBZgH2yYA8qmYxy3uktjQkSug/BfQW7aGcTZOAiBpkvcpVl TSwARdBgwM4QhA2qy9ah/VMGukUdUzJETkBZxW00w9M4EQjNoDsjj1lRV116VZmQVhGr QF6g== X-Gm-Message-State: ACrzQf3Q8qCuv/LJb9jcNVb0iTpRbtD6x32E5TqQa4ZFLKEWodYuAjSb o2KysfB+kFaqjMaZf2etCabzQNnv+S0= X-Google-Smtp-Source: AMsMyM7uGe87hHaYSYr8DBWzybsAyZvbCvp0AikjvZOVjuSGOcrSFM3nv0yoXKpVHZzFqFjGx8bj9A== X-Received: by 2002:a63:904c:0:b0:435:eb3:83da with SMTP id a73-20020a63904c000000b004350eb383damr19769272pge.612.1663663413925; Tue, 20 Sep 2022 01:43:33 -0700 (PDT) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id so16-20020a17090b1f9000b002009db534d1sm873372pjb.24.2022.09.20.01.43.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 01:43:33 -0700 (PDT) From: Yonggang Luo To: elfutils-devel@sourceware.org Cc: Yonggang Luo Subject: [PATCH 7/7] Add CMake build files Date: Tue, 20 Sep 2022 16:43:07 +0800 Message-Id: <20220920084307.1696-8-luoyonggang@gmail.com> X-Mailer: git-send-email 2.36.1.windows.1 In-Reply-To: <20220920084307.1696-1-luoyonggang@gmail.com> References: <20220920084307.1696-1-luoyonggang@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Signed-off-by: Yonggang Luo --- .gitignore | 1 + CMakeLists.txt | 47 +++++++++ libelf/CMakeLists.txt | 192 +++++++++++++++++++++++++++++++++++ libelf/config-cmake/config.h | 27 +++++ 4 files changed, 267 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 libelf/CMakeLists.txt create mode 100644 libelf/config-cmake/config.h diff --git a/.gitignore b/.gitignore index 8bcd88d7..ca06dddd 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ Makefile.in /INSTALL /aclocal.m4 /autom4te.* +/build /config.cache /config.h /config.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..11ad5c13 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,47 @@ +# Copyright (C) 2022 Yonggang Luo=0D +# This file is part of elfutils.=0D +#=0D +# This file is free software; you can redistribute it and/or modify=0D +# it under the terms of the GNU General Public License as published by=0D +# the Free Software Foundation; either version 3 of the License, or=0D +# (at your option) any later version.=0D +#=0D +# elfutils is distributed in the hope that it will be useful, but=0D +# WITHOUT ANY WARRANTY; without even the implied warranty of=0D +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the=0D +# GNU General Public License for more details.=0D +#=0D +# You should have received a copy of the GNU General Public License=0D +# along with this program. If not, see .=0D +=0D +cmake_minimum_required(VERSION 3.16)=0D +project(libelf=0D + LANGUAGES C=0D + VERSION 0.187=0D +)=0D +=0D +add_subdirectory(libelf)=0D +=0D +include(GNUInstallDirs)=0D +=0D +if (LIBELF_INSTALL)=0D + # Install the targets=0D + install(TARGETS elf=0D + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}=0D + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libelf=0D + )=0D + set(VERSION ${CMAKE_PROJECT_VERSION})=0D + set(prefix ${CMAKE_INSTALL_PREFIX})=0D + set(exec_prefix "\${prefix}")=0D + set(libdir "\${exec_prefix}/lib")=0D + set(includedir "\${prefix}/include/libelf")=0D + configure_file(=0D + ${CMAKE_CURRENT_SOURCE_DIR}/config/libelf.pc.in=0D + ${CMAKE_CURRENT_BINARY_DIR}/libelf.pc=0D + @ONLY=0D + )=0D + install(=0D + FILES ${CMAKE_CURRENT_BINARY_DIR}/libelf.pc=0D + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig=0D + )=0D +endif()=0D diff --git a/libelf/CMakeLists.txt b/libelf/CMakeLists.txt new file mode 100644 index 00000000..dc8f9291 --- /dev/null +++ b/libelf/CMakeLists.txt @@ -0,0 +1,192 @@ +# Copyright (C) 2022 Yonggang Luo=0D +# This file is part of elfutils.=0D +#=0D +# This file is free software; you can redistribute it and/or modify=0D +# it under the terms of the GNU General Public License as published by=0D +# the Free Software Foundation; either version 3 of the License, or=0D +# (at your option) any later version.=0D +#=0D +# elfutils is distributed in the hope that it will be useful, but=0D +# WITHOUT ANY WARRANTY; without even the implied warranty of=0D +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the=0D +# GNU General Public License for more details.=0D +#=0D +# You should have received a copy of the GNU General Public License=0D +# along with this program. If not, see .=0D +=0D +add_library(elf=0D + elf_begin.c=0D + elf_clone.c=0D + elf_cntl.c=0D + elf_compress_gnu.c=0D + elf_compress.c=0D + elf_end.c=0D + elf_error.c=0D + elf_fill.c=0D + elf_flagdata.c=0D + elf_flagehdr.c=0D + elf_flagelf.c=0D + elf_flagphdr.c=0D + elf_flagscn.c=0D + elf_flagshdr.c=0D + elf_getarhdr.c=0D + elf_getaroff.c=0D + elf_getarsym.c=0D + elf_getbase.c=0D + elf_getdata_rawchunk.c=0D + elf_getdata.c=0D + elf_getident.c=0D + elf_getphdrnum.c=0D + elf_getscn.c=0D + elf_getshdrnum.c=0D + elf_getshdrstrndx.c=0D + elf_gnu_hash.c=0D + elf_hash.c=0D + elf_kind.c=0D + elf_memory.c=0D + elf_ndxscn.c=0D + elf_newdata.c=0D + elf_newscn.c=0D + elf_next.c=0D + elf_nextscn.c=0D + elf_rand.c=0D + elf_rawdata.c=0D + elf_rawfile.c=0D + elf_readall.c=0D + elf_scnshndx.c=0D + elf_strptr.c=0D + elf_update.c=0D + elf_version.c=0D + elf32_checksum.c=0D + elf32_fsize.c=0D + elf32_getchdr.c=0D + elf32_getehdr.c=0D + elf32_getphdr.c=0D + elf32_getshdr.c=0D + elf32_newehdr.c=0D + elf32_newphdr.c=0D + elf32_offscn.c=0D + elf32_updatefile.c=0D + elf32_updatenull.c=0D + elf32_xlatetof.c=0D + elf32_xlatetom.c=0D + elf64_checksum.c=0D + elf64_fsize.c=0D + elf64_getchdr.c=0D + elf64_getehdr.c=0D + elf64_getphdr.c=0D + elf64_getshdr.c=0D + elf64_newehdr.c=0D + elf64_newphdr.c=0D + elf64_offscn.c=0D + elf64_updatefile.c=0D + elf64_updatenull.c=0D + elf64_xlatetof.c=0D + elf64_xlatetom.c=0D + gelf_checksum.c=0D + gelf_fsize.c=0D + gelf_getauxv.c=0D + gelf_getchdr.c=0D + gelf_getclass.c=0D + gelf_getdyn.c=0D + gelf_getehdr.c=0D + gelf_getlib.c=0D + gelf_getmove.c=0D + gelf_getnote.c=0D + gelf_getphdr.c=0D + gelf_getrel.c=0D + gelf_getrela.c=0D + gelf_getshdr.c=0D + gelf_getsym.c=0D + gelf_getsyminfo.c=0D + gelf_getsymshndx.c=0D + gelf_getverdaux.c=0D + gelf_getverdef.c=0D + gelf_getvernaux.c=0D + gelf_getverneed.c=0D + gelf_getversym.c=0D + gelf_newehdr.c=0D + gelf_newphdr.c=0D + gelf_offscn.c=0D + gelf_update_auxv.c=0D + gelf_update_dyn.c=0D + gelf_update_ehdr.c=0D + gelf_update_lib.c=0D + gelf_update_move.c=0D + gelf_update_phdr.c=0D + gelf_update_rel.c=0D + gelf_update_rela.c=0D + gelf_update_shdr.c=0D + gelf_update_sym.c=0D + gelf_update_syminfo.c=0D + gelf_update_symshndx.c=0D + gelf_update_verdaux.c=0D + gelf_update_verdef.c=0D + gelf_update_vernaux.c=0D + gelf_update_verneed.c=0D + gelf_update_versym.c=0D + gelf_xlate.c=0D + gelf_xlatetof.c=0D + gelf_xlatetom.c=0D + libelf_crc32.c=0D + libelf_next_prime.c=0D + nlist.c=0D +)=0D +if(WIN32)=0D + target_sources(=0D + elf PRIVATE=0D + ../lib/system_win32.c=0D + )=0D +endif()=0D +set(ELF_PUBLIC_HEADERS=0D + ${CMAKE_CURRENT_SOURCE_DIR}/gelf.h=0D + ${CMAKE_CURRENT_SOURCE_DIR}/libelf.h=0D + ${CMAKE_CURRENT_SOURCE_DIR}/nlist.h=0D + ${CMAKE_CURRENT_SOURCE_DIR}/elf.h=0D +)=0D +set_target_properties(=0D + elf PROPERTIES PUBLIC_HEADER=0D + "${ELF_PUBLIC_HEADERS}"=0D +)=0D +target_include_directories(=0D + elf PRIVATE=0D + ${CMAKE_CURRENT_SOURCE_DIR}/../lib=0D + ${CMAKE_CURRENT_SOURCE_DIR}/=0D + ${CMAKE_CURRENT_SOURCE_DIR}/config-cmake=0D +)=0D +target_compile_definitions(=0D + elf PRIVATE=0D + -DHAVE_CONFIG_H=0D +)=0D +if (MSVC)=0D + target_compile_definitions(=0D + elf PRIVATE=0D + -D_CRT_NONSTDC_NO_DEPRECATE=0D + -D_CRT_SECURE_NO_WARNINGS=0D + -D_CRT_SECURE_NO_WARNINGS_GLOBALS=0D + )=0D +else()=0D + target_compile_definitions(=0D + elf PRIVATE=0D + -D_FILE_OFFSET_BITS=3D64=0D + )=0D +endif()=0D +set_property(TARGET elf PROPERTY C_STANDARD 11)=0D +=0D +if (MSVC)=0D + # Enable find libz.a with msvc=0D + set(CMAKE_FIND_LIBRARY_PREFIXES "" "lib")=0D + set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".a")=0D +endif()=0D +find_package(ZLIB REQUIRED)=0D +target_link_libraries(elf ZLIB::ZLIB)=0D +=0D +find_package(Intl)=0D +if (TARGET Intl::Intl)=0D + target_link_libraries(elf Intl::Intl)=0D +else()=0D + target_compile_definitions(=0D + elf PRIVATE=0D + -DNOT_HAVE_LIBINTL=0D + )=0D +endif()=0D diff --git a/libelf/config-cmake/config.h b/libelf/config-cmake/config.h new file mode 100644 index 00000000..25f1da57 --- /dev/null +++ b/libelf/config-cmake/config.h @@ -0,0 +1,27 @@ +#ifndef _CONFIG_H_ +#define _GNU_SOURCE +#include "eu-config.h" + +#if defined(_WIN32) +#define HAVE_DECL_MEMPCPY 0 +#define HAVE_DECL_MEMRCHR 0 +#define HAVE_DECL_POWEROF2 0 +#define HAVE_DECL_MMAP 0 +#else +#define HAVE_DECL_MEMPCPY 1 +#define HAVE_DECL_MEMRCHR 1 +#define HAVE_DECL_POWEROF2 1 +#define HAVE_DECL_MMAP 1 +#endif +#define HAVE_DECL_RAWMEMCHR 0 +#define HAVE_DECL_REALLOCARRAY 1 +#define HAVE_VISIBILITY 1 + +#undef HAVE_GCC_STRUCT +#undef USE_LOCKS + +#if !defined(_MSC_VER) +#define HAVE_ERROR_H +#endif + +#endif /* _CONFIG_H_ */ \ No newline at end of file --=20 2.36.1.windows.1