diff options
author | Viorel Munteanu <ceamac@gentoo.org> | 2023-11-14 08:50:17 +0200 |
---|---|---|
committer | Viorel Munteanu <ceamac@gentoo.org> | 2023-11-14 21:14:26 +0200 |
commit | 01d66eb467ccb21b5456332a77bdccbcda33ead9 (patch) | |
tree | d85e02f9bc9c88372b5e794f5a22ffe539bdeb9f /dev-embedded/sdcc | |
parent | dev-python/pycryptodome: add 3.19.0 (diff) | |
download | gentoo-01d66eb467ccb21b5456332a77bdccbcda33ead9.tar.gz gentoo-01d66eb467ccb21b5456332a77bdccbcda33ead9.tar.bz2 gentoo-01d66eb467ccb21b5456332a77bdccbcda33ead9.zip |
dev-embedded/sdcc: fix Makefile and QA issues
Closes: https://bugs.gentoo.org/917114
Closes: https://bugs.gentoo.org/898594
Signed-off-by: Viorel Munteanu <ceamac@gentoo.org>
Diffstat (limited to 'dev-embedded/sdcc')
5 files changed, 417 insertions, 0 deletions
diff --git a/dev-embedded/sdcc/files/binutils-2.41-acinclude.m4 b/dev-embedded/sdcc/files/binutils-2.41-acinclude.m4 new file mode 100644 index 000000000000..03bc955c619b --- /dev/null +++ b/dev-embedded/sdcc/files/binutils-2.41-acinclude.m4 @@ -0,0 +1,193 @@ +dnl Copyright (C) 2000-2023 Free Software Foundation, Inc. +dnl +dnl GCC is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 3, or (at your option) +dnl any later version. +dnl +dnl GCC is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with GCC; see the file COPYING3. If not see +dnl <http://www.gnu.org/licenses/>. + +dnl See whether strncmp reads past the end of its string parameters. +dnl On some versions of SunOS4 at least, strncmp reads a word at a time +dnl but erroneously reads past the end of strings. This can cause +dnl a SEGV in some cases. +AC_DEFUN([libiberty_AC_FUNC_STRNCMP], +[AC_REQUIRE([AC_FUNC_MMAP]) +AC_CACHE_CHECK([for working strncmp], ac_cv_func_strncmp_works, +[AC_TRY_RUN([ +/* Test by Jim Wilson and Kaveh Ghazi. + Check whether strncmp reads past the end of its string parameters. */ +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> + +#ifdef HAVE_FCNTL_H +#include <fcntl.h> +#endif + +#ifdef HAVE_SYS_MMAN_H +#include <sys/mman.h> +#endif + +#ifndef MAP_ANON +#ifdef MAP_ANONYMOUS +#define MAP_ANON MAP_ANONYMOUS +#else +#define MAP_ANON MAP_FILE +#endif +#endif + +#ifndef MAP_FILE +#define MAP_FILE 0 +#endif +#ifndef O_RDONLY +#define O_RDONLY 0 +#endif + +#define MAP_LEN 0x10000 + +int +main (void) +{ +#if defined(HAVE_MMAP) || defined(HAVE_MMAP_ANYWHERE) + char *p; + int dev_zero; + + dev_zero = open ("/dev/zero", O_RDONLY); + if (dev_zero < 0) + exit (1); + + p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE, + MAP_ANON|MAP_PRIVATE, dev_zero, 0); + if (p == (char *)-1) + p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE, + MAP_ANON|MAP_PRIVATE, -1, 0); + if (p == (char *)-1) + exit (2); + else + { + char *string = "__si_type_info"; + char *q = (char *) p + MAP_LEN - strlen (string) - 2; + char *r = (char *) p + 0xe; + + strcpy (q, string); + strcpy (r, string); + strncmp (r, q, 14); + } +#endif /* HAVE_MMAP || HAVE_MMAP_ANYWHERE */ + exit (0); +} +], ac_cv_func_strncmp_works=yes, ac_cv_func_strncmp_works=no, + ac_cv_func_strncmp_works=yes) +rm -f core core.* *.core]) +if test $ac_cv_func_strncmp_works = no ; then + AC_LIBOBJ([strncmp]) +fi +]) + +dnl See if errno must be declared even when <errno.h> is included. +AC_DEFUN([libiberty_AC_DECLARE_ERRNO], +[AC_CACHE_CHECK(whether errno must be declared, libiberty_cv_declare_errno, +[AC_TRY_COMPILE( +[#include <errno.h>], +[int x = errno;], +libiberty_cv_declare_errno=no, +libiberty_cv_declare_errno=yes)]) +if test $libiberty_cv_declare_errno = yes +then AC_DEFINE(NEED_DECLARATION_ERRNO, 1, + [Define if errno must be declared even when <errno.h> is included.]) +fi +]) + +dnl See whether we need a declaration for a function. +AC_DEFUN([libiberty_NEED_DECLARATION], +[AC_MSG_CHECKING([whether $1 must be declared]) +AC_CACHE_VAL(libiberty_cv_decl_needed_$1, +[AC_TRY_COMPILE([ +#include "confdefs.h" +#include <stdio.h> +#ifdef HAVE_STRING_H +#include <string.h> +#else +#ifdef HAVE_STRINGS_H +#include <strings.h> +#endif +#endif +#ifdef HAVE_STDLIB_H +#include <stdlib.h> +#endif +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif], +[char *(*pfn) = (char *(*)) $1], +libiberty_cv_decl_needed_$1=no, libiberty_cv_decl_needed_$1=yes)]) +AC_MSG_RESULT($libiberty_cv_decl_needed_$1) +if test $libiberty_cv_decl_needed_$1 = yes; then + AC_DEFINE([NEED_DECLARATION_]translit($1, [a-z], [A-Z]), 1, + [Define if $1 is not declared in system header files.]) +fi +])dnl + +# We always want a C version of alloca() compiled into libiberty, +# because native-compiler support for the real alloca is so !@#$% +# unreliable that GCC has decided to use it only when being compiled +# by GCC. This is the part of AC_FUNC_ALLOCA that calculates the +# information alloca.c needs. +AC_DEFUN([libiberty_AC_FUNC_C_ALLOCA], +[AC_CACHE_CHECK(whether alloca needs Cray hooks, ac_cv_os_cray, +[AC_EGREP_CPP(webecray, +[#if defined(CRAY) && ! defined(CRAY2) +webecray +#else +wenotbecray +#endif +], ac_cv_os_cray=yes, ac_cv_os_cray=no)]) +if test $ac_cv_os_cray = yes; then + for ac_func in _getb67 GETB67 getb67; do + AC_CHECK_FUNC($ac_func, + [AC_DEFINE_UNQUOTED(CRAY_STACKSEG_END, $ac_func, + [Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP + systems. This function is required for alloca.c support on those + systems.]) break]) + done +fi + +AC_CACHE_CHECK(stack direction for C alloca, ac_cv_c_stack_direction, +[AC_TRY_RUN([#include <stdlib.h> + +int +find_stack_direction (void) +{ + static char *addr = 0; + auto char dummy; + if (addr == 0) + { + addr = &dummy; + return find_stack_direction (); + } + else + return (&dummy > addr) ? 1 : -1; +} + +int +main (void) +{ + exit (find_stack_direction() < 0); +}], + ac_cv_c_stack_direction=1, + ac_cv_c_stack_direction=-1, + ac_cv_c_stack_direction=0)]) +AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction, + [Define if you know the direction of stack growth for your system; + otherwise it will be automatically deduced at run-time. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown]) +]) diff --git a/dev-embedded/sdcc/files/sdcc-4.3.0-autoreconf-libiberty.patch b/dev-embedded/sdcc/files/sdcc-4.3.0-autoreconf-libiberty.patch new file mode 100644 index 000000000000..7383f471ca48 --- /dev/null +++ b/dev-embedded/sdcc/files/sdcc-4.3.0-autoreconf-libiberty.patch @@ -0,0 +1,15 @@ +Most implicit function declarations left come from the included libiberty. +Add it to eautoreconf to regenerate its tests. +https://bugs.gentoo.org/898594 + +--- a/configure.ac ++++ b/configure.ac +@@ -874,7 +874,7 @@ + test $OPT_DISABLE_PACKIHX = 0 && AC_CONFIG_SUBDIRS(support/packihx) + test $OPT_DISABLE_UCSIM = 0 && AC_CONFIG_SUBDIRS(sim/ucsim) + test $OPT_DISABLE_SDCDB = 0 && AC_CONFIG_SUBDIRS(debugger/mcs51) +-test $OPT_DISABLE_SDBINUTILS = 0 && AC_CONFIG_SUBDIRS(support/sdbinutils) ++test $OPT_DISABLE_SDBINUTILS = 0 && AC_CONFIG_SUBDIRS(support/sdbinutils support/sdbinutils/libiberty) + AC_CONFIG_FILES([doc/Makefile]) + + ####test $OPT_DISABLE_AVR = 0 && AC_CONFIG_FILES([src/avr/Makefile]) diff --git a/dev-embedded/sdcc/files/sdcc-4.3.0-fix-binutils-dependency.patch b/dev-embedded/sdcc/files/sdcc-4.3.0-fix-binutils-dependency.patch new file mode 100644 index 000000000000..cae5ebe473ed --- /dev/null +++ b/dev-embedded/sdcc/files/sdcc-4.3.0-fix-binutils-dependency.patch @@ -0,0 +1,22 @@ +https://bugs.gentoo.org/917114 +https://sourceforge.net/p/sdcc/support-requests/193/ + +--- sdcc/Makefile.in ++++ sdcc/Makefile.in +@@ -98,7 +98,6 @@ + ifeq ($(OPT_DISABLE_SDBINUTILS), 0) + TARGETS += sdcc-sdbinutils + PKGS += $(SDCC_SDBINUTILS) +-SDBINUTILS_BINS = sdar$(EXEEXT) sdranlib$(EXEEXT) sdnm$(EXEEXT) sdobjcopy$(EXEEXT) + SDCC_BINUTILS = sdcc-sdbinutils + endif + +@@ -142,7 +141,7 @@ + + tini: checkconf sdcc-tini + +-sdcc-libs: ${SDCC_SDBINUTILS} ++sdcc-libs: ${SDCC_BINUTILS} + for lib in $(SDCC_LIBS); do $(MAKE) -C $$lib; done + + sdcc-cc: sdcc-libs diff --git a/dev-embedded/sdcc/files/sdcc-4.3.0-fix-mkdir-autoconf-test.patch b/dev-embedded/sdcc/files/sdcc-4.3.0-fix-mkdir-autoconf-test.patch new file mode 100644 index 000000000000..9a0be653ba28 --- /dev/null +++ b/dev-embedded/sdcc/files/sdcc-4.3.0-fix-mkdir-autoconf-test.patch @@ -0,0 +1,13 @@ +Fix implicit function declaration in configure logs: mkdir +https://bugs.gentoo.org/898594 + +--- a/support/cpp/configure.ac ++++ b/support/cpp/configure.ac +@@ -2317,6 +2317,7 @@ + ################################################################################ + + # mkdir takes a single argument on some systems. ++AC_CHECK_HEADERS([sys/stat.h]) + gcc_AC_FUNC_MKDIR_TAKES_ONE_ARG + + # File extensions diff --git a/dev-embedded/sdcc/sdcc-4.3.0-r1.ebuild b/dev-embedded/sdcc/sdcc-4.3.0-r1.ebuild new file mode 100644 index 000000000000..6bfa58b9f7e7 --- /dev/null +++ b/dev-embedded/sdcc/sdcc-4.3.0-r1.ebuild @@ -0,0 +1,174 @@ +# Copyright 1999-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit autotools + +if [[ ${PV} == "9999" ]] ; then + ESVN_REPO_URI="https://svn.code.sf.net/p/sdcc/code/trunk/sdcc" + inherit subversion +else + SRC_URI=" + https://downloads.sourceforge.net/project/${PN}/sdcc/${PV}/${PN}-src-${PV}.tar.bz2 + doc? ( https://downloads.sourceforge.net/project/${PN}/sdcc-doc/${PV}/${PN}-doc-${PV}.tar.bz2 ) + " + + KEYWORDS="~amd64 ~x86" +fi + +DESCRIPTION="Small device C compiler (for various microprocessors)" +HOMEPAGE="https://sdcc.sourceforge.net/" + +LICENSE=" + GPL-2 ZLIB + non-free? ( MicroChip-SDCC ) + packihx? ( public-domain ) +" +SLOT="0" +# in order of configure.ac's AC_DO_PORT stanzas +SDCC_PORTS=" + mcs51 + z80 z180 + r2k r2ka r3ka + sm83 + tlcs90 + ez80-z80 + z80n + ds390 ds400 + pic14 pic16 + hc08 + s08 + stm8 + pdk13 pdk14 pdk15 pdk16 + mos6502 mos65c02 +" +IUSE=" + ${SDCC_PORTS} + +boehm-gc device-lib doc non-free packihx sdcdb +sdcpp ucsim +" + +RDEPEND=" + dev-libs/boost:= + sys-libs/zlib:= + pic14? ( >=dev-embedded/gputils-0.13.7 ) + pic16? ( >=dev-embedded/gputils-0.13.7 ) + boehm-gc? ( dev-libs/boehm-gc:= ) + sdcdb? ( sys-libs/readline:0= ) + ucsim? ( sys-libs/ncurses:= ) +" +DEPEND=" + ${RDEPEND} + dev-util/gperf +" +PATCHES=( + "${FILESDIR}"/sdcc-4.3.2-override-override.patch + "${FILESDIR}"/sdcc-4.2.0-link-tinfo.patch + "${FILESDIR}"/${P}-fix-binutils-dependency.patch + "${FILESDIR}"/${P}-fix-mkdir-autoconf-test.patch + "${FILESDIR}"/${P}-autoreconf-libiberty.patch +) + +src_prepare() { + # Fix conflicting variable names between Gentoo and sdcc + find device/lib/pic{14,16} device/non-free/lib/pic{14,16} \( \ + -name 'configure.ac' -o -name 'Makefile.*' \) \ + -exec sed -i 's/\<ARCH\>/SDCC_&/g' {} + || die + find device -name 'Makefile.in' \ + -exec sed -i 's/\<PORTDIR\>/SDCC_&/g' {} + || die + # Possible alternative: Patch the following files to not pick up the + # variables from the environment: + # - lib/Makefile.in (PORTDIR ifndef/endif) + # - device/non-free/lib/pic14/Makefile.common.in (ARCH ?= 877) + # - device/non-free/lib/pic16/configure.ac (${ARCH:-18f452}) + # - device/lib/pic14/configure.ac (${ARCH:-16f877}) + # - device/lib/pic16/configure.ac (${ARCH:-18f452}) + + # Make sure timestamps don't get messed up. + [[ ${PV} == "9999" ]] && find "${S}" -type f -exec touch -r . {} + + + mkdir -p support/sdbinutils/bfd/doc || die + + # add acinclude.m4 from binutils to run autoreconf for libiberty + cp "${FILESDIR}"/binutils-2.41-acinclude.m4 support/sdbinutils/libiberty/acinclude.m4 || die + # libiberty configure will check this file and fail if not found + cp install-sh support/sdbinutils/libiberty/ || die + # libiberty configure will fail if this was not set + export libiberty_topdir="${S}"/support/sdbinutils/libiberty + + default + eautoreconf + + # Avoid 'bfd.info' rebuild with 'makeinfo': bug #705424 + # Build dependencies are: eautoreconf->Makefile.in->bfdver.texi->bfd.info + touch support/sdbinutils/bfd/doc/bfdver.texi || die + touch support/sdbinutils/bfd/doc/bfd.info || die +} + +src_configure() { + local myeconfargs=( + ac_cv_prog_STRIP=true + --without-ccache + --enable-sdbinutils + + $(use_enable ucsim) + $(use_enable device-lib) + $(use_enable packihx) + $(use_enable sdcpp) + $(use_enable sdcdb) + $(use_enable non-free) + $(use_enable boehm-gc libgc) + + $(use_enable mcs51 mcs51-port) + $(use_enable z80 z80-port) + $(use_enable z180 z180-port) + $(use_enable r2k r2k-port) + $(use_enable r2ka r2ka-port) + $(use_enable r3ka r3ka-port) + $(use_enable sm83 sm83-port) + $(use_enable tlcs90 tlcs90-port) + $(use_enable ez80-z80 ez80_z80-port) + $(use_enable z80n z80n-port) + $(use_enable ds390 ds390-port) + $(use_enable ds400 ds400-port) + $(use_enable pic14 pic14-port) + $(use_enable pic16 pic16-port) + $(use_enable hc08 hc08-port) + $(use_enable s08 s08-port) + $(use_enable stm8 stm8-port) + $(use_enable pdk13 pdk13-port) + $(use_enable pdk14 pdk14-port) + $(use_enable pdk15 pdk15-port) + $(use_enable pdk16 pdk16-port) + $(use_enable mos6502 mos6502-port) + $(use_enable mos65c02 mos65c02-port) + ) + econf "${myeconfargs[@]}" + + # this does not build: https://sourceforge.net/p/sdcc/bugs/3673/ + # disable for now + rm device/lib/mos65c02/Makefile || die +} + +src_compile() { + default + + # Sanity check, as gputils errors/segfaults don't cause make to stop + local libs=() + use pic14 && libs+=( device/lib/build/pic14/libsdcc.lib ) + use pic16 && libs+=( device/lib/build/pic16/libsdcc.lib ) + for lib in "${libs[@]}"; do + [[ -f "${lib}" ]] || die "Failed to build ${lib}" + done +} + +src_install() { + default + dodoc doc/*.txt + find "${ED}" -type d -name .deps -exec rm -vr {} + || die + + if use doc && [[ ${PV} != "9999" ]]; then + cd "${WORKDIR}"/doc + dodoc -r * + fi +} |