From abefafd70b16201e829f3e7a7b8ececaef60548c Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Wed, 1 Apr 2020 15:46:43 +1100 Subject: [PATCH] hello_world: Adjust header inclusions and Makefile Currently hello_world fails to build with distro cross compiler packages such as Debian gcc-powerpc64-linux-gnu, because it doesn't provide string.h or unistd.h. In fact we don't need them, we just need stddef.h. This adds #include to console.h to get size_t defined. We also add #include "console.h" to console.c. The hello_world Makefile currently hard-codes CROSS_COMPILE on non-PPC machines. This means that a command like: $ CROSS_COMPILE=powerpc64le-linux-gnu- make doesn't do what you expect; it just tries to use powerpc64le-linux-gcc regardless. Adding a '?' makes it do what one expects. Signed-off-by: Paul Mackerras --- hello_world/Makefile | 2 +- hello_world/console.c | 4 ++-- hello_world/console.h | 2 ++ hello_world/hello_world.c | 2 -- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hello_world/Makefile b/hello_world/Makefile index 0cbc69f..f7f9497 100644 --- a/hello_world/Makefile +++ b/hello_world/Makefile @@ -1,7 +1,7 @@ ARCH = $(shell uname -m) ifneq ("$(ARCH)", "ppc64") ifneq ("$(ARCH)", "ppc64le") - CROSS_COMPILE = powerpc64le-linux- + CROSS_COMPILE ?= powerpc64le-linux- endif endif diff --git a/hello_world/console.c b/hello_world/console.c index 640eb48..f8e5441 100644 --- a/hello_world/console.c +++ b/hello_world/console.c @@ -1,8 +1,8 @@ -#include -#include #include #include +#include "console.h" + /* * Core UART functions to implement for a port */ diff --git a/hello_world/console.h b/hello_world/console.h index 85e7b36..fc64b91 100644 --- a/hello_world/console.h +++ b/hello_world/console.h @@ -1,3 +1,5 @@ +#include + void potato_uart_init(void); int getchar(void); void putchar(unsigned char c); diff --git a/hello_world/hello_world.c b/hello_world/hello_world.c index f1d1367..7e853d8 100644 --- a/hello_world/hello_world.c +++ b/hello_world/hello_world.c @@ -1,5 +1,3 @@ -#include -#include #include #include -- 2.30.2