Complete rewrite of the build system

This commit is contained in:
Daniel Bainton 2014-03-26 21:19:02 +00:00
parent f767b158fc
commit 56acf67326
67 changed files with 237 additions and 11756 deletions

3
.gitignore vendored
View File

@ -1,6 +1,3 @@
.cache
config.mk
pkgs.mk
*.img
root
src

28
build/mk.3rdparty Normal file
View File

@ -0,0 +1,28 @@
<$mkbuild/../config.mk
all:QV: build
build:QV: fetch
cd $src
if test "${targ}" != ""; then
env -i PATH="$PATH" mkbuild="$mkbuild" TARG="${targ}" mk -f $mkfile
else
env -i PATH="$PATH" mkbuild="$mkbuild" mk -f $mkfile
fi
install:QV: all
cd $src
if test "${targ}" != ""; then
env -i PATH="$PATH" mkbuild="$mkbuild" mk -f $mkfile install TARG="${targ}" ROOT="${ROOT}"
else
env -i PATH="$PATH" mkbuild="$mkbuild" mk -f $mkfile install ROOT="${ROOT}"
fi
clean:QV:
if test -d $src; then
cd $src
env -i PATH="$PATH" mkbuild="$mkbuild" mk -f $mkfile clean
fi
<$mkbuild/mk.fetch

27
build/mk.build Normal file
View File

@ -0,0 +1,27 @@
all:QV: $DEPS $TARG $BIN $LIB
TARG = `{ if test "$TARG" != ""; then echo $TARG; else echo "NOTARG"; fi }
BIN = `{ if test "$BIN" != ""; then echo $BIN; else echo "NOBIN"; fi }
LIB = `{ if test "$LIB" != ""; then echo $LIB; else echo "NOLIB"; fi }
`{ printf "# Auto-generated file by mk, do not edit\n\n" > .targs.mk }
`{ for i in $BIN; do printf "$i:Q: \$"$i"_OBJ\n\techo LD \$target\n\t\$LD \$prereq \$LDFLAGS \$DEPS_LDFLAGS \$LOCAL_LDFLAGS \$LOCAL_BIN_LDFLAGS -o \$target\n\n" ; done >> .targs.mk }
<.targs.mk
<$mkbuild/mk.deps
&.a:Q:
echo AR $target
$AR -rv $target $prereq
echo RANLIB $target
$RANLIB $target
%.o:Q: %.c
echo CC $stem.o
$CC $CFLAGS $DEPS_CFLAGS $LOCAL_CFLAGS $CPPFLAGS -c $stem.c -o $stem.o
%.c:Q: %.y
echo YACC $stem.y
$YACC $stem.y
mv -f y.tab.c $stem.c

12
build/mk.clean Normal file
View File

@ -0,0 +1,12 @@
clean:QV:
t=`if test "$TARG" = "NOTARG"; then echo; else echo $TARG; fi `
b=`if test "$BIN" = "NOBIN"; then echo; else echo $BIN; fi `
l=`if test "$LIB" = "NOLIB"; then echo; else echo $LIB; fi `
bin_obj=
for i in $BIN; do
bin_obj="$bin_obj \$${i}_OBJ"
done
bin_obj=`eval echo $bin_obj`
echo rm -f $t $b $OBJ $bin_obj $l $LOBJ $CLEAN_FILES .targs.mk .deps.mk
rm -f $t $b $OBJ $bin_obj $l $LOBJ $CLEAN_FILES .targs.mk .deps.mk

7
build/mk.common Normal file
View File

@ -0,0 +1,7 @@
<$mkbuild/../config.mk
<$mkbuild/mk.build
<$mkbuild/mk.install
<$mkbuild/mk.clean
fetch:VQ:
# Nothing to download

2
build/mk.default Normal file
View File

@ -0,0 +1,2 @@
<$mkbuild/mk.common
<$mkbuild/mk.target

21
build/mk.deps Normal file
View File

@ -0,0 +1,21 @@
`{ printf "# Auto-generated file by mk, do not edit\n\n" > .deps.mk }
paths = `{ find $mkbuild/../src -type f -name mkfile }
`{ for i in $DEPS; do \
for path in $paths; do \
dir=$(dirname $path); \
pkg=$(basename $dir); \
if test "$i" = "$pkg"; then \
printf "${i}_DEPDIR = $dir\n\n"; \
printf "<$dir/depsinc.mk\n\n"; \
printf "$pkg:QV:\n\tcd $dir\n\tenv -i PATH=\"$PATH\" mkbuild=\"$mkbuild\" mk\n\n"; \
fi; \
done; \
done >> .deps.mk }
<.deps.mk
deps:V: $DEPS

15
build/mk.fetch Normal file
View File

@ -0,0 +1,15 @@
fetch:QV: fetch-git fetch-http
fetch-git:QV:
if test "$git" = ""; then
return
fi
test -d $src || git clone $git $src
fetch-http:QV:
if test "$url" = ""; then
return
fi
wget -c $url
tar -xf `basename $url`

66
build/mk.install Normal file
View File

@ -0,0 +1,66 @@
install:QV: install_bin install_lib install_man install_other \
install_symlinks install_dirs
if test "$INSTALL_PERMISSIONS" = ""; then
return
fi
eval `echo $INSTALL_PERMISSIONS | tr ' ' '\n' | paste -d ' ' - - | \
awk '{ printf("echo \"CHMOD %s ${ROOT}${PREFIX}%s\"; \
chmod %s ${ROOT}${PREFIX}%s;\n", $1, $2, $1, $2) }'`
install_bin:QV: all
for f in $INSTALL_BIN; do
mkdir -p ${ROOT}${PREFIX}$BINDIR
echo INSTALL ${ROOT}${PREFIX}$BINDIR/`basename $f`
$INSTALL -m 755 $f ${ROOT}${PREFIX}$BINDIR/`basename $f`
type=`file -b $f | cut -d ' ' -f 1`
if test "$type" = "ELF"; then
$STRIP ${ROOT}${PREFIX}$BINDIR/`basename $f`
fi
done
install_lib:QV: all
for f in $INSTALL_LIB; do
mkdir -p ${ROOT}${PREFIX}$LIBDIR
echo INSTALL ${ROOT}${PREFIX}$LIBDIR/`basename $f`
$INSTALL -m 644 $f ${ROOT}${PREFIX}$LIBDIR/`basename $f`
done
install_dirs:QV: all
for f in $INSTALL_DIRS; do
echo MKDIR ${ROOT}${PREFIX}$f
mkdir -p ${ROOT}${PREFIX}$f
done
install_man:QV: all
for i in 1 1b 2 3 4 5 6 7 8; do
a=`echo '\$INSTALL_MAN'$i`
a=`eval echo $a`
for f in $a; do
mkdir -p ${ROOT}${PREFIX}$MANDIR/man$i
echo INSTALL ${ROOT}${PREFIX}$MANDIR/man$i/`basename $f`
$INSTALL -m 644 $f ${ROOT}${PREFIX}$MANDIR/man$i/`basename $f`
done
done
install_other:QV: all
for i in 1 2 3 4 5 6 7 8; do
a=`echo '\$INSTALL_OTHER'$i`
a=`eval echo $a`
d=`echo '\$INSTALL_OTHER'${i}'_DIR'`
d=`eval echo $d`
mkdir -p ${ROOT}$d
for f in $a; do
echo INSTALL ${ROOT}${PREFIX}$d/`basename $f`
$INSTALL -m 644 $f ${ROOT}${PREFIX}$d/`basename $f`
done
done
install_symlinks:QV: all
if test "$INSTALL_SYMLINK" = ""; then
return
fi
eval `echo $INSTALL_SYMLINK | tr ' ' '\n' | paste -d ' ' - - | \
awk '{ printf("echo \"LN %s ${ROOT}${PREFIX}%s\"; \
ln -sf %s ${ROOT}${PREFIX}%s;\n", $1, $2, $1, $2) }'`

30
build/mk.parent Normal file
View File

@ -0,0 +1,30 @@
<$mkbuild/../config.mk
all:QV: $TARG
`{ echo "# Auto-generated file by mk, do not edit" > .targs.mk }
`{ for i in $TARG; do printf "$i:QV:\n\tcd $i\n\tenv -i PATH=\"$PATH\" mkbuild=\"$mkbuild\" mk\n\n" ; done >> .targs.mk }
<.targs.mk
install:QV:
for t in $TARG; do
cd $t
env -i PATH="$PATH" mkbuild="$mkbuild" mk install ROOT="${ROOT}"
cd ..
done
clean:QV:
rm .targs.mk
for t in $TARG; do
cd $t
env -i PATH="$PATH" mkbuild="$mkbuild" mk clean
cd ..
done
fetch:QV:
for t in $TARG; do
cd $t
env -i PATH="$PATH" mkbuild="$mkbuild" mk fetch
cd ..
done

