Browse Source

Add an example of how to build Harvey programs outside the Harvey tree

And it works ...

Change-Id: Ic86ee36610a1e764b09a5d2225336198d6d3d5b0
Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Ronald G. Minnich 8 years ago
parent
commit
e86fb5ff9c
2 changed files with 45 additions and 0 deletions
  1. 26 0
      external_example/Makefile
  2. 19 0
      external_example/hi.c

+ 26 - 0
external_example/Makefile

@@ -0,0 +1,26 @@
+CFLAGS=-nostdinc \
+	-mcmodel=small \
+	-O0 \
+	-fplan9-extensions \
+	-mno-red-zone \
+	-ffreestanding \
+	-fno-builtin \
+	-trigraphs \
+	-Wall \
+	-Wno-missing-braces \
+	-Wno-parentheses \
+	-Wno-unknown-pragmas \
+	-Wuninitialized \
+	-Wmaybe-uninitialized \
+	-I $(HARVEY)/$(ARCH)/include \
+	-I$(HARVEY)/sys/include
+
+LDFLAGS=-nostdlib \
+	-e _main \
+	$(HARVEY)/$(ARCH)/lib/libc.a
+
+hi: hi.o
+	ld -o hi hi.o $(LDFLAGS)
+hi.o: hi.c
+	cc $(CFLAGS) -c hi.c
+

+ 19 - 0
external_example/hi.c

@@ -0,0 +1,19 @@
+/*
+ * This file is part of the UCB release of Plan 9. It is subject to the license
+ * terms in the LICENSE file found in the top-level directory of this
+ * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
+ * part of the UCB release of Plan 9, including this file, may be copied,
+ * modified, propagated, or distributed except according to the terms contained
+ * in the LICENSE file.
+ */
+
+#include <u.h>
+#include <libc.h>
+
+void
+main(int argc, char *argv[])
+{
+	print("hi\n");
+	exits(0);
+}
+