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 properly a proper system, so we can use uname
18 UNAME := $(shell uname)
19 ifeq ($(UNAME), Linux)
20 # Linux. (Todo: Add MacOS X if appropriate)
26 # You may/should set this in your environment
27 ARMLIB ?= /usr/local/lib/gcc/arm-elf/4.3.3/interwork
32 # Assume that we are running on Windows.
37 ARMLIB ?= ../../devkitARM/lib/gcc/arm-elf/4.1.0/interwork
45 OBJCOPY = arm-elf-objcopy
49 INCLUDE = -I../include
51 # Also search prerequisites in the common directory (for usb.c), and the fpga directory (for fpga.bit)
52 VPATH = . ../common/ ../fpga/
54 INCLUDES = ../include/proxmark3.h ../include/at91sam7s128.h ../include/config_gpio.h ../include/usb_cmd.h $(APP_INCLUDES)
56 CFLAGS = -c $(INCLUDE) -Wall $(APP_CFLAGS)
58 THUMBOBJ = $(patsubst %.c,$(OBJDIR)/%.o,$(THUMBSRC))
59 ARMOBJ = $(patsubst %.c,$(OBJDIR)/%.o,$(ARMSRC))
60 ASMOBJ = $(patsubst %.s,$(OBJDIR)/%.o,$(ASMSRC))
62 $(THUMBOBJ): $(OBJDIR)/%.o: %.c $(INCLUDES)
63 $(CC) $(CFLAGS) -mthumb -mthumb-interwork -o $@ $<
65 $(ARMOBJ): $(OBJDIR)/%.o: %.c $(INCLUDES)
66 $(CC) $(CFLAGS) -mthumb-interwork -o $@ $<
68 $(ASMOBJ): $(OBJDIR)/%.o: %.s
69 $(CC) $(CFLAGS) -mthumb-interwork -o $@ $<
71 # This objcopy call translates physical flash addresses to logical addresses
72 # See ldscript.common. -- Henryk Plötz <henryk@ploetzli.ch> 2009-08-27
73 $(OBJDIR)/%.s19: $(OBJDIR)/%.elf
74 $(OBJCOPY) -Osrec --srec-forceS3 --no-change-warnings \
75 --change-section-address bootphase1-0x100000 \
76 --change-section-address bootphase2-0x100000 \
77 --change-section-address fpgaimage-0x100000 \
78 --change-section-address .start-0x100000 \
79 --change-section-address .text-0x100000 \
80 --change-section-address .rodata-0x100000 $^ $@
82 # version.c should be remade on every compilation
84 version.c: default_version.c
85 perl ../tools/mkversion.pl .. > $@ || $(COPY) $^ $@
87 # Automatic dependency generation
88 DEPENDENCY_FILES = $(patsubst %.c,$(OBJDIR)/%.d,$(notdir $(THUMBSRC))) \
89 $(patsubst %.c,$(OBJDIR)/%.d,$(notdir $(ARMSRC))) \
90 $(patsubst %.s,$(OBJDIR)/%.d,$(notdir $(ASMSRC)))
92 $(DEPENDENCY_FILES): Makefile ../common/Makefile.common
94 @$(CC) -MM -MT "$(@) $(@:.d=.o)" $(CFLAGS) $< > $@
96 @$(CC) -MM -MT "$(@) $(@:.d=.o)" $(CFLAGS) $< > $@
98 -include $(DEPENDENCY_FILES)