4
build/mk.target Normal file
View File

@ -0,0 +1,4 @@
$BIN: $OBJ
$LIB: $LOBJ

View File

@ -1,20 +1,29 @@
#arch = i486
arch = x86_64
root = ${top}/root
nprocs = 4 # number of processes for building separate packages
NPROC = 4 # number of processes for mk concurrency
libcroot = ${root}/opt/cross/${arch}-linux-musl/${arch}-linux-musl
arch = i486
version = 0.0
mirror = http://dl.2f30.org/morpheus-pkgs/${arch}/${version}
CC = ${arch}-linux-musl-gcc
TOOL_BASE = ${arch}-musl-linux-
CC = ${TOOL_BASE}gcc
LD = $CC
AR = ${TOOL_BASE}ar
RANLIB = ${TOOL_BASE}ranlib
STRIP = ${TOOL_BASE}strip
#STRIP = true
SHELL = /bin/sh
PREFIX =
BINDIR = ${PREFIX}/bin
LIBDIR = ${PREFIX}/lib
ETCDIR = ${PREFIX}/etc
DFLDIR = ${ETCDIR}/default
MANDIR = ${PREFIX}/share/man
INSTALL = install
# these don't work for all packages yet...
optldflags = -s -Wl,--gc-sections -Wl,-z,relro,-z,now
optcflags = -fdata-sections -ffunction-sections -Os -g0 -fno-unwind-tables -fno-asynchronous-unwind-tables -Wa,--noexecstack
CPPFLAGS = -D_BSD_SOURCE -D_GNU_SOURCE
CFLAGS = -I${libcroot}/include ${CPPFLAGS} # ${optcflags}
LDFLAGS = -L${libcroot}/lib -static ${optldflags}
PATH = ${root}/opt/cross/${arch}-linux-musl/bin:${PATH}
CFLAGS = ${CPPFLAGS} # ${optcflags}
LDFLAGS = -static ${optldflags}

34
mkfile
View File

