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