Closed lslvr closed 5 years ago
On Jan 17, Luis Lavaire wrote:
Are there chances of having
wmutils
compiled as a single-file binary, in a similar fashion tobusybox
?
This is an interresting idea. That would be a major redesign though, so we'll consider it first.
Thanks for your response. I guessed it could involve major changes to the code (just guessed, as I'm not a C programmer). One thing that I like a lot about busybox
is the compact size of the binary, which is very helpful for embedded systems.
this is something that shouldn't be committed, at least not to the master branch.
however, I wrote a script that will statically compile all of them in to a single binary called wmbox
.
#!/bin/sh
CC=cc
rm -f wmbox.c wmbox
SRC="`ls *.c`"
for i in $SRC
do
sed "s/^main/${i%.c}_main/" $i | $CC -c -xc -o ${i%c}o -
echo extern int ${i%.c}_main '(int, char **);' >>wmbox.c
done
cat << EOF >>wmbox.c
#include <string.h>
#include <stdio.h>
int main(int argc, char **argv) {
argc--; *argv++;
if (!argc)
return 0;
EOF
for i in $SRC
do
[ $i = "util.c" -o $i = "wmbox.c" ] && continue
echo " if (!strcmp(*argv, \"${i%.c}\")) return ${i%.c}_main(argc, argv);" >>wmbox.c
done
echo 'return 1;}' >>wmbox.c
${CC} -c wmbox.c
${CC} -o wmbox *.o -static -lxcb -lxcb-util -pthread -lX11 -lXau -lXdmcp
rm -f *.o
Thank you very much, @dcat! I'll keep this on a fork.
The binary can be found on Github releases, just in case somebody else is interested on it. They're generated on Travis CI.
Are there chances of having
wmutils
compiled as a single-file binary, in a similar fashion tobusybox
?