@ -1,33 +1,7 @@
top = `{pwd}
`{ test -e config.mk || cp config.def.mk config.mk }
<config.mk
allpkgs = `{ls -d pkgs/*}
pkgs = ${allpkgs:pkgs/%=%}
<$mkbuild/mk.3rdparty
help:VQ:
printf 'Usage: mk pkg...\n'
printf '\nTo build all the targets in pkgs/, run `mk world´\n'
all world:VQ: $pkgs
clean:V:
rm -f .cache/* pkgs.mk
clean-all clean-world:V: clean
rm -rf ${root}
fetchpkgs = ${pkgs:%=%-fetch}
fetch-all fetch-world:VQ: ${fetchpkgs}
`{ mkdir -p src }
`{ mkdir -p .cache }
# generate a pkgs.mk file with the targets for all packages in pkgs/
`{ stuff/generate-pkgs.sh pkgs > pkgs.mk }
<pkgs.mk
bootable:V:
stuff/create-bootable "$root" morpheus-$arch-$version.img
src = ports
git = git://git.2f30.org/ports
mkfile = mkfile

View File

@ -1,17 +0,0 @@
git="git://git.suckless.org/9base"
build: crossmusl
targets="mk"
cd src/9base
make clean
for t in lib9 yacc; do
cd $t
make -j$nprocs CC=$CC
cd ..
done
for t in $targets; do
cd $t
make -j$nprocs CC=$CC
cp $t "$root/bin/"
cd ..
done

View File

@ -1,11 +0,0 @@
git="git://repo.or.cz/abduco.git"
build: crossmusl
cd src/abduco
make clean
sed -i "s@PREFIX = /usr/local@PREFIX = /@" config.mk
sed -i "s@INCS = -I. -I/usr/include -I/usr/local/include@INCS = -I. -I$libcroot/include@" config.mk
sed -i "s@LDFLAGS += -L/usr/lib -L/usr/local/lib ${LIBS}@LDFLAGS += $LDFLAGS ${LIBS} @" config.mk
sed -i "s@CC = cc@CC = $CC@" config.mk
make
make DESTDIR="$root" install

View File

@ -1,58 +0,0 @@
v="1.22.1"
url="$mirror/busybox-$v.tar.bz2"
build: crossmusl sbase
cd src/busybox-$v
cp $pkgdir/busybox.config .config
make -j$nprocs HOSTCC="$CC -static" CC=$CC busybox
cp busybox "$root/bin"
cd "$root/bin"
ln -sf busybox addgroup
ln -sf busybox adduser
ln -sf busybox awk
ln -sf busybox bunzip2
ln -sf busybox bzcat
ln -sf busybox bzip2
ln -sf busybox cp
ln -sf busybox delgroup
ln -sf busybox deluser
ln -sf busybox diff
ln -sf busybox dd
ln -sf busybox ed
ln -sf busybox expr
ln -sf busybox find
ln -sf busybox fdisk
ln -sf busybox fuser
ln -sf busybox grep
ln -sf busybox gunzip
ln -sf busybox gzip
ln -sf busybox hexdump
ln -sf busybox hwclock
ln -sf busybox ifconfig
ln -sf busybox ip
ln -sf busybox kbd_mode
ln -sf busybox killall
ln -sf busybox less
ln -sf busybox login
ln -sf busybox losetup
ln -sf busybox nc
ln -sf busybox od
ln -sf busybox passwd
ln -sf busybox ping
ln -sf busybox pkill
ln -sf busybox printf
ln -sf busybox reset
ln -sf busybox route
ln -sf busybox sed
ln -sf busybox stty
ln -sf busybox sysctl
ln -sf busybox tac
ln -sf busybox tar
ln -sf busybox telnet
ln -sf busybox tftp
ln -sf busybox tftpd
ln -sf busybox top
ln -sf busybox wget
ln -sf busybox xz
ln -sf busybox xzcat
ln -sf busybox zcat

File diff suppressed because it is too large Load Diff

View File

@ -1,14 +0,0 @@
v="1.0.0"
url="$mirror/crossx86-$arch-linux-musl-$v.tar.xz"
build: prepare_root
targets="ar as c++ g++ gcc ld ld.bfd nm objcopy objdump ranlib strip"
cd src
cp -r $arch-linux-musl "$root/opt/cross/"
if test "$arch" = "x86_64"; then
mv "$root/opt/cross/$arch-linux-musl/$arch-linux-musl/lib64"/* "$root/opt/cross/$arch-linux-musl/$arch-linux-musl/lib"
fi
for t in ${targets}; do
ln -sf ../opt/cross/$arch-linux-musl/bin/$arch-linux-musl-$t "$root/bin/$t"
done
ln -sf gcc "$root/bin/cc"

View File

@ -1,8 +0,0 @@
v="2014.63"
url="https://matt.ucc.asn.au/dropbear/releases/dropbear-$v.tar.bz2"
build: crossmusl zlib
cd src/dropbear-$v
CC="$CC -static" ./configure --prefix="$root" --mandir="$root/share/man"
make -j$nprocs
make install

View File

@ -1,11 +0,0 @@
git="git://repo.or.cz/dvtm.git"
build: ncurses
cd src/dvtm
make clean
sed -i "s@PREFIX = /usr/local@PREFIX = /@" config.mk
sed -i "s@INCS = -I. -I/usr/include -I/usr/local/include@INCS = -I. -I$libcroot/include -I$libcroot/include/ncursesw@" config.mk
sed -i "s@LDFLAGS += -L/usr/lib -L/usr/local/lib ${LIBS}@LDFLAGS += $LDFLAGS @" config.mk
sed -i "s@CC = cc@CC = $CC@" config.mk
make
make DESTDIR="$root" install

View File

@ -1,12 +0,0 @@
url="$mirror/dwm-git.tar.gz"
build: tinyxlib
cd src/dwm
make clean
sed -i 's@PREFIX = /usr/local@PREFIX = @' config.mk
sed -i "s@X11INC = /usr/X11R6/include@X11INC = $libcroot/include @" config.mk
sed -i "s@X11LIB = /usr/X11R6/lib@X11LIB = $libcroot/lib @" config.mk
sed -i "s@LDFLAGS = -s ${LIBS}@LDFLAGS = $LDFLAGS ${LIBS} @" config.mk
sed -i "s@CC = cc@CC = $CC@" config.mk
make
make DESTDIR="$root" install

View File

@ -1,29 +0,0 @@
v="1.42.9"
url="https://www.kernel.org/pub/linux/kernel/people/tytso/e2fsprogs/v$v/e2fsprogs-$v.tar.gz"
build: crossmusl
cd src/e2fsprogs-$v
CC="$CC -static" CFLAGS="-D__uint64_t=u_int64_t" ./configure --prefix="" --mandir="/share/man" \
--disable-nls
make -j$nprocs
make DESTDIR="$root" install install-libs
# ripped from sabotage: install libuuid, needed for cryptsetup
cd lib/uuid
make DESTDIR=$root install
rm -f $root/sbin/mkfs.ext2
rm -f $root/sbin/mkfs.ext3
rm -f $root/sbin/mkfs.ext4
rm -f $root/sbin/mkfs.ext4dev
rm -f $root/sbin/fsck.ext2
rm -f $root/sbin/fsck.ext3
rm -f $root/sbin/fsck.ext4
rm -f $root/sbin/fsck.ext4dev
cd "$root/bin"
ln -s mke2fs mkfs.ext2
ln -s mke2fs mkfs.ext3
ln -s mke2fs mkfs.ext4
ln -s mke2fs mkfs.ext4dev
ln -s e2fsck fsck.ext2
ln -s e2fsck fsck.ext3
ln -s e2fsck fsck.ext4
ln -s e2fsck fsck.ext4dev

View File

@ -1,2 +0,0 @@
build: prepare_root
cp "$pkgdir/extlinux.conf" "$root/boot"

View File

@ -1,8 +0,0 @@
DEFAULT morpheus
PROMPT 1
TIMEOUT 50
LABEL morpheus
MENU LABEL Morpheus
LINUX /boot/bzImage
APPEND root=/dev/sda1 rootwait ro

View File

@ -1,99 +0,0 @@
v="5.17"
url="$mirror/file-$v.tar.gz"
build: crossmusl zlib
set -x
cd src/file-$v/src
rm -rf *.o file ../magic/magic.mgc ../magic/magic
CFLAGS="-DBUILTIN_ELF=1 \
-DELFCORE=1 \
-DHAVE_ASCTIME_R=1 \
-DHAVE_ASPRINTF=1 \
-DHAVE_CTIME_R=1 \
-DHAVE_DAYLIGHT=1 \
-DHAVE_DECL_DAYLIGHT=1 \
-DHAVE_DECL_TZNAME=1 \
-DHAVE_DLFCN_H=1 \
-DHAVE_ERR_H=1 \
-DHAVE_FCNTL_H=1 \
-DHAVE_FORK=1 \
-DHAVE_FSEEKO=1 \
-DHAVE_GETLINE=1 \
-DHAVE_GETOPT_H=1 \
-DHAVE_GETOPT_LONG=1 \
-DHAVE_GETPAGESIZE=1 \
-DHAVE_INTTYPES_H=1 \
-DHAVE_LIBZ=1 \
-DHAVE_LIMITS_H=1 \
-DHAVE_LOCALE_H=1 \
-DHAVE_MBRTOWC=1 \
-DHAVE_MBSTATE_T=1 \
-DHAVE_MEMORY_H=1 \
-DHAVE_MKOSTEMP=1 \
-DHAVE_MKSTEMP=1 \
-DHAVE_MMAP=1 \
-DHAVE_PREAD=1 \
-DHAVE_STDDEF_H=1 \
-DHAVE_STDINT_H=1 \
-DHAVE_STDLIB_H=1 \
-DHAVE_STRCASESTR=1 \
-DHAVE_STRERROR=1 \
-DHAVE_STRINGS_H=1 \
-DHAVE_STRING_H=1 \
-DHAVE_STRNDUP=1 \
-DHAVE_STRTOF=1 \
-DHAVE_STRTOUL=1 \
-DHAVE_STRUCT_OPTION=1 \
-DHAVE_STRUCT_STAT_ST_RDEV=1 \
-DHAVE_STRUCT_TM_TM_ZONE=1 \
-DHAVE_SYS_MMAN_H=1 \
-DHAVE_SYS_PARAM_H=1 \
-DHAVE_SYS_STAT_H=1 \
-DHAVE_SYS_TIME_H=1 \
-DHAVE_SYS_TYPES_H=1 \
-DHAVE_SYS_WAIT_H=1 \
-DHAVE_TM_ISDST=1 \
-DHAVE_TM_ZONE=1 \
-DHAVE_TZNAME=1 \
-DHAVE_UNISTD_H=1 \
-DHAVE_UTIME=1 \
-DHAVE_UTIMES=1 \
-DHAVE_UTIME_H=1 \
-DHAVE_VASPRINTF=1 \
-DHAVE_VFORK=1 \
-DHAVE_VISIBILITY=1 \
-DHAVE_WCHAR_H=1 \
-DHAVE_WCTYPE_H=1 \
-DHAVE_WCWIDTH=1 \
-DHAVE_WORKING_FORK=1 \
-DHAVE_WORKING_VFORK=1 \
-DHAVE_ZLIB_H=1 \
-DPACKAGE=\"file\" \
-DPACKAGE_BUGREPORT=\"christos@astron.com\" \
-DPACKAGE_NAME=\"file\" \
-DPACKAGE_TARNAME=\"file\" \
-DPACKAGE_URL=\"\" \
-DPACKAGE_VERSION=\"$v\" \
-DSTDC_HEADERS=1 \
-D_ALL_SOURCE=1 \
-D_GNU_SOURCE=1 \
-D_POSIX_PTHREAD_SEMANTICS=1 \
-D_TANDEM_SOURCE=1 \
-D__EXTENSIONS__=1 \
-DVERSION=\"$v\""
printf "\n#ifndef _INTPTR_T_DEFINED\n#define _INTPTR_T_DEFINED\n#define intptr_t int\n#endif\n" > strcasestr.c.tmp
cat strcasestr.c >> strcasestr.c.tmp
mv strcasestr.c.tmp strcasestr.c
sed -e "s/X.YY/$(echo $v | sed -e "s|\.||g")/" < magic.h.in > magic.h
MAGIC='"/share/file/magic"'
for f in *.c; do
$CC -c $f $LOCAL_CFLAGS $CFLAGS -DPACKAGE_STRING="file $v" -DMAGIC="$MAGIC"
done
$CC -o file *.o -lz $LDFLAGS
cd ../magic
mkdir -p magic
cp Header Localstuff Magdir/* magic/
../src/file -C -m magic
mkdir -p "$root/share/file"
cp magic.mgc "$root/share/file"
cp ../src/file "$root/bin"

View File

@ -1,5 +0,0 @@
git="git://git.2f30.org/fs"
build: prepare_root
cd src/fs
cp -r * "$root/"

View File

@ -1,6 +0,0 @@
git="https://github.com/mit-athena/install.git"
build: crossmusl
cd src/install
$CC -DSTRIP="\"/bin/strip\"" $CFLAGS $LDFLAGS install.c -o install
cp install $root/bin/

View File

@ -1,19 +0,0 @@
v="3.1jupp26"
url="$mirror/joe-$v.tgz"
build: crossmusl
cd src/jupp
CC=$CC sh configure --prefix="/"
make -j$nprocs
cp joe termidx "$root/bin"
mkdir -p "$root/share/man/man1"
cp joe.1 "$root/share/man/man1"
mkdir -p "$root/etc/joe/charmaps"
cp charmaps/klingon "$root/etc/joe/charmaps"
cp joerc jmacsrc "$root/etc/joe"
mkdir -p "$root/etc/joe/syntax"
cp syntax/* "$root/etc/joe/syntax"
cd "$root/bin"
ln -sf joe jmacs
cd "$root/share/man/man1"
ln -sf joe.1 jmacs.1

View File

@ -1,18 +0,0 @@
v="3.10.32"
url="$mirror/kernel.tar.gz"
build: crossmusl
cd src/linux-$v
cp "$pkgdir/kernel-config-$arch" .config
case "$arch" in
x86_64)
A=x86_64
;;
i486)
A=x86
;;
esac
make ARCH="$A" bzImage -j$nprocs
cp arch/x86/boot/bzImage "$root/boot"
cp .config "$root/boot/bzImage.config"
cp System.map "$root/boot"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +0,0 @@
v="2.0.21"
url="$mirror/libevent-$v-stable.tar.gz"
build: crossmusl
cd src/libevent-$v-stable
CC="$CC -static" ./configure --prefix="$libcroot" --disable-shared --enable-static
make -j$nprocs
make install

View File

@ -1,9 +0,0 @@
git="git://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git"
build: crossmusl
cd src/linux_fw
mkdir -p "$root/lib/firmware"
cp -r * "$root/lib/firmware"
rm -f "$root/lib/firmware/WHENCE"
rm -f "$root/lib/firmware/"LICENSE.*
rm -f "$root/lib/firmware/"LICENCE.*

View File

@ -1,8 +0,0 @@
v="3.82"
url="$mirror/make-$v.tar.bz2"
build: crossmusl
cd src/make-$v
CC="$CC -static" ./configure --prefix="$root" --disable-nls
make -j$nprocs
make install

View File

@ -1,7 +0,0 @@
url="$mirror/man.tar.gz"
build: crossmusl
set -x
cd src/man
$CC -std=gnu99 -o man man.c $CFLAGS $LDFLAGS
cp man "$root/bin"

View File

@ -1,80 +0,0 @@
v="R47"
url="$mirror/mksh-$v.tar.gz"
build: crossmusl
set -x
cd src/mksh
cat > signames.inc << EOF
{ "INT", 2 },
{ "SEGV", 11 },
{ "ABRT", 6 },
{ "KILL", 9 },
{ "ALRM", 14 },
{ "BUS", 7 },
{ "CHLD", 17 },
{ "CONT", 18 },
{ "FPE", 8 },
{ "HUP", 1 },
{ "ILL", 4 },
{ "IO", 29 },
{ "PIPE", 13 },
{ "PROF", 27 },
{ "PWR", 30 },
{ "QUIT", 3 },
{ "STOP", 19 },
{ "SYS", 31 },
{ "TERM", 15 },
{ "TRAP", 5 },
{ "TSTP", 20 },
{ "TTIN", 21 },
{ "TTOU", 22 },
{ "URG", 23 },
{ "USR1", 10 },
{ "USR2", 12 },
{ "VTALRM", 26 },
{ "WINCH", 28 },
{ "XCPU", 24 },
{ "XFSZ", 25 },
{ "STKFLT", 16 },
EOF
LOCAL_CFLAGS="\
-I. -DMKSH_BUILDSH -D_GNU_SOURCE -DSETUID_CAN_FAIL_WITH_EAGAIN -DHAVE_ATTRIBUTE_BOUNDED=0 \
-DHAVE_ATTRIBUTE_FORMAT=1 -DHAVE_ATTRIBUTE_NORETURN=1 -DHAVE_ATTRIBUTE_UNUSED=1 -DHAVE_ATTRIBUTE_USED=1 \
-DHAVE_SYS_TIME_H=1 -DHAVE_TIME_H=1 -DHAVE_BOTH_TIME_H=1 -DHAVE_SYS_BSDTYPES_H=0 -DHAVE_SYS_FILE_H=1 \
-DHAVE_SYS_MKDEV_H=0 -DHAVE_SYS_MMAN_H=1 -DHAVE_SYS_PARAM_H=1 -DHAVE_SYS_RESOURCE_H=1 -DHAVE_SYS_SELECT_H=1 \
-DHAVE_SYS_SYSMACROS_H=1 -DHAVE_BSTRING_H=0 -DHAVE_GRP_H=1 -DHAVE_LIBGEN_H=1 -DHAVE_LIBUTIL_H=0 \
-DHAVE_PATHS_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_TERMIOS_H=1 -DHAVE_ULIMIT_H=1 -DHAVE_VALUES_H=1 \
-DHAVE_CAN_INTTYPES=1 -DHAVE_CAN_UCBINTS=1 -DHAVE_CAN_INT8TYPE=1 -DHAVE_CAN_UCBINT8=1 -DHAVE_RLIM_T=1 \
-DHAVE_SIG_T=1 -DHAVE_SYS_ERRLIST=0 -DHAVE_SYS_SIGNAME=0 -DHAVE_SYS_SIGLIST=0 -DHAVE_FLOCK=1 \
-DHAVE_LOCK_FCNTL=1 -DHAVE_GETRUSAGE=1 -DHAVE_GETTIMEOFDAY=1 -DHAVE_KILLPG=1 -DHAVE_MEMMOVE=1 \
-DHAVE_MKNOD=0 -DHAVE_MMAP=1 -DHAVE_NICE=1 -DHAVE_REVOKE=0 -DHAVE_SETLOCALE_CTYPE=1 \
-DHAVE_LANGINFO_CODESET=1 -DHAVE_SELECT=1 -DHAVE_SETRESUGID=1 -DHAVE_SETGROUPS=1 -DHAVE_STRERROR=1 \
-DHAVE_STRSIGNAL=1 -DHAVE_STRLCPY=1 -DHAVE_FLOCK_DECL=1 -DHAVE_REVOKE_DECL=1 -DHAVE_SYS_ERRLIST_DECL=0 \
-DHAVE_SYS_SIGLIST_DECL=0 -DHAVE_PERSISTENT_HISTORY=1 -DMKSH_BUILD_R=471"
SRC="\
edit.c \
eval.c \
exec.c \
expr.c \
funcs.c \
histrap.c \
jobs.c \
lalloc.c \
lex.c \
main.c \
misc.c \
shf.c \
strlcpy.c \
syn.c \
tree.c \
var.c"
for f in $SRC; do
$CC -c $f -o "${f%%.c}.o" $CFLAGS $LOCAL_CFLAGS
done
$CC -o mksh *.o $LDFLAGS
cp mksh "$root/bin"
mkdir -p "$root/share/man/man1"
cp mksh.1 "$root/share/man/man1/mksh.1"
cd "$root/bin"
ln -sf mksh sh
ln -sf mksh ksh

View File

@ -1,17 +0,0 @@
v="1.18.0"
url="$mirror/mpg123-$v.tar.bz2"
build: tinyalsa
cd src/mpg123-$v
case "$arch" in
x86_64)
A=x86-64
;;
i486)
A=x86
;;
esac
CC=$CC ./configure --prefix="$root" --with-default-audio=tinyalsa \
--enable-static=yes --enable-shared=no --with-cpu="$A"
make -j$nprocs
make install

View File

@ -1,18 +0,0 @@
v="5.9"
url="$mirror/ncurses.tar.gz"
build: crossmusl
cd src/ncurses-$v
cp $pkgdir/ncurses-fallback.c ncurses/fallback.c
CC="$CC -static" ./configure --prefix="$libcroot" --mandir="$root/share" \
--datadir="$root/share" --without-tests \
--with-normal --enable-sigwinch --disable-nls --without-dlsym \
--without-cxx-binding --enable-widec \
--with-fallbacks="linux vt100 xterm xterm256-color" </dev/ptmx
make -j$nprocs
make install
cd "$root/lib"
for lib in ncurses form panel menu ; do
ln -sf lib${lib}w_g.a lib${lib}_g.a
ln -sf lib${lib}w.a lib${lib}.a
done

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +0,0 @@
build:
mkdir -p "$root"
cd "$root"
mkdir -p boot bin dev emul etc home mnt opt proc root share src sys tmp var
mkdir -p opt/cross share/doc share/fonts/encodings share/man share/terminfo var/empty var/log var/run
rm -f include
ln -s "opt/cross/$arch-linux-musl/$arch-linux-musl/include" include
rm -f lib
ln -s "opt/cross/$arch-linux-musl/$arch-linux-musl/lib" lib
rm -f usr
ln -s . usr
rm -f sbin
ln -s bin sbin
rm -f var/tmp
ln -s ../tmp var/tmp
chmod 1777 tmp
chmod 700 root

View File

@ -1,45 +0,0 @@
From 3ebbf1c0dd5dfaee56e6fae28cefb7756180ff22 Mon Sep 17 00:00:00 2001
From: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Sat, 15 Feb 2014 15:09:55 +0100
Subject: [PATCH 2/3] remove unused code
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
---
quark.c | 16 ----------------
1 file changed, 16 deletions(-)
diff --git a/quark.c b/quark.c
index 152476a..565e091 100644
--- a/quark.c
+++ b/quark.c
@@ -31,27 +31,11 @@ typedef struct {
const char *mimetype;
} MimeType;
-typedef struct _Param Param;
-struct _Param {
- const char *key;
- const char *value;
- Param *next;
-};
-
typedef struct {
int type;
int fd;
- const char *hostname;
- const char *resource;
- Param *params;
} Request;
-typedef struct {
- const char *hostname;
- const char *resource;
- void (*handle)(const Request *r);
-} RequestHandler;
-
static const char HttpOk[] = "200 OK";
static const char HttpMoved[] = "301 Moved Permanently";
static const char HttpUnauthorized[] = "401 Unauthorized";
--
1.8.5.3

View File

@ -1,151 +0,0 @@
From aca12949c1ca39a107abdd02ca76b4a5937ca643 Mon Sep 17 00:00:00 2001
From: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Sat, 15 Feb 2014 15:36:52 +0100
Subject: [PATCH 3/3] implement http not modified
On each request send "last-modified" header with the modification time of
each file. the client will store this field and send it on the next
request(s). On the server check the "if-modified-since" field with the
modified date sent by the client, depending on this send all the data or
the "304 not modified" http status.
CAVEAT: it is assumed the exact field will be send by the client, no date/time
conversion is done for simplicity sake, as far as that's possible with http ;)
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
---
quark.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++----------------
1 file changed, 57 insertions(+), 18 deletions(-)
diff --git a/quark.c b/quark.c
index 565e091..33f5b10 100644
--- a/quark.c
+++ b/quark.c
@@ -38,6 +38,7 @@ typedef struct {
static const char HttpOk[] = "200 OK";
static const char HttpMoved[] = "301 Moved Permanently";
+static const char HttpNotModified[] = "304 Not Modified";
static const char HttpUnauthorized[] = "401 Unauthorized";
static const char HttpNotFound[] = "404 Not Found";
static const char texthtml[] = "text/html";
@@ -67,6 +68,7 @@ static char host[NI_MAXHOST];
static char reqbuf[MAXBUFLEN+1];
static char resbuf[MAXBUFLEN+1];
static char reqhost[256];
+static char reqmod[256];
static int fd;
static Request req;
@@ -184,6 +186,18 @@ responsecontenttype(const char *mimetype) {
return writetext(resbuf);
}
+int
+responsemodified(char *mod) {
+ if(snprintf(resbuf, MAXBUFLEN,
+ "Last-Modified: %s\r\n",
+ mod) >= MAXBUFLEN)
+ {
+ logerrmsg("snprintf failed, buffer sizeof exceeded");
+ return -1;
+ }
+ return writetext(resbuf);
+}
+
void
responsefiledata(int fd, off_t size) {
char buf[BUFSIZ];
@@ -200,10 +214,13 @@ void
responsefile(void) {
const char *mimetype = "unknown";
char *p;
- int i, ffd;
+ char mod[25];
+ int i, ffd, r;
struct stat st;
+ time_t t;
- if(stat(reqbuf, &st) == -1 || (ffd = open(reqbuf, O_RDONLY)) == -1) {
+ r = stat(reqbuf, &st);
+ if(r == -1 || (ffd = open(reqbuf, O_RDONLY)) == -1) {
logerrmsg("%s requests unknown path %s\n", host, reqbuf);
if(responsehdr(HttpNotFound) != -1
&& responsecontenttype(texthtml) != -1)
@@ -214,22 +231,33 @@ responsefile(void) {
writetext("\r\n<html><body>404 Not Found</body></html>\r\n");
}
else {
- if((p = strrchr(reqbuf, '.'))) {
- p++;
- for(i = 0; i < LENGTH(servermimes); i++)
- if(!strcmp(servermimes[i].extension, p)) {
- mimetype = servermimes[i].mimetype;
- break;
- }
+ t = st.st_mtim.tv_sec;
+ memcpy(mod, asctime(gmtime(&t)), 24);
+ mod[24] = 0;
+ if(!strcmp(reqmod, mod)) {
+ if(responsehdr(HttpNotModified) != -1)
+ ;
+ else
+ return;
+ } else {
+ if((p = strrchr(reqbuf, '.'))) {
+ p++;
+ for(i = 0; i < LENGTH(servermimes); i++)
+ if(!strcmp(servermimes[i].extension, p)) {
+ mimetype = servermimes[i].mimetype;
+ break;
+ }
+ }
+ if(responsehdr(HttpOk) != -1
+ && responsemodified(mod) != -1
+ && responsecontentlen(st.st_size) != -1
+ && responsecontenttype(mimetype) != -1)
+ ;
+ else
+ return;
+ if(req.type == GET && writetext("\r\n") != -1)
+ responsefiledata(ffd, st.st_size);
}
- if(responsehdr(HttpOk) != -1
- && responsecontentlen(st.st_size) != -1
- && responsecontenttype(mimetype) != -1)
- ;
- else
- return;
- if(req.type == GET && writetext("\r\n") != -1)
- responsefiledata(ffd, st.st_size);
close(ffd);
}
}
@@ -388,12 +416,23 @@ request(void) {
for(p = res; *p && *p != ' ' && *p != '\t' && *p != '\r' && *p != '\n'; p++);
if(!*p)
goto invalid_request;
- *p = 0;
if(p - res > sizeof reqhost)
goto invalid_request;
memcpy(reqhost, res, p - res);
reqhost[p - res] = 0;
}
+ if((res = strstr(reqbuf, "If-Modified-Since:"))) {
+ for(res = res + 19; *res && (*res == ' ' || *res == '\t'); res++);
+ if(!*res)
+ goto invalid_request;
+ for(p = res; *p && *p != '\r' && *p != '\n'; p++);
+ if(!*p)
+ goto invalid_request;
+ if(p - res > sizeof reqmod)
+ goto invalid_request;
+ memcpy(reqmod, res, p - res);
+ reqmod[p - res] = 0;
+ }
for(p = reqbuf; *p && *p != '\r' && *p != '\n'; p++);
if(*p == '\r' || *p == '\n') {
*p = 0;
--
1.8.5.3

View File

@ -1,10 +0,0 @@
git="git://git.suckless.org/quark"
build: crossmusl
set -x
cd src/quark
git am -3 "$pkgdir/0002-remove-unused-code.patch"
git am -3 "$pkgdir/0003-implement-http-not-modified.patch"
cp config.def.h config.h
$CC -o quark quark.c -DVERSION=\"0.1\" $CFLAGS $LDFLAGS
cp quark "$root/bin"

View File

@ -1,8 +0,0 @@
v="3.0.9"
url="$mirror/rsync-$v.tar.gz"
build: crossmusl
cd src/rsync-$v
CC=$CC ./configure --prefix="$root"
make -j$nprocs
make install

View File

@ -1,31 +0,0 @@
v="0.0"
git="git://git.2f30.org/sbase"
build: crossmusl
set -x
cd src/sbase
for f in util/*.c; do
$CC -c $f -o "${f%%.c}.o" $CFLAGS
done
for f in util/*.o; do
ar -r -c util.a $f
done
ranlib util.a
for f in *.c; do
$CC -c $f $CFLAGS
done
for f in *.o; do
$CC -o "${f%.*}" $f util.a $LDFLAGS
done
for f in *.o; do
cp "${f%.*}" "$root/bin"
done
mkdir -p "$root/share/man/man1"
for f in *.1; do
sed -e "s/VERSION/$v/g" $f > $root/share/man/man1/$f
done
# these are still buggy
for f in grep cp tar ; do
rm "$root/bin/$f"
rm "$root/share/man/man1/$f.1"
done

View File

@ -1,9 +0,0 @@
git="git://git.2f30.org/sdhcp"
build: crossmusl
set -x
cd src/sdhcp
$CC -o sdhcp sdhcp.c $CFLAGS $LDFLAGS
cp sdhcp "$root/bin"
mkdir -p "$root/share/man/man8"
cp sdhcp.8 "$root/share/man/man8"

View File

@ -1,7 +0,0 @@
url="$mirror/sic.tar.gz"
build: crossmusl
set -x
cd src/sic
$CC -o sic sic.c -DVERSION=\"1.3\" $CFLAGS $LDFLAGS
cp sic "$root/bin"

View File

@ -1,10 +0,0 @@
git="git://git.2f30.org/sinit"
build: crossmusl
set -x
cd src/sinit
cp config.def.h config.h
$CC -o sinit sinit.c $CFLAGS $LDFLAGS
cp sinit "$root/bin"
cd "$root/bin"
ln -sf sinit init

View File

@ -1,22 +0,0 @@
git="git://git.2f30.org/smdev"
build: crossmusl
set -x
cd src/smdev
cp config.def.h config.h
for f in util/*.c; do
$CC -c $f -o "${f%%.c}.o" $CFLAGS
done
for f in util/*.o; do
ar -r -c util.a $f
done
ranlib util.a
for f in *.c; do
$CC -c $f $CFLAGS
done
for f in *.o; do
$CC -o "${f%.*}" $f util.a $LDFLAGS
done
for f in *.o; do
cp "${f%.*}" "$root/bin"
done

View File

@ -1,2 +0,0 @@
build: 9base busybox crossmusl file fs make man mksh \
prepare_root sbase sinit smdev ubase zlib

View File

@ -1,15 +0,0 @@
v="4.38"
url="$mirror/terminus-font-$v.tar.gz"
build: crossmusl
cd src/terminus-font-$v
sh configure --psfdir="$root/share/fonts/console" \
--x11dir="$root/share/fonts/misc"
make -j$nprocs
make DESTDIR=/ install
cd "$root/share/fonts/misc"
gzip -d *.gz
mkfontscale
mkfontdir
cd "$root/share/fonts/console"
gzip -d *.gz

View File

@ -1,16 +0,0 @@
url="$mirror/tinyalsa.tar.gz"
build: crossmusl
set -x
cd src/tinyalsa
$CC -c mixer.c -Iinclude $CFLAGS
$CC -c pcm.c -Iinclude $CFLAGS
ar -r -c libtinyalsa.a mixer.o pcm.o
ranlib libtinyalsa.a
$CC tinyplay.c -o tinyplay -Iinclude $CFLAGS -L. -ltinyalsa $LDFLAGS
$CC tinycap.c -o tinycap -Iinclude $CFLAGS -L. -ltinyalsa $LDFLAGS
$CC tinymix.c -o tinymix -Iinclude $CFLAGS -L. -ltinyalsa $LDFLAGS
$CC tinypcminfo.c -o tinypcminfo -Iinclude $CFLAGS -L. -ltinyalsa $LDFLAGS
cp tinycap tinymix tinypcminfo tinyplay "$root/bin"
cp libtinyalsa.a "$root/lib"
cp -r include/tinyalsa "$root/include"

View File

@ -1,5 +0,0 @@
build: tinyxlib
set -x
cd src
$CC $pkgdir/tinywm.c -o tinywm -lX11 $CFLAGS $LDFLAGS
cp tinywm "$root/bin"

View File

@ -1,58 +0,0 @@
/* TinyWM is written by Nick Welch <mack@incise.org>, 2005.
*
* This software is in the public domain
* and is provided AS IS, with NO WARRANTY. */
#include <X11/Xlib.h>
#define MAX(a, b) ((a) > (b) ? (a) : (b))
int main()
{
Display * dpy;
Window root;
XWindowAttributes attr;
XButtonEvent start;
XEvent ev;
if(!(dpy = XOpenDisplay(0x0))) return 1;
root = DefaultRootWindow(dpy);
XGrabKey(dpy, XKeysymToKeycode(dpy, XStringToKeysym("F1")), Mod1Mask, root,
True, GrabModeAsync, GrabModeAsync);
XGrabButton(dpy, 1, Mod1Mask, root, True, ButtonPressMask, GrabModeAsync,
GrabModeAsync, None, None);
XGrabButton(dpy, 3, Mod1Mask, root, True, ButtonPressMask, GrabModeAsync,
GrabModeAsync, None, None);
for(;;)
{
XNextEvent(dpy, &ev);
if(ev.type == KeyPress && ev.xkey.subwindow != None)
XRaiseWindow(dpy, ev.xkey.subwindow);
else if(ev.type == ButtonPress && ev.xbutton.subwindow != None)
{
XGrabPointer(dpy, ev.xbutton.subwindow, True,
PointerMotionMask|ButtonReleaseMask, GrabModeAsync,
GrabModeAsync, None, None, CurrentTime);
XGetWindowAttributes(dpy, ev.xbutton.subwindow, &attr);
start = ev.xbutton;
}
else if(ev.type == MotionNotify)
{
int xdiff, ydiff;
while(XCheckTypedEvent(dpy, MotionNotify, &ev));
xdiff = ev.xbutton.x_root - start.x_root;
ydiff = ev.xbutton.y_root - start.y_root;
XMoveResizeWindow(dpy, ev.xmotion.window,
attr.x + (start.button==1 ? xdiff : 0),
attr.y + (start.button==1 ? ydiff : 0),
MAX(1, attr.width + (start.button==3 ? xdiff : 0)),
MAX(1, attr.height + (start.button==3 ? ydiff : 0)));
}
else if(ev.type == ButtonRelease)
XUngrabPointer(dpy, CurrentTime);
}
}

