Swap build.sh for a real Makefile
authorKarl Palsson <karlp@tweak.net.au>
Sat, 1 Oct 2011 23:22:57 +0000 (23:22 +0000)
committerKarl Palsson <karlp@tweak.net.au>
Sat, 1 Oct 2011 23:22:57 +0000 (23:22 +0000)
example/Makefile [new file with mode: 0644]
example/build.sh [deleted file]

diff --git a/example/Makefile b/example/Makefile
new file mode 100644 (file)
index 0000000..f0e1899
--- /dev/null
@@ -0,0 +1,22 @@
+EXECUTABLE=blink.elf
+BIN_IMAGE=blink.bin
+
+CC=arm-none-eabi-gcc
+OBJCOPY=arm-none-eabi-objcopy
+
+CFLAGS=-O2 -mlittle-endian -mthumb
+CFLAGS+=-mcpu=cortex-m3 -ffreestanding -nostdlib -nostdinc
+
+all: $(BIN_IMAGE)
+
+$(BIN_IMAGE): $(EXECUTABLE)
+       $(OBJCOPY) -O binary $^ $@
+
+$(EXECUTABLE): main.c
+       $(CC) $(CFLAGS) $^ -o $@
+
+clean:
+       rm -rf $(EXECUTABLE)
+       rm -rf $(BIN_IMAGE)
+
+.PHONY: all clean
diff --git a/example/build.sh b/example/build.sh
deleted file mode 100755 (executable)
index 39e8fb4..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/usr/bin/env sh
-
-CHAIN=$HOME/sat/bin/arm-none-eabi
-PATH=$HOME/sat/arm-none-eabi/bin:$PATH
-
-$CHAIN-gcc \
-    -O2 \
-    -mlittle-endian \
-    -mthumb \
-    -mcpu=cortex-m3 \
-    -ffreestanding \
-    -nostdlib \
-    -nostdinc \
-    main.c
-
-$CHAIN-objcopy \
-    -O binary \
-    a.out \
-    /tmp/foobar
\ No newline at end of file