From d3d24e46b478da7f22b5e5d82100b3f6de389e93 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 24 Oct 2023 05:15:43 +0300 Subject: [PATCH] Updated make --- Makefile | 15 +++++++++++---- build.sh | 25 ------------------------- console-tools/Makefile | 11 +++++++++++ coreutils/Makefile | 11 +++++++++++ miscutils/Makefile | 11 +++++++++++ networking/Makefile | 11 +++++++++++ 6 files changed, 55 insertions(+), 29 deletions(-) delete mode 100755 build.sh create mode 100644 console-tools/Makefile create mode 100644 coreutils/Makefile create mode 100644 miscutils/Makefile create mode 100644 networking/Makefile 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 $@ $<