View File

@ -1,8 +0,0 @@
url="$mirror/tinyxlib.tar.gz"
build: crossmusl
cd src/tinyxlib
make clean
make -j$nprocs CC=$CC BINDIR="/bin" LIBDIR="/lib" STATIC=1 \
FONT_ENCODINGS_DIRECTORY="/share/fonts/encodings/encodings.dir"
make DESTDIR="$libcroot" BINDIR="/bin" LIBDIR="/lib" STATIC=1 install

View File

@ -1,19 +0,0 @@
url="$mirror/tinyxserver.tar.gz"
build: tinyxlib zlib
cd src/tinyxserver
case "$arch" in
x86_64)
EXTRA_CFLAGS="-D_XSERVER64=1 $CFLAGS"
;;
i486)
EXTRA_CFLAGS="$CFLAGS"
;;
esac
make clean
make -j$nprocs CC=$CC EXTRA_CFLAGS="$EXTRA_CFLAGS" \
FONTDIR="/usr/share/fonts"
make DESTDIR="$root" BINDIR="/bin" install
cd "$root/usr/share/fonts/misc"
mkfontscale
mkfontdir

View File

@ -1,9 +0,0 @@
v="1.8"
url="$mirror/tmux-$v.tar.gz"
build: ncurses libevent
cd src/tmux-$v
CC=$CC ./configure --prefix="$root" \
CFLAGS="-I$libcroot/include/ncursesw $CFLAGS"
make -j$nprocs
make install

