aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKylie McClain <somasis@exherbo.org>2016-02-12 00:31:25 -0500
committerKylie McClain <somasis@exherbo.org>2016-02-12 00:32:43 -0500
commite82b3beb083f47bdd0cf8cbc31be341d32a7f7fa (patch)
treef38e3424e4ca26548db9752993cd45a8d33d6249
parent9f7a028aded382040f23657f35037a87a6e6b88b (diff)
downloadlighter-e82b3beb083f47bdd0cf8cbc31be341d32a7f7fa.tar.gz
lighter-e82b3beb083f47bdd0cf8cbc31be341d32a7f7fa.tar.xz
lighter-e82b3beb083f47bdd0cf8cbc31be341d32a7f7fa.zip
heavily improved parallelization
-rw-r--r--Makefile92
-rwxr-xr-xscripts/build18
-rwxr-xr-xscripts/extract23
-rwxr-xr-xscripts/fetch14
-rwxr-xr-xscripts/pkgs/busybox (renamed from scripts/build/busybox)4
-rwxr-xr-xscripts/pkgs/dropbear (renamed from scripts/build/dropbear)2
-rwxr-xr-xscripts/pkgs/musl (renamed from scripts/build/musl)2
-rwxr-xr-xscripts/prepare12
-rwxr-xr-xscripts/toolchain10
9 files changed, 103 insertions, 74 deletions
diff --git a/Makefile b/Makefile
index 31f3c47..ef56054 100644
--- a/Makefile
+++ b/Makefile
@@ -6,21 +6,31 @@ CXXFLAGS ?= $(CFLAGS)
CFLAGS += -static
LDFLAGS += -static
+JOBS ?= $(shell expr $$(grep -c processor /proc/cpuinfo) + 4)
+
+LIGHTER ?= $(PWD)
+ARCHIVES ?= $(LIGHTER)/archives
+BUILD ?= $(LIGHTER)/build
+CONFIGS ?= $(LIGHTER)/configs
+DOWNLOADS ?= $(LIGHTER)/downloads
+TOOLCHAIN ?= $(LIGHTER)/toolchain
+
+PATH +=:$(TOOLCHAIN)
export CFLAGS
export CXXFLAGS
export LDFLAGS
-
-JOBS = $$(expr $$(grep -c processor /proc/cpuinfo) + 4)
-
-BUILD ?= $(PWD)/build
-
-PATH += :$(PWD)/toolchain
-
-urls = \
- http://busybox.net/downloads/busybox-1.24.1.tar.bz2 \
- https://matt.ucc.asn.au/dropbear/releases/dropbear-2015.71.tar.bz2
-
-make = busybox dropbear
+export JOBS
+export LIGHTER
+export ARCHIVES
+export BUILD
+export CONFIGS
+export DOWNLOADS
+export TOOLCHAIN
+export PATH
+
+make = \
+ busybox=http=//busybox.net/downloads/busybox-1.24.1.tar.bz2 \
+ dropbear=https=//matt.ucc.asn.au/dropbear/releases/dropbear-2015.71.tar.bz2
all:
@printf "lighter $(VERSION)\n\n"
@@ -30,58 +40,38 @@ all:
"JOBS" "$(JOBS)" \
"BUILD" "$(BUILD)"
@printf "\n"
- @$(MAKE) build
-
-toolchain:
- @printf "making any needed toolchain links...\n"
- @sh -e scripts/toolchain
- @printf "\n"
-# @for d in $(dirs);do echo "mkdir -p $(BUILD)/$$d"; [ -d "$$d" ] || mkdir -p $(BUILD)/"$$d";done
+ @$(MAKE) --no-print-directory buildall
-prepare: toolchain skel
+$(BUILD)/.prepare:
@printf "making build directories...\n"
- -mkdir -p "$(BUILD)" >/dev/null 2>&1
- -mkdir "$(BUILD)"/root >/dev/null 2>&1
- @printf "copying skeleton root to %s...\n" "$(BUILD)"
- cp -r skel/* "$(BUILD)"/root/
+ @sh -e scripts/prepare
@printf "\n"
-fetch: prepare
- @printf "fetching all needed files...\n"
- @sh -e scripts/fetch $(urls)
+$(BUILD)/.toolchain: $(BUILD)/.prepare
+ @printf "making any needed toolchain links...\n"
+ @sh -e scripts/toolchain
+ @touch "$(BUILD)"/.toolchain
@printf "\n"
-extract: fetch
- @printf "extracting downloaded files...\n"
- @sh -e scripts/extract $(urls)
- @printf "\n"
+$(BUILD)/.fetch-%: $(BUILD)/.prepare
+ @sh -e scripts/fetch "$*"
-build/.built-%: toolchain
- @printf "building %s...\n" "$*"
- mkdir -p "$(BUILD)/$*"
- DESTDIR="$(BUILD)/$*" BUILD="$(BUILD)/root" J="$(JOBS)" sh -e scripts/build/$*
- cp -R "$(BUILD)/$*"/* "$(BUILD)/root"
- -[ -d "$(BUILD)"/$* ] && rm -r "$(BUILD)"/$*
- @touch build/.built-$*
- @printf "\n"
+$(BUILD)/.extract-%: $(BUILD)/.fetch-%
+ @sh -e scripts/extract "$*"
-clean-%:
- @printf "cleaning archives/%s...\n" "$*"
- rm -rf archives/"$*"*
+$(BUILD)/.build-%: $(BUILD)/.toolchain $(BUILD)/.extract-%
+ @sh -e scripts/build "$*"
$(BUILD)/initramfs.cpio.gz:
cd "$(BUILD)/root" && find . -print0 | cpio --null -ov --format=newc | gzip -9 > "$(BUILD)"/initramfs.cpio.gz
-pack: $(BUILD)/initramfs.cpio.gz
-
-repack:
- rm -f $(BUILD)/initramfs.cpio.gz
- $(MAKE) pack
-
-build: prepare fetch extract $(foreach m,$(make),build/.built-$(m)) pack
+pack: $(BUILD)/initramfs.cpio.gz
+buildall: $(foreach m,$(make),$(BUILD)/.build-$(m))
+build:
+ @$(MAKE) --no-print-directory buildall
+ @$(MAKE) --no-print-directory pack
clean:
rm -rf downloads archives $(BUILD) toolchain
-.PHONY: clean all prepare fetch extract build pack
-
+.PHONY: all fetch
diff --git a/scripts/build b/scripts/build
new file mode 100755
index 0000000..19f2d54
--- /dev/null
+++ b/scripts/build
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+pkg=$(echo "$1" | cut -d'=' -f1 | tr '=' ':')
+
+export DESTDIR="$BUILD"/"$pkg"
+export J="$JOBS"
+[ -d "$BUILD"/"$pkg" ] || mkdir "$BUILD"/"$pkg"
+[ -f "$BUILD"/.build-"$pkg" ] && exit 0
+printf "building %s...\n" "$pkg"
+printf "%-20s%-20s\n" \
+ "DESTDIR" "$DESTDIR" \
+ "BUILD" "$BUILD" \
+ "JOBS" "$J"
+sh -e scripts/pkgs/"$pkg"
+cp -rf "$BUILD"/"$pkg"/* "$BUILD"/root/
+rm -rf "$BUILD"/"$pkg"
+touch "$BUILD"/.build-"$pkg"
+printf '\n'
diff --git a/scripts/extract b/scripts/extract
index b55a1a2..ea1252a 100755
--- a/scripts/extract
+++ b/scripts/extract
@@ -1,16 +1,21 @@
#!/bin/sh
-urls="$@"
+pkg=$(echo "$1" | cut -d'=' -f1)
+archives=$(echo "$@" | cut -d'=' -f2- | tr '=' ':')
-[ -d archives ] || mkdir archives
-cd archives
-for url in ${urls};do
- u=$(echo "$url" | sed 's|.*/||g;s/\\?.*//')
- echo "$u"
- [ -d "$u" ] && rm -rf "$u"
- case "$u" in
+[ -f "$BUILD"/.extract-"$pkg" ] && exit 0
+cd "$ARCHIVES"
+printf "extracting %s...\n" "$pkg"
+for archive in ${archives};do
+ a=$(echo "$archive" | sed 's|.*/||g;s/\\?.*//')
+ echo " $a"
+ [ -d "$a" ] && rm -rf "$a"
+ [ -f "$BUILD"/.extract-"$a" ] && continue
+ case "$a" in
*.tar|*.tar.gz|*.tgz|*.txz|*.tar.xz|*.tar.bz2)
- tar xf ../downloads/"$u"
+ tar xf ../downloads/"$a"
;;
esac
done
+touch "$BUILD"/.extract-"$pkg"
+printf "\n"
diff --git a/scripts/fetch b/scripts/fetch
index 4daad85..0470757 100755
--- a/scripts/fetch
+++ b/scripts/fetch
@@ -1,13 +1,17 @@
#!/bin/sh
-urls="$@"
+pkg=$(echo "$1" | cut -d'=' -f1)
+urls=$(echo "$1" | cut -d'=' -f2- | tr '=' ':')
-[ -d downloads ] || mkdir downloads
-cd downloads
+[ -f "$BUILD"/.fetch-"$pkg" ] && exit 0
+cd "$DOWNLOADS"
+printf "fetching %s...\n" "$pkg"
for url in ${urls};do
u=$(echo "$url" | sed 's|.*/||g;s/\\?.*//')
- echo "$url"
- if [ ! -f "$u" ];then
+ echo " $url"
+ if [ ! -f "$u" ] && [ ! -f "$BUILD"/.fetch-"$u" ];then
curl -L#O "$url"
fi
done
+touch "$BUILD"/.fetch-"$pkg"
+printf "\n"
diff --git a/scripts/build/busybox b/scripts/pkgs/busybox
index db8bb39..d93eb8f 100755
--- a/scripts/build/busybox
+++ b/scripts/pkgs/busybox
@@ -1,8 +1,8 @@
#!/bin/sh
-cd archives/busybox-*
+cd "$ARCHIVES"/busybox-*
-cp ../../configs/busybox ./.config
+cp "$CONFIGS"/busybox ./.config
make -j$J V=2 CC=${CC} HOSTCC=${CC}
install -D busybox "$DESTDIR"/bin/busybox
for bin in $("$DESTDIR"/bin/busybox --list);do
diff --git a/scripts/build/dropbear b/scripts/pkgs/dropbear
index fe00f44..57aefe8 100755
--- a/scripts/build/dropbear
+++ b/scripts/pkgs/dropbear
@@ -1,6 +1,6 @@
#!/bin/sh
-cd archives/dropbear-*
+cd "$ARCHIVES"/dropbear-*
./configure --prefix=/ --sbindir=/bin --disable-{syslog,shadow,lastlog,utmp,utmpx,wtmp,wtmpx,shared} --enable-static
make -j$J MULTI=1
diff --git a/scripts/build/musl b/scripts/pkgs/musl
index 79ee295..06ba029 100755
--- a/scripts/build/musl
+++ b/scripts/pkgs/musl
@@ -1,6 +1,6 @@
#!/bin/sh
-cd archives/musl-*
+cd "$ARCHIVES"/musl-*
./configure --prefix=/ --disable-gcc-wrapper --enable-static --disable-shared
make -j$J
diff --git a/scripts/prepare b/scripts/prepare
new file mode 100755
index 0000000..c8ec4e9
--- /dev/null
+++ b/scripts/prepare
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+[ -d "$BUILD" ] || mkdir -p "$BUILD"
+[ -d "$BUILD/root" ] || mkdir "$BUILD/root"
+[ -d "$DOWNLOADS" ] || mkdir "$DOWNLOADS"
+[ -d "$ARCHIVES" ] || mkdir "$ARCHIVES"
+[ -d "$TOOLCHAIN" ] || mkdir "$TOOLCHAIN"
+
+printf "copying skeleton root to %s...\n" "$BUILD/root"
+cp -rf skel/* "$BUILD"/root
+
+touch "$BUILD"/.prepare
diff --git a/scripts/toolchain b/scripts/toolchain
index e03b9f8..94a5a6d 100755
--- a/scripts/toolchain
+++ b/scripts/toolchain
@@ -6,8 +6,7 @@ toolchain="
cc c++ cpp
"
-[ -d toolchain ] || mkdir toolchain
-
+cd "$TOOLCHAIN"
for tc in $toolchain;do
tc_clean=$(echo "$tc" | tr '+' 'x')
tc_var=$(echo "$tc_clean" | tr '[a-z]' '[A-Z]')
@@ -15,15 +14,16 @@ for tc in $toolchain;do
tc_set=$(eval echo $(echo \$$(eval echo "\$tc_var")))
if [ ! -z "$tc_set" ];then
echo "$tc_set -> $tc"
- ln -sf $(which "$tc_set") toolchain/"$tc"
+ ln -sf $(which "$tc_set") "$tc"
else
if [ ! -z "$CHOST" ];then
- if which $CHOST-"$tc" >/dev/null 2>&1;then
+ if which "$CHOST-$tc" >/dev/null 2>&1;then
echo "$CHOST-$tc -> $tc"
- ln -sf $(which "$CHOST-$tc") toolchain/"$tc"
+ ln -sf $(which "$CHOST-$tc") "$tc"
fi
fi
continue
fi
done
+touch "$BUILD"/.toolchain