Linux series explanation——[systemd] download and compilation record

The init program of Ubuntu 18.04 is merged into systemd. This article records the download and compilation of systemd.

1. Download systemd source code

(1) Check the systemd version number to determine the branch that needs to be downloaded

sun@sun-pc:~$ systemd --version
systemd 237
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN -PCRE2 default-hierarchy=hybrid

(2) As shown above, the version of systemd is 237, which corresponds to the v237 tag of the git warehouse.

sun@sun-pc:~/3rdcode$ git clone https://github.com/systemd/systemd.git --branch=v237

After the download is completed, the contents of the systemd directory are as follows:

sun@sun-pc:~/3rdcode/systemd$ ls
catalog       configure       ENVIRONMENT.md  hwdb             Makefile     meson_options.txt  modprobe.d  po       README.md  shell-completion  sysusers.d  TODO                   travis-ci     xorg
coccinelle    DISTRO_PORTING  factory         LICENSE.GPL2     man          mkosi.build        network     presets  rules      src               test        tools                  UIDS-GIDS.md
CODING_STYLE  docs            HACKING         LICENSE.LGPL2.1  meson.build  mkosi.default      NEWS        README   scripts    sysctl.d          tmpfiles.d  TRANSIENT-SETTINGS.md  units

2. Configure the compilation environment

After the systemd code is downloaded, enter the systemd directory and execute the following command

sun@sun-pc:~/3rdcode/systemd$ ./configure 
+ exec meson build
The Meson build system
Version: 0.45.1
Source dir: /home/sun/3rdcode/systemd
Build dir: /home/sun/3rdcode/systemd/build
Build type: native build
...

After configuration, you can see that the systemd directory has an additional build directory.

sun@sun-pc:~/3rdcode/systemd$ ls
build       CODING_STYLE    docs            HACKING       LICENSE.LGPL2.1  meson.build        mkosi.default  NEWS     README     scripts           sysctl.d    tmpfiles.d  TRANSIENT-SETTINGS.md  units
catalog     configure       ENVIRONMENT.md  hwdb          Makefile         meson_options.txt  modprobe.d     po       README.md  shell-completion  sysusers.d  TODO        travis-ci              xorg
coccinelle  DISTRO_PORTING  factory         LICENSE.GPL2  man              mkosi.build        network        presets  rules      src               test        tools       UIDS-GIDS.md

3. Compile systemd source code

sun@sun-pc:~/3rdcode/systemd$ make

Guess you like

Origin blog.csdn.net/In_engineer/article/details/132415230