View File

@ -1,31 +0,0 @@
v=0.0
git="git://git.2f30.org/ubase"
build: crossmusl
set -x
cd src/ubase
cp config.def.h config.h
for f in util/*.c; do
$CC -c $f -o "${f%%.c}.o" $CFLAGS
done
for f in util/*.o; do
ar -r -c util.a $f
done
ranlib util.a
for f in *.c; do
$CC -c $f $CFLAGS
done
for f in *.o; do
$CC -o "${f%.*}" $f util.a $LDFLAGS
done
for f in *.o; do
cp "${f%.*}" "$root/bin"
done
mkdir -p "$root/share/man/man1"
for f in *.1; do
sed -e "s/VERSION/$v/g" $f > $root/share/man/man1/$f
done
mkdir -p "$root/share/man/man8"
for f in *.8; do
cp $f "$root/share/man/man8"
done

View File

@ -1,7 +0,0 @@
url="$mirror/uuterm.tar.gz"
build: tinyxlib
cd src/uuterm
make clean
make CC=$CC LDFLAGS_X11="$LDFLAGS" uuterm-x11
cp uuterm-x11 "$root/bin"

View File

@ -1,12 +0,0 @@
v="7.4"
url="http://ftp.vim.org/pub/vim/unix/vim-$v.tar.bz2"
build: ncurses
cd src/vim74
make clean
CC=$CC ./configure --prefix=/ \
--enable-multibyte --disable-gui --with-x=no \
--disable-nls --disable-netbeans
make -j$nprocs
make DESTDIR="$root" install
ln -sf vim "$root/bin/vi"

View File

@ -1,5 +0,0 @@
build: tinyxlib
set -x
cd src
$CC $pkgdir/xsetroot.c -o xsetroot -lX11 $CFLAGS $LDFLAGS
cp xsetroot "$root/bin"

View File

@ -1,545 +0,0 @@
/*
*
Copyright 1987, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
/*
* xsetroot.c MIT Project Athena, X Window System root window
* parameter setting utility. This program will set
* various parameters of the X root window.
*
* Author: Mark Lillibridge, MIT Project Athena
* 11-Jun-87
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/Xmu/CurUtil.h>
#include <X11/Xcursor/Xcursor.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "X11/bitmaps/gray"
#define Dynamic 1
static char *program_name;
static Display *dpy;
static int screen;
static Window root;
static char *fore_color = NULL;
static char *back_color = NULL;
static int reverse = 0;
static int save_colors = 0;
static int unsave_past = 0;
static Pixmap save_pixmap = (Pixmap)None;
static void usage(void) _X_NORETURN;
static void FixupState(void);
static void SetBackgroundToBitmap(Pixmap bitmap,
unsigned int width, unsigned int height);
static Cursor CreateCursorFromFiles(char *cursor_file, char *mask_file);
static Cursor CreateCursorFromName(char *name);
static Pixmap MakeModulaBitmap(int mod_x, int mod_y);
static XColor NameToXColor(char *name, unsigned long pixel);
static unsigned long NameToPixel(char *name, unsigned long pixel);
static Pixmap ReadBitmapFile(char *filename, unsigned int *width, unsigned int *height, int *x_hot, int *y_hot);
static void
usage(void)
{
fprintf(stderr, "usage: %s [options]\n%s\n", program_name,
" where options are:\n"
" -display <display> or -d <display>\n"
" -fg <color> or -foreground <color>\n"
" -bg <color> or -background <color>\n"
" -rv or -reverse\n"
" -def or -default\n"
" -name <string>\n"
" -cursor <cursor file> <mask file>\n"
" -cursor_name <cursor-font name>\n"
" -xcf <ARGB cursor file> <cursor size>\n"
" -solid <color>\n"
" -gray or -grey\n"
" -bitmap <filename>\n"
" -mod <x> <y>\n"
" -help\n"
" -version\n"
);
exit(1);
/*NOTREACHED*/
}
int
main(int argc, char *argv[])
{
int excl = 0;
int nonexcl = 0;
int restore_defaults = 0;
char *display_name = NULL;
char *name = NULL;
char *cursor_file = NULL;
char *cursor_mask = NULL;
char *cursor_name = NULL;
char *solid_color = NULL;
char *xcf = NULL;
int xcf_size = 32;
Cursor cursor;
int gray = 0;
char *bitmap_file = NULL;
int mod_x = 0;
int mod_y = 0;
register int i;
unsigned int ww, hh;
Pixmap bitmap;
program_name=argv[0];
for (i = 1; i < argc; i++) {
if (!strcmp ("-display", argv[i]) || !strcmp ("-d", argv[i])) {
if (++i>=argc) usage ();
display_name = argv[i];
continue;
}
if (!strcmp("-help", argv[i])) {
usage();
}
if (!strcmp("-version", argv[i])) {
printf("%s\n", "1.1.1");
exit(0);
}
if (!strcmp("-def", argv[i]) || !strcmp("-default", argv[i])) {
restore_defaults = 1;
continue;
}
if (!strcmp("-name", argv[i])) {
if (++i>=argc) usage();
name = argv[i];
nonexcl++;
continue;
}
if (!strcmp("-cursor", argv[i])) {
if (++i>=argc) usage();
cursor_file = argv[i];
if (++i>=argc) usage();
cursor_mask = argv[i];
nonexcl++;
continue;
}
if (!strcmp("-cursor_name", argv[i])) {
if (++i>=argc) usage();
cursor_name = argv[i];
nonexcl++;
continue;
}
if (!strcmp("-xcf", argv[i])) {
if (++i>=argc) usage();
xcf = argv[i];
if (++i>=argc) usage();
xcf_size = atoi(argv[i]);
if (xcf_size <= 0)
xcf_size = 32;
nonexcl++;
continue;
}
if (!strcmp("-fg",argv[i]) || !strcmp("-foreground",argv[i])) {
if (++i>=argc) usage();
fore_color = argv[i];
continue;
}
if (!strcmp("-bg",argv[i]) || !strcmp("-background",argv[i])) {
if (++i>=argc) usage();
back_color = argv[i];
continue;
}
if (!strcmp("-solid", argv[i])) {
if (++i>=argc) usage();
solid_color = argv[i];
excl++;
continue;
}
if (!strcmp("-gray", argv[i]) || !strcmp("-grey", argv[i])) {
gray = 1;
excl++;
continue;
}
if (!strcmp("-bitmap", argv[i])) {
if (++i>=argc) usage();
bitmap_file = argv[i];
excl++;
continue;
}
if (!strcmp("-mod", argv[i])) {
if (++i>=argc) usage();
mod_x = atoi(argv[i]);
if (mod_x <= 0) mod_x = 1;
if (++i>=argc) usage();
mod_y = atoi(argv[i]);
if (mod_y <= 0) mod_y = 1;
excl++;
continue;
}
if (!strcmp("-rv",argv[i]) || !strcmp("-reverse",argv[i])) {
reverse = 1;
continue;
}
usage();
}
/* Check for multiple use of exclusive options */
if (excl > 1) {
fprintf(stderr, "%s: choose only one of {solid, gray, bitmap, mod}\n",
program_name);
usage();
}
dpy = XOpenDisplay(display_name);
if (!dpy) {
fprintf(stderr, "%s: unable to open display '%s'\n",
program_name, XDisplayName (display_name));
exit (2);
}
screen = DefaultScreen(dpy);
root = RootWindow(dpy, screen);
/* If there are no arguments then restore defaults. */
if (!excl && !nonexcl)
restore_defaults = 1;
/* Handle a cursor file */
if (cursor_file) {
cursor = CreateCursorFromFiles(cursor_file, cursor_mask);
XDefineCursor(dpy, root, cursor);
XFreeCursor(dpy, cursor);
}
if (cursor_name) {
cursor = CreateCursorFromName (cursor_name);
if (cursor)
{
XDefineCursor (dpy, root, cursor);
XFreeCursor (dpy, cursor);
}
}
if (xcf) {
XcursorImages *images = XcursorFilenameLoadImages(xcf, xcf_size);
if (!images) {
fprintf(stderr, "Invalid cursor file \"%s\"\n", xcf);
} else {
cursor = XcursorImagesLoadCursor(dpy, images);
if (cursor)
{
XDefineCursor (dpy, root, cursor);
XFreeCursor (dpy, cursor);
}
}
}
/* Handle -gray and -grey options */
if (gray) {
bitmap = XCreateBitmapFromData(dpy, root, gray_bits,
gray_width, gray_height);
SetBackgroundToBitmap(bitmap, gray_width, gray_height);
}
/* Handle -solid option */
if (solid_color) {
XSetWindowBackground(dpy, root, NameToPixel(solid_color,
BlackPixel(dpy, screen)));
XClearWindow(dpy, root);
unsave_past = 1;
}
/* Handle -bitmap option */
if (bitmap_file) {
bitmap = ReadBitmapFile(bitmap_file, &ww, &hh, (int *)NULL, (int *)NULL);
SetBackgroundToBitmap(bitmap, ww, hh);
}
/* Handle set background to a modula pattern */
if (mod_x) {
bitmap = MakeModulaBitmap(mod_x, mod_y);
SetBackgroundToBitmap(bitmap, 16, 16);
}
/* Handle set name */
if (name)
XStoreName(dpy, root, name);
/* Handle restore defaults */
if (restore_defaults) {
if (!cursor_file)
XUndefineCursor(dpy, root);
if (!excl) {
XSetWindowBackgroundPixmap(dpy, root, (Pixmap) None);
XClearWindow(dpy, root);
unsave_past = 1;
}
}
FixupState();
XCloseDisplay(dpy);
exit (0);
}
/* Free past incarnation if needed, and retain state if needed. */
static void
FixupState(void)
{
Atom prop, type;
int format;
unsigned long length, after;
unsigned char *data;
if (!(DefaultVisual(dpy, screen)->class & Dynamic))
unsave_past = 0;
if (!unsave_past && !save_colors)
return;
prop = XInternAtom(dpy, "_XSETROOT_ID", False);
if (unsave_past) {
(void)XGetWindowProperty(dpy, root, prop, 0L, 1L, True, AnyPropertyType,
&type, &format, &length, &after, &data);
if ((type == XA_PIXMAP) && (format == 32) &&
(length == 1) && (after == 0))
XKillClient(dpy, *((Pixmap *)data));
else if (type != None)
fprintf(stderr, "%s: warning: _XSETROOT_ID property is garbage\n",
program_name);
}
if (save_colors) {
if (!save_pixmap)
save_pixmap = XCreatePixmap(dpy, root, 1, 1, 1);
XChangeProperty(dpy, root, prop, XA_PIXMAP, 32, PropModeReplace,
(unsigned char *) &save_pixmap, 1);
XSetCloseDownMode(dpy, RetainPermanent);
}
}
/*
* SetBackgroundToBitmap: Set the root window background to a caller supplied
* bitmap.
*/
static void
SetBackgroundToBitmap(Pixmap bitmap, unsigned int width, unsigned int height)
{
Pixmap pix;
GC gc;
XGCValues gc_init;
gc_init.foreground = NameToPixel(fore_color, BlackPixel(dpy, screen));
gc_init.background = NameToPixel(back_color, WhitePixel(dpy, screen));
if (reverse) {
unsigned long temp=gc_init.foreground;
gc_init.foreground=gc_init.background;
gc_init.background=temp;
}
gc = XCreateGC(dpy, root, GCForeground|GCBackground, &gc_init);
pix = XCreatePixmap(dpy, root, width, height,
(unsigned int)DefaultDepth(dpy, screen));
XCopyPlane(dpy, bitmap, pix, gc, 0, 0, width, height, 0, 0, (unsigned long)1);
XSetWindowBackgroundPixmap(dpy, root, pix);
XFreeGC(dpy, gc);
XFreePixmap(dpy, bitmap);
if (save_colors)
save_pixmap = pix;
else
XFreePixmap(dpy, pix);
XClearWindow(dpy, root);
unsave_past = 1;
}
/*
* CreateCursorFromFiles: make a cursor of the right colors from two bitmap
* files.
*/
#define BITMAP_HOT_DEFAULT 8
static Cursor
CreateCursorFromFiles(char *cursor_file, char *mask_file)
{
Pixmap cursor_bitmap, mask_bitmap;
unsigned int width, height, ww, hh;
int x_hot, y_hot;
Cursor cursor;
XColor fg, bg, temp;
fg = NameToXColor(fore_color, BlackPixel(dpy, screen));
bg = NameToXColor(back_color, WhitePixel(dpy, screen));
if (reverse) {
temp = fg; fg = bg; bg = temp;
}
cursor_bitmap = ReadBitmapFile(cursor_file, &width, &height, &x_hot, &y_hot);
mask_bitmap = ReadBitmapFile(mask_file, &ww, &hh, (int *)NULL, (int *)NULL);
if (width != ww || height != hh) {
fprintf(stderr,
"%s: dimensions of cursor bitmap and cursor mask bitmap are different\n",
program_name);
exit(1);
/*NOTREACHED*/
}
if ((x_hot == -1) && (y_hot == -1)) {
x_hot = BITMAP_HOT_DEFAULT;
y_hot = BITMAP_HOT_DEFAULT;
}
if ((x_hot < 0) || (x_hot >= width) ||
(y_hot < 0) || (y_hot >= height)) {
fprintf(stderr, "%s: hotspot is outside cursor bounds\n", program_name);
exit(1);
/*NOTREACHED*/
}
cursor = XCreatePixmapCursor(dpy, cursor_bitmap, mask_bitmap, &fg, &bg,
(unsigned int)x_hot, (unsigned int)y_hot);
XFreePixmap(dpy, cursor_bitmap);
XFreePixmap(dpy, mask_bitmap);
return(cursor);
}
static Cursor
CreateCursorFromName(char *name)
{
XColor fg, bg, temp;
int i;
Font fid;
fg = NameToXColor(fore_color, BlackPixel(dpy, screen));
bg = NameToXColor(back_color, WhitePixel(dpy, screen));
if (reverse) {
temp = fg; fg = bg; bg = temp;
}
i = XmuCursorNameToIndex (name);
if (i == -1)
return (Cursor) 0;
fid = XLoadFont (dpy, "cursor");
if (!fid)
return (Cursor) 0;
return XCreateGlyphCursor (dpy, fid, fid,
i, i+1, &fg, &bg);
}
/*
* MakeModulaBitmap: Returns a modula bitmap based on an x & y mod.
*/
static Pixmap
MakeModulaBitmap(int mod_x, int mod_y)
{
int i;
long pattern_line = 0;
char modula_data[16*16/8];
for (i=16; i--; ) {
pattern_line <<=1;
if ((i % mod_x) == 0) pattern_line |= 0x0001;
}
for (i=0; i<16; i++) {
if ((i % mod_y) == 0) {
modula_data[i*2] = (char)0xff;
modula_data[i*2+1] = (char)0xff;
} else {
modula_data[i*2] = pattern_line & 0xff;
modula_data[i*2+1] = (pattern_line>>8) & 0xff;
}
}
return(XCreateBitmapFromData(dpy, root, modula_data, 16, 16));
}
/*
* NameToXColor: Convert the name of a color to its Xcolor value.
*/
static XColor
NameToXColor(char *name, unsigned long pixel)
{
XColor c;
if (!name || !*name) {
c.pixel = pixel;
XQueryColor(dpy, DefaultColormap(dpy, screen), &c);
} else if (!XParseColor(dpy, DefaultColormap(dpy, screen), name, &c)) {
fprintf(stderr, "%s: unknown color or bad color format: %s\n",
program_name, name);
exit(1);
/*NOTREACHED*/
}
return(c);
}
static unsigned long
NameToPixel(char *name, unsigned long pixel)
{
XColor ecolor;
if (!name || !*name)
return pixel;
if (!XParseColor(dpy,DefaultColormap(dpy,screen),name,&ecolor)) {
fprintf(stderr,"%s: unknown color \"%s\"\n",program_name,name);
exit(1);
/*NOTREACHED*/
}
if (!XAllocColor(dpy, DefaultColormap(dpy, screen),&ecolor)) {
fprintf(stderr, "%s: unable to allocate color for \"%s\"\n",
program_name, name);
exit(1);
/*NOTREACHED*/
}
if ((ecolor.pixel != BlackPixel(dpy, screen)) &&
(ecolor.pixel != WhitePixel(dpy, screen)) &&
(DefaultVisual(dpy, screen)->class & Dynamic))
save_colors = 1;
return(ecolor.pixel);
}
static Pixmap
ReadBitmapFile(char *filename, unsigned int *width, unsigned int *height,
int *x_hot, int *y_hot)
{
Pixmap bitmap;
int status;
status = XReadBitmapFile(dpy, root, filename, width,
height, &bitmap, x_hot, y_hot);
if (status == BitmapSuccess)
return(bitmap);
else if (status == BitmapOpenFailed)
fprintf(stderr, "%s: can't open file: %s\n", program_name, filename);
else if (status == BitmapFileInvalid)
fprintf(stderr, "%s: bad bitmap format file: %s\n",
program_name, filename);
else
fprintf(stderr, "%s: insufficient memory for bitmap: %s",
program_name, filename);
exit(1);
/*NOTREACHED*/
}

