Move Make rules to separate files

This commit is contained in:
Alex Kotov 2022-12-06 11:37:02 +04:00
parent deb30d6800
commit 9cb89c0ca3
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
4 changed files with 94 additions and 93 deletions

View File

@ -13,102 +13,12 @@ DEST_LIBS = \
all: fhs $(DEST_BINS) $(DEST_CONFIGS) $(DEST_HEADERS) $(DEST_LIBS)
fhs:
install -d dest/bin
install -d dest/boot
install -d dest/dev
install -d dest/etc
install -d dest/etc/opt
install -d dest/home
install -d dest/lib
install -d dest/media
install -d dest/mnt
install -d dest/opt
install -d dest/root
install -d dest/run
install -d dest/sbin
install -d dest/srv
install -d dest/tmp
install -d dest/usr
install -d dest/usr/bin
install -d dest/usr/games
install -d dest/usr/include
install -d dest/usr/lib
install -d dest/usr/libexec
install -d dest/usr/local
install -d dest/usr/local/bin
install -d dest/usr/local/etc
install -d dest/usr/local/games
install -d dest/usr/local/include
install -d dest/usr/local/lib
install -d dest/usr/local/man
install -d dest/usr/local/sbin
install -d dest/usr/local/share
install -d dest/usr/local/src
install -d dest/usr/sbin
install -d dest/usr/share
install -d dest/usr/share/man
install -d dest/usr/share/misc
install -d dest/usr/src
install -d dest/var
install -d dest/var/cache
install -d dest/var/lib
install -d dest/var/lib/misc
install -d dest/var/local
install -d dest/var/lock
install -d dest/var/log
install -d dest/var/mail
install -d dest/var/opt
install -d dest/var/spool
install -d dest/var/tmp
dest/bin/busybox: build/busybox/busybox
$(MAKE) -C build/busybox install
include make/busybox.mk
include make/fhs.mk
include make/libkernaux.mk
dest/etc/hosts: etc/hosts fhs
install -m 644 etc/hosts dest/etc/hosts
dest/etc/shells: etc/shells fhs
install -m 644 etc/shells dest/etc/shells
dest/usr/include/kernaux.h: build/libkernaux/main/Makefile
$(MAKE) -C build/libkernaux/main DESTDIR='$(ABS_DEST)' install-data
dest/usr/lib/libkernaux.la: build/libkernaux/main/Makefile
$(MAKE) -C build/libkernaux/main DESTDIR='$(ABS_DEST)' install-exec
build/busybox/.config:
mkdir -p build/busybox
$(MAKE) -C build/busybox -f $(ABS_REPO)/vendor/busybox/Makefile KBUILD_SRC=$(ABS_REPO)/vendor/busybox defconfig
cp build/busybox/.config build/busybox/.config.bak
sed -i 's!^#* *CONFIG_PREFIX[^_].*$$!CONFIG_PREFIX="$(ABS_REPO)/dest"!' build/busybox/.config
sed -i 's!^#* *CONFIG_STATIC[^_].*$$!CONFIG_STATIC=y!' build/busybox/.config
sed -i 's!^#* *CONFIG_WERROR[^_].*$$!CONFIG_WERROR=n!' build/busybox/.config
# It's for Linux
sed -i 's!^#* *CONFIG_DEPMOD[^_].*$$!CONFIG_DEPMOD=n!' build/busybox/.config
sed -i 's!^#* *CONFIG_INSMOD[^_].*$$!CONFIG_INSMOD=n!' build/busybox/.config
sed -i 's!^#* *CONFIG_LINUXRC[^_].*$$!CONFIG_LINUXRC=n!' build/busybox/.config
sed -i 's!^#* *CONFIG_LSMOD[^_].*$$!CONFIG_LSMOD=n!' build/busybox/.config
sed -i 's!^#* *CONFIG_MODINFO[^_].*$$!CONFIG_MODINFO=n!' build/busybox/.config
sed -i 's!^#* *CONFIG_MODPROBE[^_].*$$!CONFIG_MODPROBE=n!' build/busybox/.config
sed -i 's!^#* *CONFIG_SELINUX[^_].*$$!CONFIG_SELINUX=n!' build/busybox/.config
sed -i 's!^#* *CONFIG_SELINUXENABLED[^_].*$$!CONFIG_SELINUXENABLED=n!' build/busybox/.config
# Unnecessary programs
sed -i 's!^#* *CONFIG_HUSH[^_].*$$!CONFIG_HUSH=n!' build/busybox/.config
# https://wiki.musl-libc.org/building-busybox.html
sed -i 's!^#* *CONFIG_EXTRA_COMPAT[^_].*$$!CONFIG_EXTRA_COMPAT=n!' build/busybox/.config
sed -i 's!^#* *CONFIG_FEATURE_INETD_RPC[^_].*$$!CONFIG_FEATURE_INETD_RPC=n!' build/busybox/.config
sed -i 's!^#* *CONFIG_FEATURE_MOUNT_NFS[^_].*$$!CONFIG_FEATURE_MOUNT_NFS=n!' build/busybox/.config
sed -i 's!^#* *CONFIG_FEATURE_VI_REGEX_SEARCH[^_].*$$!CONFIG_FEATURE_VI_REGEX_SEARCH=n!' build/busybox/.config
sed -i 's!^#* *CONFIG_IFPLUGD[^_].*$$!CONFIG_IFPLUGD=n!' build/busybox/.config
sed -i 's!^#* *CONFIG_PAM[^_].*$$!CONFIG_PAM=n!' build/busybox/.config
build/busybox/busybox: build/busybox/.config
$(MAKE) -C build/busybox
build/libkernaux/main/Makefile: vendor/libkernaux/configure
mkdir -p build/libkernaux/main
cd build/libkernaux/main && '../../../vendor/libkernaux/configure' --prefix=/usr
vendor/libkernaux/configure:
cd vendor/libkernaux && ./autogen.sh

