summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@gmail.com>2013-12-20 13:31:19 -0300
committerClaudio Takahasi <claudio.takahasi@gmail.com>2013-12-23 11:36:34 -0300
commit44754fa78bdb7c92ea241b3dbdfb83dfcf8d80de (patch)
treea1daf4226c9024220df6958366f3a69c16a26408 /examples
parentb13593e244243acf27c72b40cfeee325e98f3ce8 (diff)
build: Add Makefile per example
This patch changes the build system creating one Makefile for each project.
Diffstat (limited to 'examples')
-rw-r--r--examples/helloworld/Makefile.am40
1 files changed, 40 insertions, 0 deletions
diff --git a/examples/helloworld/Makefile.am b/examples/helloworld/Makefile.am
new file mode 100644
index 0000000..2e6cc6d
--- /dev/null
+++ b/examples/helloworld/Makefile.am
@@ -0,0 +1,40 @@
+AM_CFLAGS=-mcpu=cortex-m0 -mthumb -mfloat-abi=soft -c
+AM_LDFLAGS=--specs=nano.specs -Xlinker -Map=helloworld.map \
+ -T$(top_builddir)/platform/nrf51822/gcc_nrf51_blank_xxaa.ld \
+ -L$(SDK_DIR)/Nordic/nrf51822/Source/templates/gcc
+
+PLATFORM_LIBS = $(top_builddir)/stack/libblestack.a \
+ $(top_builddir)/platform/nrf51822/libnrf.a
+
+AM_CPPFLAGS=-I$(top_builddir)/platform/nrf51822
+
+HELLO_SOURCE_FILES = main.c
+HELLO_OBJECT_FILES = $(HELLO_SOURCE_FILES:.c=.o)
+
+all: helloworld.bin
+
+helloworld.bin: helloworld.out
+ $(OBJCOPY) -Obinary helloworld.out $@
+
+helloworld.out: $(HELLO_OBJECT_FILES)
+
+ $(CC) $(AM_LDFLAGS) $(HELLO_OBJECT_FILES) $(PLATFORM_LIBS) -o $@
+
+ $(OBJDUMP) -h helloworld.out
+
+# Build object files from C source files
+%.o: %.c
+ $(CC) -c $(CFLAGS) $(AM_CPPFLAGS) -o $@ $<
+
+# Build object files from ASM source files
+%.o: %.s
+ $(CC) -c $(ASMFLAGS) $(AM_CPPFLAGS) -o $@ $<
+
+MAINTAINERCLEANFILES = Makefile.in \
+ helloworld.bin \
+ helloworld.out \
+ helloworld.map
+
+clean-local:
+ $(RM) -rf $(MAINTAINERCLEANFILES)
+ $(RM) *.o