diff --git a/Makefile b/Makefile index f475a8f..59a9995 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,13 @@ -all: - chmod +x build.sh - ./build.sh rootfs +objects = coreutils console-tools networking miscutils + +CFLAGS?=-s -Os -flto -pedantic -Wall -Wextra +CC?=cc + +all: $(objects) + +$(objects): + echo MAKE $@ + cd $@ && $(MAKE) -B CC="$(CC)" CFLAGS="$(CFLAGS)" && cd .. clean: - ./build.sh clean + rm bin/* diff --git a/build.sh b/build.sh deleted file mode 100755 index 683b4d2..0000000 --- a/build.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -if [ -z $CC ]; then - CC=cc -fi -if [ -z $CFLAGS ]; then - CFLAGS="-s -Os -pedantic -Wall -Wextra" -fi -if [ -z $1 ]; then - echo $0 "[rootfs / clean]" - exit -fi - -echo "ENV: CC: " $CC "| CFLAGS: " $CFLAGS - -if [ $1 = "clean" ]; then - rm bin/* -elif [ $1 = "rootfs" ]; then - applets="coreutils/* miscutils/* console-tools/* networking/*" - for i in $applets; do - echo CC $i - $CC $CFLAGS $i -o $(echo bin/$(basename $i .c)) - done -else - echo $0 "[rootfs / clean]" -fi diff --git a/console-tools/Makefile b/console-tools/Makefile new file mode 100644 index 0000000..76c8c29 --- /dev/null +++ b/console-tools/Makefile @@ -0,0 +1,11 @@ +C_SOURCES:=$(wildcard ./*.c) +C_TARGETS:=$(patsubst ./%.c, ../bin/%, $(C_SOURCES)) +TARGETS:=$(C_TARGETS) + +CFLAGS?=-s -Os -flto -pedantic -Wall -Wextra +CC?=cc + +all: ../bin $(TARGETS) + +../bin/%: %.c + $(CC) $(CFLAGS) -o $@ $< diff --git a/coreutils/Makefile b/coreutils/Makefile new file mode 100644 index 0000000..76c8c29 --- /dev/null +++ b/coreutils/Makefile @@ -0,0 +1,11 @@ +C_SOURCES:=$(wildcard ./*.c) +C_TARGETS:=$(patsubst ./%.c, ../bin/%, $(C_SOURCES)) +TARGETS:=$(C_TARGETS) + +CFLAGS?=-s -Os -flto -pedantic -Wall -Wextra +CC?=cc + +all: ../bin $(TARGETS) + +../bin/%: %.c + $(CC) $(CFLAGS) -o $@ $< diff --git a/miscutils/Makefile b/miscutils/Makefile new file mode 100644 index 0000000..76c8c29 --- /dev/null +++ b/miscutils/Makefile @@ -0,0 +1,11 @@ +C_SOURCES:=$(wildcard ./*.c) +C_TARGETS:=$(patsubst ./%.c, ../bin/%, $(C_SOURCES)) +TARGETS:=$(C_TARGETS) + +CFLAGS?=-s -Os -flto -pedantic -Wall -Wextra +CC?=cc + +all: ../bin $(TARGETS) + +../bin/%: %.c + $(CC) $(CFLAGS) -o $@ $< diff --git a/networking/Makefile b/networking/Makefile new file mode 100644 index 0000000..76c8c29 --- /dev/null +++ b/networking/Makefile @@ -0,0 +1,11 @@ +C_SOURCES:=$(wildcard ./*.c) +C_TARGETS:=$(patsubst ./%.c, ../bin/%, $(C_SOURCES)) +TARGETS:=$(C_TARGETS) + +CFLAGS?=-s -Os -flto -pedantic -Wall -Wextra +CC?=cc + +all: ../bin $(TARGETS) + +../bin/%: %.c + $(CC) $(CFLAGS) -o $@ $<