31
make/busybox.mk Normal file
View File

@ -0,0 +1,31 @@
dest/bin/busybox: build/busybox/busybox
$(MAKE) -C build/busybox install
build/busybox/busybox: build/busybox/.config
$(MAKE) -C build/busybox
build/busybox/.config:
mkdir -p build/busybox
$(MAKE) -C build/busybox -f $(ABS_REPO)/vendor/busybox/Makefile KBUILD_SRC=$(ABS_REPO)/vendor/busybox defconfig
cp build/busybox/.config build/busybox/.config.bak
sed -i 's!^#* *CONFIG_PREFIX[^_].*$$!CONFIG_PREFIX="$(ABS_REPO)/dest"!' build/busybox/.config
sed -i 's!^#* *CONFIG_STATIC[^_].*$$!CONFIG_STATIC=y!' build/busybox/.config
sed -i 's!^#* *CONFIG_WERROR[^_].*$$!CONFIG_WERROR=n!' build/busybox/.config
# It's for Linux
sed -i 's!^#* *CONFIG_DEPMOD[^_].*$$!CONFIG_DEPMOD=n!' build/busybox/.config
sed -i 's!^#* *CONFIG_INSMOD[^_].*$$!CONFIG_INSMOD=n!' build/busybox/.config
sed -i 's!^#* *CONFIG_LINUXRC[^_].*$$!CONFIG_LINUXRC=n!' build/busybox/.config
sed -i 's!^#* *CONFIG_LSMOD[^_].*$$!CONFIG_LSMOD=n!' build/busybox/.config
sed -i 's!^#* *CONFIG_MODINFO[^_].*$$!CONFIG_MODINFO=n!' build/busybox/.config
sed -i 's!^#* *CONFIG_MODPROBE[^_].*$$!CONFIG_MODPROBE=n!' build/busybox/.config
sed -i 's!^#* *CONFIG_SELINUX[^_].*$$!CONFIG_SELINUX=n!' build/busybox/.config
sed -i 's!^#* *CONFIG_SELINUXENABLED[^_].*$$!CONFIG_SELINUXENABLED=n!' build/busybox/.config
# Unnecessary programs
sed -i 's!^#* *CONFIG_HUSH[^_].*$$!CONFIG_HUSH=n!' build/busybox/.config
# https://wiki.musl-libc.org/building-busybox.html
sed -i 's!^#* *CONFIG_EXTRA_COMPAT[^_].*$$!CONFIG_EXTRA_COMPAT=n!' build/busybox/.config
sed -i 's!^#* *CONFIG_FEATURE_INETD_RPC[^_].*$$!CONFIG_FEATURE_INETD_RPC=n!' build/busybox/.config
sed -i 's!^#* *CONFIG_FEATURE_MOUNT_NFS[^_].*$$!CONFIG_FEATURE_MOUNT_NFS=n!' build/busybox/.config
sed -i 's!^#* *CONFIG_FEATURE_VI_REGEX_SEARCH[^_].*$$!CONFIG_FEATURE_VI_REGEX_SEARCH=n!' build/busybox/.config
sed -i 's!^#* *CONFIG_IFPLUGD[^_].*$$!CONFIG_IFPLUGD=n!' build/busybox/.config
sed -i 's!^#* *CONFIG_PAM[^_].*$$!CONFIG_PAM=n!' build/busybox/.config

48
make/fhs.mk Normal file
View File

@ -0,0 +1,48 @@
fhs:
install -d dest/bin
install -d dest/boot
install -d dest/dev
install -d dest/etc
install -d dest/etc/opt
install -d dest/home
install -d dest/lib
install -d dest/media
install -d dest/mnt
install -d dest/opt
install -d dest/root
install -d dest/run
install -d dest/sbin
install -d dest/srv
install -d dest/tmp
install -d dest/usr
install -d dest/usr/bin
install -d dest/usr/games
install -d dest/usr/include
install -d dest/usr/lib
install -d dest/usr/libexec
install -d dest/usr/local
install -d dest/usr/local/bin
install -d dest/usr/local/etc
install -d dest/usr/local/games
install -d dest/usr/local/include
install -d dest/usr/local/lib
install -d dest/usr/local/man
install -d dest/usr/local/sbin
install -d dest/usr/local/share
install -d dest/usr/local/src
install -d dest/usr/sbin
install -d dest/usr/share
install -d dest/usr/share/man
install -d dest/usr/share/misc
install -d dest/usr/src
install -d dest/var
install -d dest/var/cache
install -d dest/var/lib
install -d dest/var/lib/misc
install -d dest/var/local
install -d dest/var/lock
install -d dest/var/log
install -d dest/var/mail
install -d dest/var/opt
install -d dest/var/spool
install -d dest/var/tmp

12
make/libkernaux.mk Normal file
View File

@ -0,0 +1,12 @@
dest/usr/include/kernaux.h: build/libkernaux/main/Makefile
$(MAKE) -C build/libkernaux/main DESTDIR='$(ABS_DEST)' install-data
dest/usr/lib/libkernaux.la: build/libkernaux/main/Makefile
$(MAKE) -C build/libkernaux/main DESTDIR='$(ABS_DEST)' install-exec
build/libkernaux/main/Makefile: vendor/libkernaux/configure
mkdir -p build/libkernaux/main
cd build/libkernaux/main && '../../../vendor/libkernaux/configure' --prefix=/usr
vendor/libkernaux/configure:
cd vendor/libkernaux && ./autogen.sh