portage-overlay

personal portage ebuild repository
git clone anongit@rnpnr.xyz:portage-overlay.git
Log | Files | Refs | Feed | README

tcc-0.9.28_p20230917.ebuild (2195B)


      1 # Copyright 1999-2023 Gentoo Authors
      2 # Distributed under the terms of the GNU General Public License v2
      3 
      4 EAPI=8
      5 
      6 inherit toolchain-funcs
      7 
      8 MY_COMMIT="507fbacabdc91f5d138c1c992e7c9ad39277bc47"
      9 DESCRIPTION="A very small C compiler for ix86/amd64"
     10 HOMEPAGE="https://bellard.org/tcc/ https://repo.or.cz/tinycc.git/"
     11 
     12 if [[ ${PV} == *9999* ]]; then
     13 	EGIT_REPO_URI="https://repo.or.cz/r/tinycc.git"
     14 	inherit git-r3
     15 elif [[ ${PV} == *_p* ]] ; then
     16 	SRC_URI="https://repo.or.cz/tinycc.git/snapshot/${MY_COMMIT}.tar.gz -> ${P}.tar.gz"
     17 	S="${WORKDIR}"/tinycc-507fbac
     18 else
     19 	SRC_URI="https://download.savannah.gnu.org/releases/tinycc/${P}.tar.bz2"
     20 fi
     21 
     22 LICENSE="LGPL-2.1"
     23 SLOT="0"
     24 if [[ ${PV} != *9999* ]] ; then
     25 	KEYWORDS="~amd64 ~arm64 ~riscv ~x86 ~amd64-linux"
     26 fi
     27 
     28 BDEPEND="dev-lang/perl" # doc generation
     29 IUSE="+static test"
     30 RESTRICT="!test? ( test )"
     31 
     32 src_prepare() {
     33 	default
     34 
     35 	# Don't strip
     36 	sed -i \
     37 		-e 's|$(INSTALL) -s|$(INSTALL)|' \
     38 		-e 's|STRIP_yes = -s|STRIP_yes =|' \
     39 		Makefile || die
     40 
     41 	# Fix examples
     42 	sed -i -e '1{
     43 		i#! /usr/bin/tcc -run
     44 		/^#!/d
     45 	}' examples/ex*.c || die
     46 	sed -i -e '1s/$/ -lX11/' examples/ex4.c || die
     47 
     48 	# bug 888115
     49 	sed -i -e "s|/usr/local/bin/tcc|/usr/bin/tcc|g" tcc-doc.texi || die
     50 
     51 	# Fix texi2html invocation
     52 	sed -i -e 's/-number//' Makefile || die
     53 	sed -i -e 's/--sections//' Makefile || die
     54 }
     55 
     56 src_configure() {
     57 	local libc
     58 
     59 	use test && unset CFLAGS LDFLAGS # Tests run with CC=tcc etc, they will fail hard otherwise
     60 					# better fixes welcome, it feels wrong to hack the env like this
     61 
     62 	use elibc_musl && libc=musl
     63 
     64 	if use static; then
     65 		LDFLAGS="${LDFLAGS} -static"
     66 	fi
     67 
     68 	# not autotools, so call configure directly
     69 	./configure --cc="$(tc-getCC)" \
     70 		$(use_enable static) \
     71 		${libc:+--config-${libc}} \
     72 		--prefix="${EPREFIX}/usr" \
     73 		--libdir="${EPREFIX}/usr/$(get_libdir)" \
     74 		--docdir="${EPREFIX}/usr/share/doc/${PF}"
     75 }
     76 
     77 src_compile() {
     78 	emake AR="$(tc-getAR)" LDFLAGS="${LDFLAGS}"
     79 }
     80 
     81 src_test() {
     82 	# this is using tcc bits that don't know as-needed etc.
     83 	TCCFLAGS="" emake test
     84 }
     85 
     86 src_install() {
     87 	emake DESTDIR="${D}" install
     88 
     89 	dodoc Changelog README TODO VERSION
     90 	#dohtml tcc-doc.html
     91 	exeinto /usr/share/doc/${PF}/examples
     92 	doexe examples/ex*.c
     93 }