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