1 { lib, stdenv, fetchurl }:
3 # Note: this package is used for bootstrapping fetchurl, and thus
4 # cannot use fetchpatch! All mutable patches (generated by GitHub or
5 # cgit) that are needed here should be included directly in Nixpkgs as
8 stdenv.mkDerivation rec {
13 url = "mirror://gnu/m4/m4-${version}.tar.bz2";
14 sha256 = "sha256-swapHA/ZO8QoDPwumMt6s5gf91oYe+oyk4EfRSyJqMg=";
17 # https://gitweb.gentoo.org/repo/gentoo.git/tree/sys-devel/m4/m4-1.4.19-r1.ebuild
18 patches = lib.optional stdenv.hostPlatform.isLoongArch64 ./loong-fix-build.patch;
19 postPatch = if stdenv.hostPlatform.isLoongArch64 then ''
20 touch ./aclocal.m4 ./lib/config.hin ./configure ./doc/stamp-vti || die
21 find . -name Makefile.in -exec touch {} + || die
25 enableParallelBuilding = true;
29 configureFlags = [ "--with-syscmd-shell=${stdenv.shell}" ]
30 ++ lib.optional stdenv.hostPlatform.isMinGW "CFLAGS=-fno-stack-protector";
33 description = "GNU M4, a macro processor";
35 GNU M4 is an implementation of the traditional Unix macro
36 processor. It is mostly SVR4 compatible although it has some
37 extensions (for example, handling more than 9 positional
38 parameters to macros). GNU M4 also has built-in functions for
39 including files, running shell commands, doing arithmetic, etc.
41 GNU M4 is a macro processor in the sense that it copies its
42 input to the output expanding macros as it goes. Macros are
43 either builtin or user-defined and can take any number of
44 arguments. Besides just doing macro expansion, m4 has builtin
45 functions for including named files, running UNIX commands,
46 doing integer arithmetic, manipulating text in various ways,
47 recursion etc... m4 can be used either as a front-end to a
48 compiler or as a macro processor in its own right.
50 homepage = "https://www.gnu.org/software/m4/";
52 license = lib.licenses.gpl3Plus;
54 platforms = lib.platforms.unix ++ lib.platforms.windows;