View File

@ -1,8 +0,0 @@
v="1.2.8"
url="$mirror/zlib-$v.tar.gz"
build: crossmusl
cd src/zlib-$v
CC=$CC ./configure --prefix="$root" --libdir="$libcroot/lib" --static
make -j$nprocs
make install

View File

@ -1,4 +0,0 @@
#!/bin/sh
pkg=`echo $1 | sed -e 's,-fetch$,,'`
cmp -s .cache/$1 pkgs/$pkg/build

View File

@ -1,3 +0,0 @@
#!/bin/sh
cmp -s .cache/$1 pkgs/$1/build

View File

@ -1,33 +0,0 @@
cp $pkgdir/build $top/.cache/$target
pkgdir=
fetch-target:
cd src
pkg=`echo $target | sed -e 's,-fetch$,,'`
eval url=$url
if test "$url" = ""; then
if test "$git" != ""; then
[ -d $pkg ] || git clone $git $pkg
fi
else
wget -c $url
file=`basename $url`
type=`file -b $file | cut -d ' ' -f 1`
case "$type" in
gzip)
tar -xzf $file
;;
bzip2)
tar -xjf $file
;;
XZ)
tar -xJf $file
;;
*)
echo "Unknown file type $type" 1>&2
exit 1
;;
esac
fi
cp $pkgdir/build $top/.cache/$target

