aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKylie McClain <somasis@exherbo.org>2016-02-09 02:41:48 -0500
committerKylie McClain <somasis@exherbo.org>2016-02-09 08:26:01 -0500
commit039ab6d8e7939d133d9dc6a1d196b9de5e18012c (patch)
treeb5f899f6b3c8268d7710671f60ac189bf6d60ea6
downloadlighter-039ab6d8e7939d133d9dc6a1d196b9de5e18012c.tar.gz
lighter-039ab6d8e7939d133d9dc6a1d196b9de5e18012c.tar.xz
lighter-039ab6d8e7939d133d9dc6a1d196b9de5e18012c.zip
initial commit
-rw-r--r--.gitignore7
-rw-r--r--LICENSE13
-rw-r--r--Makefile75
-rw-r--r--README.md1
-rwxr-xr-xscripts/build/mksh6
-rwxr-xr-xscripts/build/musl7
-rwxr-xr-xscripts/build/toybox11
-rwxr-xr-xscripts/extract16
-rwxr-xr-xscripts/fetch13
-rwxr-xr-xscripts/toolchain29
-rw-r--r--skel/etc/profile6
11 files changed, 184 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2e64f63
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,7 @@
+*.swp
+*~
+.*.kak.*
+/archives/
+/build/
+/downloads/
+/toolchain/
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..0cb0b66
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,13 @@
+Copyright (c) 2016 Kylie McClain <somasis@exherbo.org>
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..6bb8ea9
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,75 @@
+VERSION =scm
+
+CFLAGS ?= -Os
+CXXFLAGS ?= $(CFLAGS)
+
+CFLAGS += -I$(BUILD)/include -L$(BUILD)/lib -static
+LDFLAGS += -static
+
+export CFLAGS
+export CXXFLAGS
+export LDFLAGS
+
+JOBS = $$(grep -c processor /proc/cpuinfo)
+
+BUILD ?= $(PWD)/build
+
+PATH += :$(PWD)/toolchain
+
+urls = \
+ http://www.musl-libc.org/releases/musl-1.0.5.tar.gz \
+ http://landley.net/toybox/downloads/toybox-0.7.0.tar.gz \
+ http://sources.voidlinux.eu/sources/mksh-R52b/mksh-R52b.tgz
+
+make = musl toybox mksh
+
+all:
+ @printf "lighter $(VERSION)\n\n"
+ @printf "%-20s%-20s\n" \
+ "CFLAGS" "$(CFLAGS)" \
+ "CXXFLAGS" "$(CXXFLAGS)" \
+ "MAKEFLAGS" "$(MAKEFLAGS)" \
+ "BUILD" "$(BUILD)"
+ @printf "\n"
+ @$(MAKE) --no-print-directory 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
+
+skel:
+ @printf "copying skeleton root to %s...\n" "$(BUILD)"
+ -mkdir -p "$(BUILD)"
+ @cp -r skel/* $(BUILD)
+ @printf "\n"
+
+prepare: toolchain skel
+
+fetch: prepare
+ @printf "fetching all needed files...\n"
+ @sh -e scripts/fetch $(urls)
+ @printf "\n"
+
+extract: fetch
+ @printf "extracting downloaded files...\n"
+ @sh -e scripts/extract $(urls)
+ @printf "\n"
+
+build/.built-%: toolchain
+ @printf "building %s...\n" "$*"
+ @BUILD="$(BUILD)" J="$(JOBS)" sh -e scripts/build/$* && touch build/.built-$*
+ @printf "\n"
+
+clean-%:
+ @printf "cleaning archives/%s...\n" "$*"
+ @rm -rf archives/"$*"*
+
+build: prepare fetch extract $(foreach m,$(make),build/.built-$(m))
+
+clean:
+ rm -rf downloads archives $(BUILD) toolchain
+
+.PHONY: all skel toolchain fetch extract build
+
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..2dafb58
--- /dev/null
+++ b/README.md
@@ -0,0 +1 @@
+# lighter
diff --git a/scripts/build/mksh b/scripts/build/mksh
new file mode 100755
index 0000000..77c3206
--- /dev/null
+++ b/scripts/build/mksh
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+cd archives/mksh
+
+sh ./Build.sh -r -c lto
+install -s -D mksh "$BUILD"/bin/sh
diff --git a/scripts/build/musl b/scripts/build/musl
new file mode 100755
index 0000000..79ee295
--- /dev/null
+++ b/scripts/build/musl
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+cd archives/musl-*
+
+./configure --prefix=/ --disable-gcc-wrapper --enable-static --disable-shared
+make -j$J
+make -j$J install DESTDIR="$BUILD"
diff --git a/scripts/build/toybox b/scripts/build/toybox
new file mode 100755
index 0000000..204f043
--- /dev/null
+++ b/scripts/build/toybox
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+cd archives/toybox-*
+
+make -j$J defconfig
+make -j$J toybox
+install -D toybox "$BUILD"/bin/toybox
+for bin in $("$BUILD"/bin/toybox);do
+ ln -s toybox "$BUILD"/bin/"$bin"
+done
+
diff --git a/scripts/extract b/scripts/extract
new file mode 100755
index 0000000..b55a1a2
--- /dev/null
+++ b/scripts/extract
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+urls="$@"
+
+[ -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
+ *.tar|*.tar.gz|*.tgz|*.txz|*.tar.xz|*.tar.bz2)
+ tar xf ../downloads/"$u"
+ ;;
+ esac
+done
diff --git a/scripts/fetch b/scripts/fetch
new file mode 100755
index 0000000..ba01717
--- /dev/null
+++ b/scripts/fetch
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+urls="$@"
+
+[ -d downloads ] || mkdir downloads
+cd downloads
+for url in ${urls};do
+ u=$(echo "$url" | sed 's|.*/||g;s/\\?.*//')
+ echo "$url"
+ if [ ! -f "$u" ];then
+ curl -#O "$url"
+ fi
+done
diff --git a/scripts/toolchain b/scripts/toolchain
new file mode 100755
index 0000000..e03b9f8
--- /dev/null
+++ b/scripts/toolchain
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+toolchain="
+ addr2line ar as c++filt dwp elfedit gprof ld nm objcopy objdump
+ ranlib readelf size strings strip
+ cc c++ cpp
+"
+
+[ -d toolchain ] || mkdir toolchain
+
+for tc in $toolchain;do
+ tc_clean=$(echo "$tc" | tr '+' 'x')
+ tc_var=$(echo "$tc_clean" | tr '[a-z]' '[A-Z]')
+ # tc_var=CC, if $CC set...
+ 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"
+ else
+ if [ ! -z "$CHOST" ];then
+ if which $CHOST-"$tc" >/dev/null 2>&1;then
+ echo "$CHOST-$tc -> $tc"
+ ln -sf $(which "$CHOST-$tc") toolchain/"$tc"
+ fi
+ fi
+ continue
+ fi
+done
+
diff --git a/skel/etc/profile b/skel/etc/profile
new file mode 100644
index 0000000..9a9cada
--- /dev/null
+++ b/skel/etc/profile
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+umask 022
+
+export PATH="/bin"
+