Mercurial > hg > aboriginal
changeset 83:8fb80545fe84
Move the "hello world" source into sources/toys. Build (in mini-native)
tools/bin/hello-{dynamic,static} to make debugging qemu system emulation
easier via "init=/tools/bin/hello-static" and such.
author | Rob Landley <rob@landley.net> |
---|---|
date | Fri, 12 Jan 2007 15:25:59 -0500 |
parents | 7b1360b20d9c |
children | fd38aafb06b1 |
files | cross-compiler.sh mini-native.sh sources/toys/hello.c sources/toys/thread-hello.c |
diffstat | 4 files changed, 32 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/cross-compiler.sh Fri Jan 12 02:59:26 2007 -0500 +++ b/cross-compiler.sh Fri Jan 12 15:25:59 2007 -0500 @@ -110,21 +110,10 @@ [ $? -ne 0 ] && dienow # A quick hello world program to test the cross-compiler out. - -cat > "$WORK"/hello.c << 'EOF' && -#include <stdio.h> - -int main(int argc, char *argv[]) -{ - printf("Hello world!\n"); - return 0; -} -EOF - # Build hello.c dynamic, then static, to verify header/library paths. -"${ARCH}-gcc" -Os "$WORK"/hello.c -o "$WORK"/hello && -"${ARCH}-gcc" -Os -static "$WORK"/hello.c -o "$WORK"/hello && +"${ARCH}-gcc" -Os "${SOURCES}/toys/hello.c" -o "$WORK"/hello && +"${ARCH}-gcc" -Os -static "${SOURCES}/toys/hello.c" -o "$WORK"/hello && ([ -z "${QEMU_TEST}" ] || [ x"$(qemu-"${KARCH}" "${WORK}"/hello)" == x"Hello world!" ]) && echo Cross-toolchain seems to work.
--- a/mini-native.sh Fri Jan 12 02:59:26 2007 -0500 +++ b/mini-native.sh Fri Jan 12 15:25:59 2007 -0500 @@ -156,6 +156,14 @@ [ $? -ne 0 ] && dienow +# Put statically and dynamically linked hello world programs on there for +# test purposes. + +"${ARCH}-gcc" "${SOURCES}/toys/hello.c" -Os -s -o "${TOOLS}/bin/hello-dynamic" && +"${ARCH}-gcc" "${SOURCES}/toys/hello.c" -Os -s -static -o "${TOOLS}/bin/hello-static" && + +[ $? -ne 0 ] && dienow + fi # Clean up and package the result
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sources/toys/hello.c Fri Jan 12 15:25:59 2007 -0500 @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(int argc, char *argv[]) +{ + printf("Hello world!\n"); + return 0; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sources/toys/thread-hello.c Fri Jan 12 15:25:59 2007 -0500 @@ -0,0 +1,15 @@ +#define __REENTRANT +#include <pthread.h> +#include <stdio.h> + +void *threadhello(void *unused) +{ + printf("Hello, world!\n"); + return 0; +} + +int main() { + pthread_t thready; + pthread_create(&thready, NULL, &threadhello, NULL); + usleep(10); +}