ROOT := $(shell pwd)/linuxroot CPU := $(shell nproc) MUSL_VERSION := 1.2.4 NCURSES_VERSION := 6.4 OPENSSL_VERSION := 3.0.12 NCURSES := $(ROOT)/usr/lib/libncursesw.so MUSL := $(ROOT)/usr/include/stdio.h OPENSSL := $(ROOT)/usr/lib64/libssl.so DHCPCD := $(ROOT)/usr/sbin/dhcpcd BSDTAR := $(ROOT)/usr/bin/bsdtar ZLIB := $(ROOT)/usr/lib/libz.so TOYBOX := $(ROOT)/bin/toybox CDEV := $(ROOT)/sbin/cdev .PHONY: all clean all: ./linux.iso $(ROOT)/sbin/init: if [ ! -e svn ]; then mkdir svn ; fi if [ ! -e svn/cinit ]; then svn co http://sw.e3t.cc/sw/~nishi/cinit/trunk svn/cinit ; fi mkdir -p $(ROOT)/sbin cd svn/cinit && make STATIC=YES -j$(CPU) && cp bin/cinit $(ROOT)/sbin/init && cp bin/cshutdown $(ROOT)/sbin/shutdown $(ROOT)/bin/getty: if [ ! -e svn ]; then mkdir svn ; fi if [ ! -e svn/cgetty ]; then svn co http://sw.e3t.cc/sw/~nishi/cgetty/trunk svn/cgetty ; fi mkdir -p $(ROOT)/bin cd svn/cgetty && make STATIC=YES -j$(CPU) && cp bin/cgetty $(ROOT)/bin/getty $(ROOT)/bin/login: if [ ! -e svn ]; then mkdir svn ; fi if [ ! -e svn/clogin ]; then svn co http://sw.e3t.cc/sw/~nishi/clogin/trunk svn/clogin ; fi mkdir -p $(ROOT)/bin cd svn/clogin && make STATIC=YES -j$(CPU) && cp bin/clogin $(ROOT)/bin/login $(ROOT)/sbin/mount: if [ ! -e svn ]; then mkdir svn ; fi if [ ! -e svn/cmount ]; then svn co http://sw.e3t.cc/sw/~nishi/cmount/trunk svn/cmount ; fi mkdir -p $(ROOT)/sbin cd svn/cmount && make STATIC=YES -j$(CPU) && cp bin/cmount $(ROOT)/sbin/mount $(CDEV): if [ ! -e svn ]; then mkdir svn ; fi if [ ! -e svn/cdev ]; then svn co http://sw.e3t.cc/sw/~nishi/cdev/trunk svn/cdev ; fi mkdir -p $(ROOT)/sbin cd svn/cdev && make STATIC=YES -j$(CPU) && cp bin/cdev $(ROOT)/sbin/cdev $(ROOT)/bin/sh: if [ ! -e git ]; then mkdir git ; fi if [ ! -e git/oksh ]; then git clone https://github.com/ibara/oksh git/oksh ; fi mkdir -p $(ROOT)/bin cd git/oksh && ./configure --enable-static --disable-curses && make -j$(CPU) && cp oksh $(ROOT)/bin/sh $(ROOT)/isolinux/bzImage: mkdir -p $(ROOT)/isolinux wget -O $@ http://ftp.slackware.com/pub/slackware/slackware64-15.0/kernels/huge.s/bzImage $(MUSL): if [ ! -e "musl.tar.gz" ]; then wget -O musl.tar.gz https://musl.libc.org/releases/musl-$(MUSL_VERSION).tar.gz ; fi if [ ! -e "musl-$(MUSL_VERSION)" ]; then tar xvf musl.tar.gz ; fi mkdir -p $(ROOT)/usr/include cd musl-$(MUSL_VERSION) && ./configure --disable-doc --exec-prefix=$(ROOT)/usr --prefix=$(ROOT)/usr cd musl-$(MUSL_VERSION) && make -j$(CPU) && make install $(NCURSES): $(MUSL) if [ ! -e "ncurses.tar.gz" ]; then wget https://invisible-island.net/archives/ncurses/ncurses-$(NCURSES_VERSION).tar.gz -O ncurses.tar.gz ; fi if [ ! -e "ncurses-$(NCURSES_VERSION)" ]; then tar xvf ncurses.tar.gz ; fi mkdir -p $(ROOT)/usr/lib mkdir -p $(ROOT)/usr/share cd ncurses-$(NCURSES_VERSION) && ./configure --enable-termcap --with-shared --enable-widec --prefix=/usr && make -j$(CPU) && make install DESTDIR=$(ROOT) $(ROOT)/usr/bin/htop: $(MUSL) $(NCURSES) if [ ! -e "htop" ]; then git clone https://github.com/htop-dev/htop ; fi cd htop && ./autogen.sh && export CFLAGS="--sysroot=$(ROOT)" && export CXXFLAGS="--sysroot=$(ROOT)" export LDFLAGS="--sysroot=$(ROOT) -L$(ROOT)/usr/lib" && ./configure -exec-prefix=$(ROOT)/usr --prefix=$(ROOT)/usr && make -j$(CPU) && make install $(DHCPCD): $(MUSL) if [ ! -e "dhcpcd" ]; then git clone https://github.com/NetworkConfiguration/dhcpcd ; fi cd dhcpcd && export CFLAGS="--sysroot=$(ROOT)" && export CXXFLAGS="--sysroot=$(ROOT)" export LDFLAGS="--sysroot=$(ROOT) -L$(ROOT)/usr/lib" && ./configure --prefix=/usr --exec-prefix=/usr --etcdir=/etc --without-udev cd dhcpcd && make -j$(CPU) && make install DESTDIR=$(ROOT) $(TOYBOX): $(MUSL) if [ ! -e "toybox" ]; then git clone https://github.com/landley/toybox ; fi cd toybox && cp ../dist/toybox-config .config && LDFLAGS="-static" make toybox CC=clang -j$(CPU) && cp ./toybox $@ $(OPENSSL): $(MUSL) if [ ! -e "openssl.tar.gz" ]; then wget https://www.openssl.org/source/openssl-3.0.12.tar.gz -O openssl.tar.gz ; fi if [ ! -e "openssl-$(OPENSSL_VERSION)" ]; then tar xvf openssl.tar.gz ; fi cd openssl-$(OPENSSL_VERSION) && export CFLAGS="--sysroot=$(ROOT)" && export CXXFLAGS="--sysroot=$(ROOT)" && export LDFLAGS="--sysroot=$(ROOT) -L$(ROOT)/usr/lib" && ./config --prefix=$(ROOT)/usr --openssldir=$(ROOT)/usr && make -j$(CPU) && make install $(BSDTAR): $(MUSL) $(ZLIB) if [ ! -e "libarchive" ]; then git clone https://github.com/libarchive/libarchive ; fi cd libarchive && export CFLAGS="--sysroot=$(ROOT)" && export CXXFLAGS="--sysroot=$(ROOT)" && export LDFLAGS="--sysroot=$(ROOT) -L$(ROOT)/usr/lib" && autoreconf -fvi && ./configure --prefix=$(ROOT)/usr --exec-prefix=$(ROOT)/usr && make -j$(CPU) && make install $(ZLIB): $(MUSL) if [ ! -e "zlib" ]; then git clone https://github.com/libarchive/zlib ; fi cd zlib && export CFLAGS="--sysroot=$(ROOT)" && export CXXFLAGS="--sysroot=$(ROOT)" && export LDFLAGS="--sysroot=$(ROOT) -L$(ROOT)/usr/lib" && ./configure --prefix=$(ROOT)/usr && make -j$(CPU) && make install $(ROOT)/bin/nv: if [ ! -e "nashville" ]; then svn co http://sw.nishi.boats/sw/~nishi/nashville/trunk nashville ; fi cd nashville && make STATIC=YES -j$(CPU) && cp bin/nashville $@ $(ROOT)/usr/include/linux/mman.h: wget -O kernel-headers.txz http://ftp.slackware.com/pub/slackware/slackware64-15.0/slackware64/d/kernel-headers-5.15.19-x86-2.txz tar xvf kernel-headers.txz -C $(ROOT) rm -rf $(ROOT)/usr/include/asm cp -rf $(ROOT)/usr/include/asm-x86 $(ROOT)/usr/include/asm $(ROOT)/efiboot.img: $(ROOT)/isolinux/bzImage \ dist/refind.conf -rm $@ fallocate -l 16m $@ mkfs.msdos $@ mmd -i $@ ::EFI mmd -i $@ ::EFI/BOOT mmd -i $@ ::EFI/BOOT/ICONS mcopy -i $@ /usr/share/refind/refind_x64.efi ::EFI/BOOT/BOOTX64.EFI mcopy -i $@ dist/refind.conf ::EFI/BOOT/ convert dist/iluzja-alt.png -resize 'x600' -gravity center -extent 800x600 iluzja-600.png mcopy -i $@ iluzja-600.png ::/bg.png mcopy -i $@ /usr/share/refind/icons/* ::EFI/BOOT/ICONS/ mcopy -i $@ $(ROOT)/isolinux/bzImage ::/ $(ROOT)/usr/share/zoneinfo: if [ ! -e tzdb-2023c.tar.lz ]; then wget https://data.iana.org/time-zones/releases/tzdb-2023c.tar.lz ; fi tar xvf tzdb-2023c.tar.lz cd tzdb-2023c && make TOPDIR=$(ROOT) LDLIBS=-lintl install ./linux.iso: dist/isolinux.cfg \ dist/inittab \ dist/sysinit \ dist/issue \ dist/rc.conf \ dist/rc.subr \ dist/rc.proc \ dist/center.c \ dist/hostname \ dist/getty-wrapper \ $(ROOT)/isolinux/bzImage \ $(ROOT)/sbin/init \ $(ROOT)/bin/getty \ $(ROOT)/sbin/mount \ $(ROOT)/bin/login \ $(ROOT)/bin/getty \ $(ROOT)/bin/sh \ $(ROOT)/usr/include/linux/mman.h \ $(NCURSES) \ $(MUSL) \ $(OPENSSL) \ $(DHCPCD) \ $(BSDTAR) \ $(ZLIB) \ $(TOYBOX) \ $(CDEV) \ $(ROOT)/usr/bin/htop \ $(ROOT)/bin/nv \ $(ROOT)/efiboot.img \ $(ROOT)/usr/share/zoneinfo mkdir -p $(ROOT)/isolinux mkdir -p $(ROOT)/etc mkdir -p $(ROOT)/dev mkdir -p $(ROOT)/root mkdir -p $(ROOT)/proc mkdir -p $(ROOT)/sys mkdir -p $(ROOT)/run mkdir -p $(ROOT)/tmp mkdir -p $(ROOT)/var -useradd -R $(ROOT) -g 0 -u 0 -d /root -s /bin/sh root -groupadd -R $(ROOT) -g 0 root -echo "root:`mkpasswd root`:0::::::" > $(ROOT)/etc/shadow cp /usr/share/syslinux/isolinux.bin $(ROOT)/isolinux/ cp /usr/share/syslinux/ldlinux.c32 $(ROOT)/isolinux/ cp /usr/share/syslinux/libutil.c32 $(ROOT)/isolinux/ cp /usr/share/syslinux/libcom32.c32 $(ROOT)/isolinux/ cp /usr/share/syslinux/menu.c32 $(ROOT)/isolinux/ cp /usr/share/syslinux/vesamenu.c32 $(ROOT)/isolinux/ convert dist/iluzja.png -resize 'x480' -gravity center -extent 640x480 $(ROOT)/isolinux/iluzja-480.png cp dist/isolinux.cfg $(ROOT)/isolinux/ cp dist/inittab $(ROOT)/etc/ cp dist/sysinit $(ROOT)/etc/ cp dist/issue $(ROOT)/etc/ cp dist/hostname $(ROOT)/etc/ cp dist/rc.proc $(ROOT)/etc/ chmod +x $(ROOT)/etc/rc.proc cp dist/rc.subr $(ROOT)/etc/ chmod +x $(ROOT)/etc/rc.subr cp dist/rc.conf $(ROOT)/etc/ chmod +x $(ROOT)/etc/rc.conf cp dist/getty-wrapper $(ROOT)/bin/ chmod +x $(ROOT)/bin/getty-wrapper mkdir -p $(ROOT)/etc/init.d -cp -rf dist/init.d/* $(ROOT)/etc/init.d/ -mkdir -p $(ROOT)/etc/rcS.d -cp -rf dist/rcS.d/* $(ROOT)/etc/rcS.d/ -mkdir -p $(ROOT)/etc/rc0.d -cp -rf dist/rc0.d/* $(ROOT)/etc/rc0.d/ -mkdir -p $(ROOT)/etc/rc1.d -cp -rf dist/rc1.d/* $(ROOT)/etc/rc1.d/ -mkdir -p $(ROOT)/etc/rc2.d -cp -rf dist/rc2.d/* $(ROOT)/etc/rc2.d/ -mkdir -p $(ROOT)/etc/rc3.d -cp -rf dist/rc3.d/* $(ROOT)/etc/rc3.d/ -mkdir -p $(ROOT)/etc/rc4.d -cp -rf dist/rc4.d/* $(ROOT)/etc/rc4.d/ -mkdir -p $(ROOT)/etc/rc5.d -cp -rf dist/rc5.d/* $(ROOT)/etc/rc5.d/ -mkdir -p $(ROOT)/etc/rc6.d -cp -rf dist/rc6.d/* $(ROOT)/etc/rc6.d/ -chmod +x $(ROOT)/etc/rc?.d/* -chmod +x $(ROOT)/etc/init.d/* ln -sf /usr/lib $(ROOT)/lib ln -sf libc.so $(ROOT)/usr/lib/ld-musl-x86_64.so.1 ln -sf nv $(ROOT)/bin/cat ln -sf toybox $(ROOT)/bin/mkdir ln -sf toybox $(ROOT)/bin/rm ln -sf busybox $(ROOT)/bin/ip ln -sf nv $(ROOT)/bin/chmod gcc --sysroot=$(ROOT) -o $(ROOT)/bin/center dist/center.c chmod +x $(ROOT)/etc/sysinit -rm $@ xorriso -as mkisofs -o $@ -isohybrid-mbr /usr/share/syslinux/isohdpfx.bin -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -eltorito-platform efi -eltorito-boot efiboot.img -no-emul-boot $(ROOT) du -h $@ clean: rm -rf svn git