Actions

EmSys

Git - More Structure

From EdWiki

GitLab - More Structure

  • Goals
    Add another file to our repository
  • Now add a Makefile
   #              Makefile                                  #
   all:	hello.elf
   hello.elf:	hello.o
   hello.o:	hello.c hello.h
   clean:
   	-rm -f hello.elf hello.o
   # The following variables and implicit rules are required for the GNU
   # Assembler and the GNU Compiler.
   AS        = as
   CC        = gcc
   LD        = ld
   ASFLAGS   = -g
   CFLAGS    = -O2 -g -Wall
   LDFLAGS   =
   LOADLIBES =
   LDLIBS    = -lc
   # Compile C code (.c) to an object file (.o)
   %.o: %.c
   	$(CC) -c $(CFLAGS) $< -o $@
   # Assemble ARM assembly language source (.s) to an object file (.o)
   %.o: %.s
   	$(AS) $(ASFLAGS) $< -o $@
   # Link files into an executable (.exe), using the GNU Compiler.
   %.elf:
  	$(CC) $(LDFLAGS) $+ $(LOADLIBES) $(LDLIBS) -o $@
   # Miscellaneous rules
   .PHONY:	all clean
   .DEFAULT:
   .SUFFIXES:
  • Add and commit the change.
git add Makefile
git commit -m "Added a Makefile."

You should be able to use Make to run your hello program now.

make
hello.exe