View File

@ -1,27 +0,0 @@
#!/bin/sh
f=`pwd`/`dirname $0`
p=$1
printf '# auto-generated file, do not edit\n'
cd $p
for pkg in *; do
deps=$(cat $pkg/build | sed -e 'N;s,\\\n, ,' | grep ^build: | cut -d ':' -f 2-)
fdeps=`for d in $deps; do echo -n "$d-fetch "; done`
cat $pkg/build $f/fetch-pkg.mk |
sed -e "s,^build:,$pkg:QP${f}/cmp-pkgs: $pkg-fetch `pwd`/$pkg/build," \
-e "s,^fetch-target:,$pkg-fetch:QP${f}/cmp-fetch: $fdeps," \
-e "s,^v=,_${pkg}_v=," \
-e "s,^pkgdir=,_${pkg}_pkgdir=`pwd`/$pkg," \
-e "s,\$v,\${_${pkg}_v},g" \
-e "s,\$pkgdir,\${_${pkg}_pkgdir},g" \
-e "s,\$url,\${_${pkg}_url},g" \
-e "s, url=, _${pkg}_url=,g" \
-e "s,\$git,\${_${pkg}_git},g" \
-e "s,^git=,_${pkg}_git=," \
-e "s,^url=,_${pkg}_url=,"
echo
done