First cookbook example for the docs: Hello World in C.
This commit is contained in:
parent
d664099c9d
commit
d663c9b67d
10 changed files with 216 additions and 2 deletions
3
Documentation/cookbook/hello/.gitignore
vendored
Normal file
3
Documentation/cookbook/hello/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
hello
|
||||
*~
|
||||
.*~
|
||||
1
Documentation/cookbook/hello/all.do
Normal file
1
Documentation/cookbook/hello/all.do
Normal file
|
|
@ -0,0 +1 @@
|
|||
redo-ifchange hello
|
||||
1
Documentation/cookbook/hello/clean.do
Normal file
1
Documentation/cookbook/hello/clean.do
Normal file
|
|
@ -0,0 +1 @@
|
|||
rm -f hello *~ .*~
|
||||
6
Documentation/cookbook/hello/hello.c
Normal file
6
Documentation/cookbook/hello/hello.c
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
printf("Hello, world!\n");
|
||||
return 0;
|
||||
}
|
||||
16
Documentation/cookbook/hello/hello.do
Normal file
16
Documentation/cookbook/hello/hello.do
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# If hello.c changes, this script needs to be
|
||||
# re-run.
|
||||
redo-ifchange hello.c
|
||||
|
||||
# Compile hello.c into the 'hello' binary.
|
||||
#
|
||||
# $3 is the redo variable that represents the
|
||||
# output filename. We want to build a file
|
||||
# called "hello", but if we write that directly,
|
||||
# then an interruption could result in a
|
||||
# partially-written file. Instead, write it to
|
||||
# $3, and redo will move our output into its
|
||||
# final location, only if this script completes
|
||||
# successfully.
|
||||
#
|
||||
cc -o $3 hello.c -Wall
|
||||
12
Documentation/cookbook/hello/test.do
Normal file
12
Documentation/cookbook/hello/test.do
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# Make sure everything has been built before we start
|
||||
redo-ifchange all
|
||||
|
||||
# Ensure that the hello program, when run, says
|
||||
# hello like we expect.
|
||||
if ./hello | grep -i 'hello' >/dev/null; then
|
||||
echo "success" >&2
|
||||
exit 0
|
||||
else
|
||||
echo "missing 'hello' message!" >&2
|
||||
exit 1
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue