Updated make

This commit is contained in:
Your Name 2023-10-24 05:15:43 +03:00
parent deef828e3c
commit d3d24e46b4
6 changed files with 55 additions and 29 deletions

View File

@ -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/*

View File

@ -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

11
console-tools/Makefile Normal file
View File

@ -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 $@ $<

11
coreutils/Makefile Normal file
View File

@ -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 $@ $<

11
miscutils/Makefile Normal file
View File

@ -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 $@ $<

11
networking/Makefile Normal file
View File

@ -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 $@ $<