nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 204 lines 4.8 kB view raw
1{ 2 lib, 3 fetchurl, 4 kaem, 5 tinycc, 6 gnupatch, 7}: 8let 9 pname = "gnumake"; 10 version = "4.4.1"; 11 12 src = fetchurl { 13 url = "mirror://gnu/make/make-${version}.tar.gz"; 14 sha256 = "1cwgcmwdn7gqn5da2ia91gkyiqs9birr10sy5ykpkaxzcwfzn5nx"; 15 }; 16 17 patches = [ 18 # Replaces /bin/sh with sh, see patch file for reasoning 19 ./0001-No-impure-bin-sh.patch 20 # Purity: don't look for library dependencies (of the form `-lfoo') in /lib 21 # and /usr/lib. It's a stupid feature anyway. Likewise, when searching for 22 # included Makefiles, don't look in /usr/include and friends. 23 ./0002-remove-impure-dirs.patch 24 # Fixes for tinycc. See comments in patch file for reasoning 25 ./0003-tinycc-support.patch 26 ]; 27 28 CFLAGS = [ 29 "-I./src" 30 "-I./lib" 31 "-DHAVE_CONFIG_H" 32 "-DMAKE_MAINTAINER_MODE" 33 "-DLIBDIR=\\\"${placeholder "out"}/lib\\\"" 34 "-DLOCALEDIR=\\\"/fake-locale\\\"" 35 "-DPOSIX=1" 36 # mes-libc doesn't implement osync_* methods 37 "-DNO_OUTPUT_SYNC=1" 38 # mes-libc doesn't define O_TMPFILE 39 "-DO_TMPFILE=020000000" 40 ] 41 ++ config; 42 43 /* 44 Maintenance notes: 45 46 Generated by 47 ./configure \ 48 --build i686-pc-linux-gnu \ 49 --host i686-pc-linux-gnu \ 50 CC="${tinycc.compiler}/bin/tcc -B ${tinycc.libs}/lib" \ 51 ac_cv_func_dup=no 52 - `ac_cv_func_dup` disabled as mes-libc doesn't implement tmpfile() 53 54 The output src/config.h was then manually filtered, removing definitions that 55 didn't have uses in the source code 56 */ 57 config = [ 58 "-DFILE_TIMESTAMP_HI_RES=0" 59 "-DHAVE_ALLOCA" 60 "-DHAVE_ALLOCA_H" 61 "-DHAVE_ATEXIT" 62 "-DHAVE_DECL_BSD_SIGNAL=0" 63 "-DHAVE_DECL_GETLOADAVG=0" 64 "-DHAVE_DECL_SYS_SIGLIST=0" 65 "-DHAVE_DECL__SYS_SIGLIST=0" 66 "-DHAVE_DECL___SYS_SIGLIST=0" 67 "-DHAVE_DIRENT_H" 68 "-DHAVE_DUP2" 69 "-DHAVE_FCNTL_H" 70 "-DHAVE_FDOPEN" 71 "-DHAVE_GETCWD" 72 "-DHAVE_GETTIMEOFDAY" 73 "-DHAVE_INTTYPES_H" 74 "-DHAVE_ISATTY" 75 "-DHAVE_LIMITS_H" 76 "-DHAVE_LOCALE_H" 77 "-DHAVE_MEMORY_H" 78 "-DHAVE_MKTEMP" 79 "-DHAVE_SA_RESTART" 80 "-DHAVE_SETVBUF" 81 "-DHAVE_SIGACTION" 82 "-DHAVE_SIGSETMASK" 83 "-DHAVE_STDINT_H" 84 "-DHAVE_STDLIB_H" 85 "-DHAVE_STRDUP" 86 "-DHAVE_STRERROR" 87 "-DHAVE_STRINGS_H" 88 "-DHAVE_STRING_H" 89 "-DHAVE_STRTOLL" 90 "-DHAVE_SYS_FILE_H" 91 "-DHAVE_SYS_PARAM_H" 92 "-DHAVE_SYS_RESOURCE_H" 93 "-DHAVE_SYS_SELECT_H" 94 "-DHAVE_SYS_STAT_H" 95 "-DHAVE_SYS_TIMEB_H" 96 "-DHAVE_SYS_TIME_H" 97 "-DHAVE_SYS_WAIT_H" 98 "-DHAVE_TTYNAME" 99 "-DHAVE_UMASK" 100 "-DHAVE_UNISTD_H" 101 "-DHAVE_WAITPID" 102 "-DMAKE_JOBSERVER" 103 "-DMAKE_SYMLINKS" 104 "-DPATH_SEPARATOR_CHAR=':'" 105 "-DSCCS_GET=\\\"get\\\"" 106 "-DSTDC_HEADERS" 107 "-Dsig_atomic_t=int" 108 "-Dvfork=fork" 109 ]; 110 111 # Maintenance note: list of source files derived from Basic.mk 112 make_SOURCES = [ 113 "src/ar.c" 114 "src/arscan.c" 115 "src/commands.c" 116 "src/default.c" 117 "src/dir.c" 118 "src/expand.c" 119 "src/file.c" 120 "src/function.c" 121 "src/getopt.c" 122 "src/getopt1.c" 123 "src/guile.c" 124 "src/hash.c" 125 "src/implicit.c" 126 "src/job.c" 127 "src/load.c" 128 "src/loadapi.c" 129 "src/main.c" 130 "src/misc.c" 131 "src/output.c" 132 "src/read.c" 133 "src/remake.c" 134 "src/rule.c" 135 "src/shuffle.c" 136 "src/signame.c" 137 "src/strcache.c" 138 "src/variable.c" 139 "src/version.c" 140 "src/vpath.c" 141 ]; 142 glob_SOURCES = [ 143 "lib/fnmatch.c" 144 "lib/glob.c" 145 ]; 146 remote_SOURCES = [ "src/remote-stub.c" ]; 147 sources = 148 make_SOURCES 149 ++ glob_SOURCES 150 ++ remote_SOURCES 151 ++ [ 152 "src/posixos.c" 153 ]; 154 155 objects = map (x: lib.replaceStrings [ ".c" ] [ ".o" ] (builtins.baseNameOf x)) sources; 156in 157kaem.runCommand "${pname}-${version}" 158 { 159 inherit pname version; 160 161 nativeBuildInputs = [ 162 tinycc.compiler 163 gnupatch 164 ]; 165 166 meta = with lib; { 167 description = "Tool to control the generation of non-source files from sources"; 168 homepage = "https://www.gnu.org/software/make"; 169 license = licenses.gpl3Plus; 170 teams = [ teams.minimal-bootstrap ]; 171 mainProgram = "make"; 172 platforms = platforms.unix; 173 }; 174 } 175 '' 176 # Unpack 177 ungz --file ${src} --output make.tar 178 untar --file make.tar 179 rm make.tar 180 cd make-${version} 181 182 # Patch 183 ${lib.concatMapStringsSep "\n" (f: "patch -Np1 -i ${f}") patches} 184 185 # Configure 186 catm src/config.h src/mkconfig.h src/mkcustom.h 187 cp lib/glob.in.h lib/glob.h 188 cp lib/fnmatch.in.h lib/fnmatch.h 189 190 # Compile 191 alias CC="tcc -B ${tinycc.libs}/lib ${lib.concatStringsSep " " CFLAGS}" 192 ${lib.concatMapStringsSep "\n" (f: "CC -c ${f}") sources} 193 194 # Link 195 CC -o make ${lib.concatStringsSep " " objects} 196 197 # Check 198 ./make --version 199 200 # Install 201 mkdir -p ''${out}/bin 202 cp ./make ''${out}/bin 203 chmod 555 ''${out}/bin/make 204 ''