]> git.zerfleddert.de Git - proxmark3-svn/blame - common/Makefile.common
(Our Windows ARM toolchain really likes its glue sections)
[proxmark3-svn] / common / Makefile.common
CommitLineData
7e931bbd 1# This new makefile replaces the previous Makefile/Makefile.linux
2# with as much common code for both environments as possible.
3# Following is a short OS detection to set up variables, all the
4# remaining Makefile should be portable and only depend on these
5# variables
0fc0fca5 6#
7
8# Make sure that all is the default target
9# (The including Makefile still needs to define what 'all' is)
10all:
7e931bbd 11
12# Windows' echo echos its input verbatim, on Posix there is some
13# amount of shell command line parsing going on. echo "" on
14# Windows yields literal "", on Linux yields an empty line
15ifeq ($(shell echo ""),)
0fc0fca5 16
7e931bbd 17# This is properly a proper system, so we can use uname
18UNAME := $(shell uname)
19ifeq ($(UNAME), Linux)
20# Linux. (Todo: Add MacOS X if appropriate)
21DELETE=rm -rf
0fc0fca5 22MOVE=mv
7e931bbd 23PATHSEP=/
24DETECTED_OS=Linux
25# You may/should set this in your environment
26ARMLIB ?= /usr/local/lib/gcc/arm-elf/4.3.3/interwork
27endif
0fc0fca5 28
7e931bbd 29else
0fc0fca5 30
7e931bbd 31# Assume that we are running on Windows.
32DELETE=del /q
0fc0fca5 33MOVE=ren
7e931bbd 34PATHSEP=\\#
35ARMLIB ?= ../../devkitARM/lib/gcc/arm-elf/4.1.0/interwork
36DETECTED_OS=Windows
0fc0fca5 37
7e931bbd 38endif
39
40CC = arm-elf-gcc
41AS = arm-elf-as
42LD = arm-elf-ld
43OBJCOPY = arm-elf-objcopy
44
45OBJDIR = obj
46
47INCLUDE = -I../include
48
49# Also search prerequisites in the common directory (for usb.c)
50VPATH = . ../common/
51
52INCLUDES = ../include/proxmark3.h ../include/at91sam7s128.h ../include/config_gpio.h ../include/usb_cmd.h $(APP_INCLUDES)
53
54CFLAGS = -c $(INCLUDE) -Wall $(APP_CFLAGS)
0fc0fca5 55
56THUMBOBJ = $(patsubst %.c,$(OBJDIR)/%.o,$(THUMBSRC))
57ARMOBJ = $(patsubst %.c,$(OBJDIR)/%.o,$(ARMSRC))
58ASMOBJ = $(patsubst %.s,$(OBJDIR)/%.o,$(ASMSRC))
59
60$(THUMBOBJ): $(OBJDIR)/%.o: %.c $(INCLUDES)
61 $(CC) $(CFLAGS) -mthumb -mthumb-interwork -o $@ $<
62
63$(ARMOBJ): $(OBJDIR)/%.o: %.c $(INCLUDES)
64 $(CC) $(CFLAGS) -mthumb-interwork -o $@ $<
65
66$(ASMOBJ): $(OBJDIR)/%.o: %.s
67 $(CC) $(CFLAGS) -mthumb-interwork -o $@ $<
68
2bfed17d 69# This objcopy call translates physical flash addresses to logical addresses
70# See ldscript.common. -- Henryk Plötz <henryk@ploetzli.ch> 2009-08-27
0fc0fca5 71$(OBJDIR)/%.s19: $(OBJDIR)/%.elf
2bfed17d 72 $(OBJCOPY) -Osrec --srec-forceS3 --no-change-warnings \
73 --change-section-address bootphase1-0x100000 \
74 --change-section-address bootphase2-0x100000 \
75 --change-section-address fpgaimage-0x100000 \
76 --change-section-address .start-0x100000 \
77 --change-section-address .text-0x100000 \
78 --change-section-address .rodata-0x100000 $^ $@
0fc0fca5 79
80# Automatic dependency generation
81DEPENDENCY_FILES = $(patsubst %.c,$(OBJDIR)/%.d,$(notdir $(THUMBSRC))) \
82 $(patsubst %.c,$(OBJDIR)/%.d,$(notdir $(ARMSRC))) \
83 $(patsubst %.s,$(OBJDIR)/%.d,$(notdir $(ASMSRC)))
84
85$(DEPENDENCY_FILES): Makefile ../common/Makefile.common
86$(OBJDIR)/%.d: %.c
8652988d 87 @$(CC) -MM -MT "$(@) $(@:.d=.o)" $(CFLAGS) $< > $@
0fc0fca5 88$(OBJDIR)/%.d: %.s
8652988d 89 @$(CC) -MM -MT "$(@) $(@:.d=.o)" $(CFLAGS) $< > $@
0fc0fca5 90
91-include $(DEPENDENCY_FILES)
Impressum, Datenschutz