]> git.zerfleddert.de Git - proxmark3-svn/blame - common/Makefile.common
added eh_frame needed for gcc 4.4.1 or higher
[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
db335b3d 17# This is probably a proper system, so we can use uname
7e931bbd 18UNAME := $(shell uname)
19ifeq ($(UNAME), Linux)
20# Linux. (Todo: Add MacOS X if appropriate)
21DELETE=rm -rf
0fc0fca5 22MOVE=mv
8a6aec16 23COPY=cp
7e931bbd 24PATHSEP=/
64b81198 25FLASH_TOOL=linux/flasher
7e931bbd 26DETECTED_OS=Linux
27# You may/should set this in your environment
28ARMLIB ?= /usr/local/lib/gcc/arm-elf/4.3.3/interwork
29endif
0fc0fca5 30
7e931bbd 31else
0fc0fca5 32
7e931bbd 33# Assume that we are running on Windows.
34DELETE=del /q
0fc0fca5 35MOVE=ren
8a6aec16 36COPY=copy
7e931bbd 37PATHSEP=\\#
38ARMLIB ?= ../../devkitARM/lib/gcc/arm-elf/4.1.0/interwork
64b81198 39FLASH_TOOL=winsrc\\prox.exe
7e931bbd 40DETECTED_OS=Windows
0fc0fca5 41
7e931bbd 42endif
43
8fcbf652 44CROSS = arm-elf-
45CC = $(CROSS)gcc
46AS = $(CROSS)as
47LD = $(CROSS)ld
48OBJCOPY = $(CROSS)objcopy
7e931bbd 49
50OBJDIR = obj
51
52INCLUDE = -I../include
53
e73e7172 54# Also search prerequisites in the common directory (for usb.c), and the fpga directory (for fpga.bit)
55VPATH = . ../common/ ../fpga/
7e931bbd 56
57INCLUDES = ../include/proxmark3.h ../include/at91sam7s128.h ../include/config_gpio.h ../include/usb_cmd.h $(APP_INCLUDES)
58
d4086fe2 59CFLAGS = -c $(INCLUDE) -Wall -Werror -pedantic -std=gnu99 $(APP_CFLAGS)
0fc0fca5 60
61THUMBOBJ = $(patsubst %.c,$(OBJDIR)/%.o,$(THUMBSRC))
62ARMOBJ = $(patsubst %.c,$(OBJDIR)/%.o,$(ARMSRC))
63ASMOBJ = $(patsubst %.s,$(OBJDIR)/%.o,$(ASMSRC))
4271e82d 64VERSIONOBJ = $(OBJDIR)/version.o
0fc0fca5 65
66$(THUMBOBJ): $(OBJDIR)/%.o: %.c $(INCLUDES)
67 $(CC) $(CFLAGS) -mthumb -mthumb-interwork -o $@ $<
68
69$(ARMOBJ): $(OBJDIR)/%.o: %.c $(INCLUDES)
70 $(CC) $(CFLAGS) -mthumb-interwork -o $@ $<
71
72$(ASMOBJ): $(OBJDIR)/%.o: %.s
73 $(CC) $(CFLAGS) -mthumb-interwork -o $@ $<
74
4271e82d 75$(VERSIONOBJ): $(OBJDIR)/%.o: %.c $(INCLUDES)
76 $(CC) $(CFLAGS) -mthumb -mthumb-interwork -o $@ $<
77
2bfed17d 78# This objcopy call translates physical flash addresses to logical addresses
db335b3d 79# without touching start address or RAM addresses (.bss and .data sections)
2bfed17d 80# See ldscript.common. -- Henryk Plötz <henryk@ploetzli.ch> 2009-08-27
4f3bd973 81OBJCOPY_TRANSLATIONS = --no-change-warnings \
db335b3d 82 --change-addresses -0x100000 --change-start 0 \
8fcbf652 83 --change-section-address .bss+0 --change-section-address .data+0 \
4f3bd973 84 --change-section-address .commonarea+0
85$(OBJDIR)/%.s19: $(OBJDIR)/%.elf
86 $(OBJCOPY) -Osrec --srec-forceS3 --strip-debug $(OBJCOPY_TRANSLATIONS) $^ $@
0fc0fca5 87
8a6aec16 88# version.c should be remade on every compilation
89.PHONY: version.c
90version.c: default_version.c
91 perl ../tools/mkversion.pl .. > $@ || $(COPY) $^ $@
92
0fc0fca5 93# Automatic dependency generation
94DEPENDENCY_FILES = $(patsubst %.c,$(OBJDIR)/%.d,$(notdir $(THUMBSRC))) \
95 $(patsubst %.c,$(OBJDIR)/%.d,$(notdir $(ARMSRC))) \
96 $(patsubst %.s,$(OBJDIR)/%.d,$(notdir $(ASMSRC)))
97
98$(DEPENDENCY_FILES): Makefile ../common/Makefile.common
4271e82d 99$(patsubst %.o,%.d,$(THUMBOBJ) $(ARMOBJ)): $(OBJDIR)/%.d: %.c
8652988d 100 @$(CC) -MM -MT "$(@) $(@:.d=.o)" $(CFLAGS) $< > $@
4271e82d 101$(patsubst %.o,%.d,$(ASMOBJ)):$(OBJDIR)/%.d: %.s
8652988d 102 @$(CC) -MM -MT "$(@) $(@:.d=.o)" $(CFLAGS) $< > $@
0fc0fca5 103
104-include $(DEPENDENCY_FILES)
Impressum, Datenschutz