1{ lib, stdenv, fetchurl
2, fetchpatch
3, xorgproto, libX11, bison, ksh, perl, gnum4
4, libXinerama, libXt, libXext, libtirpc, motif, libXft, xbitmaps
5, libjpeg, libXmu, libXdmcp, libXScrnSaver, symlinkJoin, bdftopcf
6, ncompress, mkfontdir, tcl-8_5, libXaw, libxcrypt, gcc, glibcLocales
7, autoPatchelfHook, libredirect, makeWrapper, xset, xrdb, fakeroot
8, rpcsvc-proto }:
9
10let
11 x11ProjectRoot = symlinkJoin {
12 name = "x11ProjectRoot";
13 paths = [
14 bdftopcf mkfontdir
15 xset # fonts
16 xrdb # session load
17 ];
18 };
19in stdenv.mkDerivation rec {
20 version = "2.3.2";
21 pname = "cde";
22
23 src = fetchurl {
24 url = "mirror://sourceforge/cdesktopenv/cde-${version}.tar.gz";
25 sha256 = "029rljhi5r483x8rzdpl8625z0wx8r7k2m0364nbw66h5pig9lbx";
26 };
27
28 # remove with next release
29 patches = [
30 ./2.3.2.patch
31 ./0001-all-remove-deprecated-sys_errlist-and-replace-with-A.patch
32
33 (fetchpatch {
34 name = "binutils-2.36.patch";
35 url = "https://github.com/cdesktopenv/cde/commit/0b7849e210a99a413ddeb52a0eb5aef9a08504a0.patch";
36 sha256 = "0wlhs617hws3rwln9v74y1nw27n3pp7jkpnxlala7k5y64506ipj";
37 stripLen = 1;
38 })
39 ];
40
41 buildInputs = [
42 libX11 libXinerama libXt libXext libtirpc motif libXft xbitmaps
43 libjpeg libXmu libXdmcp libXScrnSaver tcl-8_5 libXaw ksh libxcrypt
44 ];
45 nativeBuildInputs = [
46 bison ncompress autoPatchelfHook makeWrapper fakeroot
47 rpcsvc-proto
48 ];
49 # build fails otherwise
50 enableParallelBuilding = false;
51
52 # Workaround build failure on -fno-common toolchains:
53 # ld: raima/startup.o:/build/cde-2.3.2/lib/DtSearch/raima/dbtype.h:408: multiple definition of
54 # `__SK__'; raima/alloc.o:/build/cde-2.3.2/lib/DtSearch/raima/dbtype.h:408: first defined here
55 env.NIX_CFLAGS_COMPILE = "-fcommon";
56
57 makeFlags = [
58 "World"
59 "BOOTSTRAPCFLAGS=-I${xorgproto}/include/X11"
60 "IMAKECPP=cpp"
61 "LOCALE_ARCHIVE=${glibcLocales}/lib/locale/locale-archive"
62 # Workaround for dtdocbook issue with tcl 8.6.13.
63 # TODO: this might be possible to remove when updating CDE
64 "TCLLIB=-ltcl8.5"
65 ];
66
67 preConfigure = ''
68 # binutils 2.37 fix
69 fixupList=(
70 "config/cf/Imake.tmpl"
71 "config/util/crayar.sh"
72 "config/util/crayar.sh"
73 "programs/dtwm/Makefile.tmpl"
74 )
75 for toFix in "''${fixupList[@]}"; do
76 substituteInPlace "$toFix" --replace "clq" "cq"
77 done
78 '';
79
80 preBuild = ''
81 while IFS= read -r -d ''$'\0' i; do
82 substituteInPlace "$i" --replace /usr/dt $out/opt/dt
83 done < <(find "." -type f -exec grep -Iq /usr/dt {} \; -and -print0)
84
85 cat >> config/cf/site.def << EOF
86#define MakeFlagsToShellFlags(makeflags,shellcmd) set -e
87#define KornShell ${ksh}/bin/ksh
88#define PerlCmd ${perl}/bin/perl
89#define M4Cmd ${gnum4}/bin/m4
90#define X11ProjectRoot ${x11ProjectRoot}
91#define CppCmd ${gcc}/bin/cpp
92TIRPCINC = -I${libtirpc.dev}/include/tirpc
93EOF
94
95 patchShebangs .
96 unset AR
97 '';
98
99 installPhase = ''
100 fakeroot admin/IntegTools/dbTools/installCDE -s . -DontRunScripts
101
102 mkdir -p $out/bin
103 mv $out/opt/dt/bin/dtmail $out/bin
104 '';
105
106 meta = with lib; {
107 description = "Common Desktop Environment";
108 homepage = "https://sourceforge.net/projects/cdesktopenv/";
109 license = licenses.lgpl2;
110 maintainers = [ ];
111 platforms = [ "i686-linux" "x86_64-linux" ];
112 };
113}