8.15. M4-1.4.19

The M4 package contains a macro processor.

Approximate build time: 0.3 SBU
Required disk space: 49 MB

8.15.1. Installation of M4

Create the PKGBUILD for the M4 package with the following commands:

mkdir /sources/m4
cd /sources/m4
cat > PKGBUILD << "REALEOF"
# Maintainer: Linux From Scratch <lfs-dev@lists.linuxfromscratch.org>

pkgname="m4"
pkgver="1.4.19"
pkgrel="1"
pkgdesc="The M4 package contains a macro processor."
arch=('x86'
      'x86_64')
url="http://www.gnu.org/software/m4/"
license=('GPLv3')
groups=('core')
depends=('bash'
         'glibc')
makedepends=('binutils'
             'coreutils'
             'gcc'
             'grep'
             'make'
             'sed'
             'texinfo')
checkdepends=('diffutils')
optdepends=('libsigsegv')
source=('https://ftp.gnu.org/gnu/m4/m4-1.4.19.tar.xz')
md5sums=('0d90823e1426f1da2fd872df0311298d')

build() {
  cd "${pkgname}-${pkgver}"
  ./configure --prefix=/usr
  make
}

check() {
  cd "${pkgname}-${pkgver}"
  make check
}

package() {
  cd "${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}" install
}
REALEOF

Prepare the build directory for the pacman user and build the package:

chown -R root:pacman .
chmod 2775 .
chmod 664 PKGBUILD
su pacman -c 'makepkg -L --nodeps'

Add the newly created package to the central package repository:

cp m4-1.4.19-1-$(uname -m).pkg.tar.xz \
   /srv/pacman/repos/LFS/
repo-add /srv/pacman/repos/LFS/LFS.db.tar.xz \
         /srv/pacman/repos/LFS/m4-1.4.19-1-$(uname -m).pkg.tar.xz

Update the local cache and install the zlib package:

pacman -Syu
pacman -S m4 --overwrite \* -dd --noconfirm

Finally, copy the source files into the source repository and clean up the build directory:

mkdir /srv/pacman/source/LFS/m4
cp PKGBUILD /srv/pacman/source/LFS/m4
cd /sources
rm -rf m4

8.15.2. Contents of M4

Installed program: m4

Short Descriptions

m4

Copies the given files while expanding the macros that they contain. These macros are either built-in or user-defined and can take any number of arguments. Besides performing macro expansion, m4 has built-in functions for including named files, running Unix commands, performing integer arithmetic, manipulating text, recursion, etc. The m4 program can be used either as a front end to a compiler or as a macro processor in its own right