summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: bd72981a2de4abe3198e8cc95d57fc1f45ef0918 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# Contributor: carstene1ns <arch carsten-teibes de>
# Contributor: felix <base64 -d <<< ZmVsaXgudm9uLnNAcG9zdGVvLmRlCg==>
# Contributor: janezz55

pkgname=dosbox-gcc
pkgver=14.2.0
libmver=0.8.2
_target="i586-pc-msdosdjgpp"
_djver=2.05
pkgrel=1
pkgdesc="djgpp cross-compiler for the dosbox environment"
arch=('i686' 'x86_64')
url="http://gcc.gnu.org"
license=('GPL' 'LGPL' 'FDL' 'custom')
groups=('djgpp')
depends=('sed' 'zlib' 'libisl' 'libmpc' 'dosbox-binutils')
makedepends=('unzip' 'tar' 'xz')
optdepends=('dosbox-djcrx: headers and utilities')
options=('!strip' 'staticlibs' '!emptydirs')
source=("https://ftp.gnu.org/gnu/gcc/gcc-$pkgver/gcc-$pkgver.tar.xz"
        "ftp://www.delorie.com/pub/djgpp/current/v2/djcrx${_djver//./}.zip"
        "https://github.com/JuliaMath/openlibm/archive/refs/tags/v${libmver}.zip"
        "gcc-djgpp.diff"
        "lto.patch")
sha256sums=('SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP')
noextract=("gcc-$pkgver.tar.xz"
           "djcrx${_djver//./}.zip"
           "v${libmver}.zip")

prepare() {
  tar Jxf gcc-$pkgver.tar.xz

  # gcc hacks
  cd $srcdir/gcc-$pkgver

  # build the lto plugin
  patch -Np0 < ../lto.patch

  # Other DJGPP related changes
  patch -Np1 < ../gcc-djgpp.diff

  # extract bootstrap djcrx
  mkdir -p ../gcc-build-$_target/lib/gcc/$_target/$pkgver
  cd ../gcc-build-$_target/lib/gcc/$_target/$pkgver
  unzip -qoW "$srcdir/djcrx${_djver//./}.zip" 'include/**' 'lib/*.[oa]'
  mv lib/* .

  # fix djcrx
  cd include
  unzip -jqoW "$srcdir/v${libmver}.zip" "openlibm-${libmver}/include/**"
  rm -f math.h complex.h fenv.h libm/math.h
  ln -s openlibm_math.h math.h
  ln -s openlibm_math.h libm/math.h
  ln -s openlibm_complex.h complex.h
  ln -s openlibm_fenv.h fenv.h

  sed -i 's/\/\/typedef	__double_t	double_t/typedef	double	double_t/' math.h
  sed -i 's/\/\/typedef	__float_t	float_t/typedef	float	float_t/' math.h
}

build() {
  cd gcc-build-$_target
  CPPFLAGS="$CPPFLAGS -Ofast" \
  ../gcc-$pkgver/configure \
    --prefix=/usr \
    --libexecdir=/usr/lib \
    --datarootdir=/usr/$_target/share \
    --target="$_target" \
    --with-arch=i586 \
    --with-cpu=i586 \
    --with-isl \
    --with-system-zlib \
    --disable-gcov \
    --disable-install-libiberty \
    --disable-libssp \
    --disable-libquadmath \
    --disable-libquadmath-support \
    --disable-libgomp \
    --disable-libsanitizer \
    --disable-multilib \
    --disable-nls \
    --disable-plugin \
    --enable-compressed-debug-sections=all \
    --enable-gold=yes \
    --enable-languages=c,c++ \
    --enable-ld=no \
    --enable-lto \
    --enable-shared \
    --enable-static \
    --disable-threads \
    --disable-libstdcxx-pch \
    --disable-libstdcxx-threads \
    --enable-cxx-flags="-O3 -fno-plt" \
    --enable-libstdcxx-filesystem-ts \
    --enable-checking=release
  make all-gcc

  cd $srcdir/gcc-build-$_target
  ac_cv_func_dlopen=no \
  ac_cv_func_shl_load=no \
  ac_cv_lib_dld_shl_load=no \
  ac_cv_lib_dl_dlopen=no \
  ac_cv_lib_svld_dlopen=no \
  ac_cv_lib_dld_dld_link=no \
  make all
}

package_dosbox-gcc() {
  echo ...installing
  make -C gcc-build-$_target DESTDIR=$pkgdir/ install

  # strip manually, djgpp libs spew errors otherwise
  strip -s $pkgdir/usr/bin/$_target-* $pkgdir/usr/lib/gcc/$_target/$pkgver/{cc1*,collect2,lto*}

  # for compatibility
  ln -sf $_target-gcc $pkgdir/usr/bin/$_target-cc

  # remove unnecessary files
  rm -rf $pkgdir/usr/$_target/share/{man,info,locale,gcc-$pkgver/python}
  rm -rf $pkgdir/usr/share/{man,info,locale}
  rm -rf $pkgdir/usr/lib/gcc/$_target/$pkgver/include-fixed
  rm -f $pkgdir/usr/lib/libcc1.*
}