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