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
8 # Make sure that all is the default target
9 # (The including Makefile still needs to define what 'all' is)
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 ""),)
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)
25 FLASH_TOOL=linux/flasher
27 # You may/should set this in your environment
28 ARMLIB ?= /usr/local/lib/gcc/arm-elf/4.3.3/interwork
33 # Assume that we are running on Windows.
38 ARMLIB ?= ../../devkitARM/lib/gcc/arm-elf/4.1.0/interwork
39 FLASH_TOOL=winsrc\\prox.exe
48 OBJCOPY = $(CROSS)objcopy
52 INCLUDE = -I../include
54 # Also search prerequisites in the common directory (for usb.c), and the fpga directory (for fpga.bit)
55 VPATH = . ../common/ ../fpga/
57 INCLUDES = ../include/proxmark3.h ../include/at91sam7s128.h ../include/config_gpio.h ../include/usb_cmd.h $(APP_INCLUDES)
59 CFLAGS = -c $(INCLUDE) -Wall -Werror -pedantic -std=gnu99 $(APP_CFLAGS)
61 THUMBOBJ = $(patsubst %.c,$(OBJDIR)/%.o,$(THUMBSRC))
62 ARMOBJ = $(patsubst %.c,$(OBJDIR)/%.o,$(ARMSRC))
63 ASMOBJ = $(patsubst %.s,$(OBJDIR)/%.o,$(ASMSRC))
64 VERSIONOBJ = $(OBJDIR)/version.o
66 $(THUMBOBJ): $(OBJDIR)/%.o: %.c $(INCLUDES)
67 $(CC) $(CFLAGS) -mthumb -mthumb-interwork -o $@ $<
69 $(ARMOBJ): $(OBJDIR)/%.o: %.c $(INCLUDES)
70 $(CC) $(CFLAGS) -mthumb-interwork -o $@ $<
72 $(ASMOBJ): $(OBJDIR)/%.o: %.s
73 $(CC) $(CFLAGS) -mthumb-interwork -o $@ $<
75 $(VERSIONOBJ): $(OBJDIR)/%.o: %.c $(INCLUDES)
76 $(CC) $(CFLAGS) -mthumb -mthumb-interwork -o $@ $<
78 # This objcopy call translates physical flash addresses to logical addresses
79 # without touching start address or RAM addresses (.bss and .data sections)
80 # See ldscript.common. -- Henryk Plötz <henryk@ploetzli.ch> 2009-08-27
81 OBJCOPY_TRANSLATIONS = --no-change-warnings \
82 --change-addresses -0x100000 --change-start 0 \
83 --change-section-address .bss+0 --change-section-address .data+0 \
84 --change-section-address .commonarea+0
85 $(OBJDIR)/%.s19: $(OBJDIR)/%.elf
86 $(OBJCOPY) -Osrec --srec-forceS3 --strip-debug $(OBJCOPY_TRANSLATIONS) $^ $@
88 # version.c should be remade on every compilation
90 version.c: default_version.c
91 perl ../tools/mkversion.pl .. > $@ || $(COPY) $^ $@
93 # Automatic dependency generation
94 DEPENDENCY_FILES = $(patsubst %.c,$(OBJDIR)/%.d,$(notdir $(THUMBSRC))) \
95 $(patsubst %.c,$(OBJDIR)/%.d,$(notdir $(ARMSRC))) \
96 $(patsubst %.s,$(OBJDIR)/%.d,$(notdir $(ASMSRC)))
98 $(DEPENDENCY_FILES): Makefile ../common/Makefile.common
99 $(patsubst %.o,%.d,$(THUMBOBJ) $(ARMOBJ)): $(OBJDIR)/%.d: %.c
100 @$(CC) -MM -MT "$(@) $(@:.d=.o)" $(CFLAGS) $< > $@
101 $(patsubst %.o,%.d,$(ASMOBJ)):$(OBJDIR)/%.d: %.s
102 @$(CC) -MM -MT "$(@) $(@:.d=.o)" $(CFLAGS) $< > $@
104 -include $(DEPENDENCY_FILES)