#include <stdio.h>
int main(void)
{
printf("hello, world! \n");
return 0;
}
The contents of the ~/example/Makefile are as follows:
# Define TARGET and source filenames
target := hellworld
DIRS := $(shell find.-maxdepth 3-type d)
SRCS := $(foreach dir,$(DIRS),$(wildcard $(dir)/*.c))
OBJS := $(SRCS:.c=.o)
CC=aarch64-linux-gnu-gcc
# Define compiler and compile options
CFLAGS := -Wall-Wextra -g-wno-unused-parameters
# define default TARGET
all: $(TARGET)
# define target file dependencies and compile commands
$(TARGET): $(OBJS)
$(CC) $(CFLAGS) $(LIBS) $^ -o $@
# Define the command to compile the source file to the target file
%.o: %.c
$(CC) $(CFLAGS) $(LIBS) -C $< -o $@
# Define command to clear temporary files
clean:
rm -f $(TARGET) $(OBJS)