2018-03-03 14:57:43 +03:00
APPS = init hello sh ls terminal uname compositor drawlines background session kdebug cat yutani-test sysinfo hostname yutani-query env mount date echo nyancat kill ps pstree bim
2018-02-25 08:13:54 +03:00
CC = i686-pc-toaru-gcc
AR = i686-pc-toaru-ar
2018-03-03 14:54:35 +03:00
CFLAGS = -nodefaultlibs -O3 -m32 -Wa,--32 -g -std= c99 -I. -Iapps -isystem include -Lbase/lib
2018-02-25 08:13:54 +03:00
LIBS = -lnihc -lgcc
LIBC_OBJS = $( patsubst %.c,%.o,$( wildcard libc/*.c) )
APPS_X = $( foreach app,$( APPS) ,base/bin/$( app) )
all : image .iso
base/dev :
mkdir -p base/dev
base/tmp :
mkdir -p base/tmp
base/proc :
mkdir -p base/proc
base/bin :
mkdir -p base/bin
base/lib :
mkdir -p base/lib
dirs : base /dev base /tmp base /proc base /bin base /lib
libc/%.o : libc /%.c
$( CC) -fPIC -c -m32 -Wa,--32 -O3 -isystem include -o $@ $<
2018-02-26 05:42:54 +03:00
base/lib/ld.so : linker /linker .c base /lib /libnihc .a | dirs
2018-02-25 08:13:54 +03:00
$( CC) -static -Wl,-static $( CFLAGS) -o $@ -Os -T linker/link.ld $< $( LIBS)
2018-02-26 05:42:54 +03:00
base/lib/libnihc.a : ${LIBC_OBJS } | dirs
2018-02-25 08:13:54 +03:00
$( AR) cr $@ $^
2018-02-26 05:42:54 +03:00
base/lib/libnihc.so : ${LIBC_OBJS } | dirs
2018-02-25 08:13:54 +03:00
$( CC) -o $@ $( CFLAGS) -shared -fPIC $^
base/lib/libtoaru_graphics.so : lib /graphics .c lib /graphics .h
$( CC) -o $@ $( CFLAGS) -shared -fPIC $<
base/lib/libtoaru_list.so : lib /list .c lib /list .h
$( CC) -o $@ $( CFLAGS) -shared -fPIC $<
2018-02-25 12:25:05 +03:00
base/lib/libtoaru_tree.so : lib /tree .c lib /tree .h base /lib /libtoaru_list .so
$( CC) -o $@ $( CFLAGS) -shared -fPIC $< -ltoaru_list
2018-02-25 11:14:43 +03:00
base/lib/libtoaru_hashmap.so : lib /hashmap .c lib /hashmap .h base /lib /libtoaru_list .so
$( CC) -o $@ $( CFLAGS) -shared -fPIC $< -ltoaru_list
2018-02-25 08:13:54 +03:00
base/lib/libtoaru_kbd.so : lib /kbd .c lib /kbd .h
$( CC) -o $@ $( CFLAGS) -shared -fPIC $<
2018-02-25 11:14:43 +03:00
base/lib/libtoaru_pthread.so : lib /pthread .c lib /pthread .h
$( CC) -o $@ $( CFLAGS) -shared -fPIC $<
base/lib/libtoaru_pex.so : lib /pex .c lib /pex .h
$( CC) -o $@ $( CFLAGS) -shared -fPIC $<
base/lib/libtoaru_dlfcn.so : lib /dlfcn .c lib /dlfcn .h
$( CC) -o $@ $( CFLAGS) -shared -fPIC $<
base/lib/libtoaru_yutani.so : lib /yutani .c lib /yutani .h base /lib /libtoaru_graphics .so
$( CC) -o $@ $( CFLAGS) -shared -fPIC $< -ltoaru_graphics
2018-02-25 08:13:54 +03:00
base/lib/libtoaru_rline.so : lib /rline .c lib /rline .h base /lib /libtoaru_kbd .so
2018-02-25 11:14:43 +03:00
$( CC) -o $@ $( CFLAGS) -shared -fPIC $< -ltoaru_kbd
base/lib/libtoaru_termemu.so : lib /termemu .c lib /termemu .h base /lib /libtoaru_graphics .so
$( CC) -o $@ $( CFLAGS) -shared -fPIC $< -ltoaru_graphics
2018-03-01 09:10:57 +03:00
base/lib/libtoaru_drawstring.so : lib /drawstring .c lib /drawstring .h base /lib /libtoaru_graphics .so
$( CC) -o $@ $( CFLAGS) -shared -fPIC $< -ltoaru_graphics
2018-02-25 11:14:43 +03:00
base/lib/libtoaru_decorations.so : lib /decorations .c lib /decorations .h base /lib /libtoaru_graphics .so
$( CC) -o $@ $( CFLAGS) -shared -fPIC $< -ltoaru_graphics
2018-02-25 08:13:54 +03:00
2018-03-01 09:10:57 +03:00
base/lib/libtoaru-decor-fancy.so : decors /decor -fancy .c lib /decorations .h base /lib /libtoaru_graphics .so base /lib /libtoaru_decorations .so base /lib /libtoaru_drawstring .so
$( CC) -o $@ $( CFLAGS) -shared -fPIC $< -ltoaru_decorations -ltoaru_drawstring -ltoaru_graphics
2018-02-25 15:54:39 +03:00
2018-03-03 14:53:13 +03:00
base/bin/init : apps /init .c base /lib /libnihc .a | dirs
2018-02-25 08:13:54 +03:00
$( CC) -static -Wl,-static $( CFLAGS) -o $@ $< $( LIBS)
2018-03-03 14:53:13 +03:00
base/bin/sh : apps /sh .c base /lib /libnihc .so base /lib /libtoaru_list .so base /lib /libtoaru_rline .so
2018-02-25 08:13:54 +03:00
$( CC) $( CFLAGS) -o $@ $< -ltoaru_rline -ltoaru_list -ltoaru_kbd $( LIBS)
2018-03-03 14:53:13 +03:00
base/bin/sysinfo : apps /sysinfo .c base /lib /libnihc .so base /lib /libtoaru_graphics .so base /lib /libtoaru_termemu .so
2018-02-25 17:06:07 +03:00
$( CC) $( CFLAGS) -o $@ $< -ltoaru_graphics -ltoaru_termemu $( LIBS)
2018-02-25 08:13:54 +03:00
2018-03-03 14:53:13 +03:00
base/bin/terminal : apps /terminal .c base /lib /libnihc .so base /lib /libtoaru_graphics .so base /lib /libtoaru_yutani .so base /lib /libtoaru_decorations .so base /lib /libtoaru_dlfcn .so base /lib /libtoaru_list .so base /lib /libtoaru_kbd .so base /lib /libtoaru_termemu .so base /lib /libtoaru_pex .so base /lib /libtoaru_hashmap .so
2018-02-25 11:14:43 +03:00
$( CC) $( CFLAGS) -o $@ $< -ltoaru_termemu -ltoaru_decorations -ltoaru_yutani -ltoaru_graphics -ltoaru_pex -ltoaru_hashmap -ltoaru_dlfcn -ltoaru_kbd -ltoaru_list $( LIBS)
2018-03-03 14:53:13 +03:00
base/bin/background : apps /background .c base /lib /libnihc .so base /lib /libtoaru_graphics .so base /lib /libtoaru_yutani .so base /lib /libtoaru_pthread .so base /lib /libtoaru_drawstring .so
2018-03-01 09:10:57 +03:00
$( CC) $( CFLAGS) -o $@ $< -ltoaru_drawstring -ltoaru_yutani -ltoaru_graphics -ltoaru_pex -ltoaru_pthread -ltoaru_hashmap -ltoaru_list $( LIBS)
2018-02-25 11:14:43 +03:00
2018-03-03 14:53:13 +03:00
base/bin/drawlines : apps /drawlines .c base /lib /libnihc .so base /lib /libtoaru_graphics .so base /lib /libtoaru_yutani .so base /lib /libtoaru_pthread .so
2018-02-25 11:14:43 +03:00
$( CC) $( CFLAGS) -o $@ $< -ltoaru_yutani -ltoaru_graphics -ltoaru_pex -ltoaru_pthread -ltoaru_hashmap -ltoaru_list $( LIBS)
2018-02-25 12:29:31 +03:00
2018-03-03 14:53:13 +03:00
base/bin/yutani-query : apps /yutani -query .c base /lib /libnihc .so base /lib /libtoaru_graphics .so base /lib /libtoaru_yutani .so base /lib /libtoaru_pthread .so
2018-02-25 17:06:07 +03:00
$( CC) $( CFLAGS) -o $@ $< -ltoaru_yutani -ltoaru_graphics -ltoaru_pex -ltoaru_pthread -ltoaru_hashmap -ltoaru_list $( LIBS)
2018-03-03 14:53:13 +03:00
base/bin/yutani-test : apps /yutani -test .c base /lib /libnihc .so base /lib /libtoaru_graphics .so base /lib /libtoaru_yutani .so base /lib /libtoaru_pthread .so
2018-02-25 12:29:31 +03:00
$( CC) $( CFLAGS) -o $@ $< -ltoaru_yutani -ltoaru_graphics -ltoaru_pex -ltoaru_pthread -ltoaru_hashmap -ltoaru_list $( LIBS)
2018-02-25 11:14:43 +03:00
2018-03-03 14:53:13 +03:00
base/bin/compositor : apps /compositor .c base /lib /libnihc .so base /lib /libtoaru_graphics .so base /lib /libtoaru_list .so base /lib /libtoaru_kbd .so base /lib /libtoaru_pthread .so base /lib /libtoaru_pex .so base /lib /libtoaru_yutani .so base /lib /libtoaru_hashmap .so
2018-02-25 11:14:43 +03:00
$( CC) $( CFLAGS) -o $@ $< -ltoaru_yutani -ltoaru_pthread -ltoaru_pex -ltoaru_graphics -ltoaru_kbd -ltoaru_hashmap -ltoaru_list $( LIBS)
2018-03-03 14:53:13 +03:00
base/bin/ls : apps /ls .c base /lib /libnihc .so base /lib /libtoaru_list .so
2018-02-25 08:13:54 +03:00
$( CC) $( CFLAGS) -o $@ $< -ltoaru_list $( LIBS)
2018-03-03 14:53:13 +03:00
base/bin/nyancat : apps /nyancat /nyancat .c base /lib /libnihc .so
2018-03-02 15:25:32 +03:00
$( CC) $( CFLAGS) -o $@ $< $( LIBS)
2018-03-03 14:53:13 +03:00
base/bin/ps : apps /ps .c base /lib /libnihc .so base /lib /libtoaru_list .so
2018-03-03 14:23:13 +03:00
$( CC) $( CFLAGS) -o $@ $< -ltoaru_list $( LIBS)
2018-03-03 14:53:13 +03:00
base/bin/pstree : apps /pstree .c base /lib /libnihc .so base /lib /libtoaru_tree .so base /lib /libtoaru_list .so
2018-03-03 14:23:13 +03:00
$( CC) $( CFLAGS) -o $@ $< -ltoaru_tree -ltoaru_list $( LIBS)
2018-03-03 14:53:13 +03:00
base/bin/% : apps /%.c base /lib /libnihc .so | dirs
2018-02-25 08:13:54 +03:00
$( CC) $( CFLAGS) -o $@ $< $( LIBS)
2018-02-25 15:54:39 +03:00
cdrom/ramdisk.img.gz : ${APPS_X } base /lib /ld .so base /lib /libtoaru -decor -fancy .so | dirs
2018-02-25 08:13:54 +03:00
genext2fs -B 4096 -d base -U -b 16384 -N 2048 cdrom/ramdisk.img
rm -f cdrom/ramdisk.img.gz
gzip cdrom/ramdisk.img
image.iso : cdrom /ramdisk .img .gz
grub-mkrescue -d /usr/lib/grub/i386-pc --compress= xz -o $@ cdrom
2018-02-25 11:43:31 +03:00
.PHONY : clean
clean :
rm -f base/lib/*.so
rm -f base/lib/libnihc.a
2018-03-01 06:55:28 +03:00
rm -f ${ APPS_X }
2018-02-25 11:43:31 +03:00
rm -f libc/*.o
rm -f image.iso
rm -f cdrom/randisk.img.gz