Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide static binaries. #60

Closed
lslvr opened this issue Jan 17, 2019 · 5 comments
Closed

Provide static binaries. #60

lslvr opened this issue Jan 17, 2019 · 5 comments

Comments

@lslvr
Copy link

lslvr commented Jan 17, 2019

Are there chances of having wmutils compiled as a single-file binary, in a similar fashion to busybox?

@z3bra
Copy link
Contributor

z3bra commented Jan 18, 2019 via email

@lslvr
Copy link
Author

lslvr commented Jan 18, 2019

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.

@dcat
Copy link
Member

dcat commented Jan 30, 2019

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

@lslvr
Copy link
Author

lslvr commented Jan 30, 2019

Thank you very much, @dcat! I'll keep this on a fork.

@lslvr lslvr closed this as completed Jan 30, 2019
@lslvr
Copy link
Author

lslvr commented Jan 31, 2019

The binary can be found on Github releases, just in case somebody else is interested on it. They're generated on Travis CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants