]>
Commit | Line | Data |
---|---|---|
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) | |
10 | all: | |
7e931bbd | 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 ""),) | |
0fc0fca5 | 16 | |
db335b3d | 17 | # This is probably a proper system, so we can use uname |
7e931bbd | 18 | UNAME := $(shell uname) |
19 | ifeq ($(UNAME), Linux) | |
20 | # Linux. (Todo: Add MacOS X if appropriate) | |
21 | DELETE=rm -rf | |
0fc0fca5 | 22 | MOVE=mv |
8a6aec16 | 23 | COPY=cp |
7e931bbd | 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 | |
0fc0fca5 | 29 | |
7e931bbd | 30 | else |
0fc0fca5 | 31 | |
7e931bbd | 32 | # Assume that we are running on Windows. |
33 | DELETE=del /q | |
0fc0fca5 | 34 | MOVE=ren |
8a6aec16 | 35 | COPY=copy |
7e931bbd | 36 | PATHSEP=\\# |
37 | ARMLIB ?= ../../devkitARM/lib/gcc/arm-elf/4.1.0/interwork | |
38 | DETECTED_OS=Windows | |
0fc0fca5 | 39 | |
7e931bbd | 40 | endif |
41 | ||
8fcbf652 | 42 | CROSS = arm-elf- |
43 | CC = $(CROSS)gcc | |
44 | AS = $(CROSS)as | |
45 | LD = $(CROSS)ld | |
46 | OBJCOPY = $(CROSS)objcopy | |
7e931bbd | 47 | |
48 | OBJDIR = obj | |
49 | ||
50 | INCLUDE = -I../include | |
51 | ||
e73e7172 | 52 | # Also search prerequisites in the common directory (for usb.c), and the fpga directory (for fpga.bit) |
53 | VPATH = . ../common/ ../fpga/ | |
7e931bbd | 54 | |
55 | INCLUDES = ../include/proxmark3.h ../include/at91sam7s128.h ../include/config_gpio.h ../include/usb_cmd.h $(APP_INCLUDES) | |
56 | ||
57 | CFLAGS = -c $(INCLUDE) -Wall $(APP_CFLAGS) | |
0fc0fca5 | 58 | |
59 | THUMBOBJ = $(patsubst %.c,$(OBJDIR)/%.o,$(THUMBSRC)) | |
60 | ARMOBJ = $(patsubst %.c,$(OBJDIR)/%.o,$(ARMSRC)) | |
61 | ASMOBJ = $(patsubst %.s,$(OBJDIR)/%.o,$(ASMSRC)) | |
4271e82d | 62 | VERSIONOBJ = $(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 |
0fc0fca5 | 79 | $(OBJDIR)/%.s19: $(OBJDIR)/%.elf |
db335b3d | 80 | $(OBJCOPY) -Osrec --srec-forceS3 --strip-debug --no-change-warnings \ |
81 | --change-addresses -0x100000 --change-start 0 \ | |
8fcbf652 | 82 | --change-section-address .bss+0 --change-section-address .data+0 \ |
83 | --change-section-address .commonarea+0 $^ $@ | |
0fc0fca5 | 84 | |
8a6aec16 | 85 | # version.c should be remade on every compilation |
86 | .PHONY: version.c | |
87 | version.c: default_version.c | |
88 | perl ../tools/mkversion.pl .. > $@ || $(COPY) $^ $@ | |
89 | ||
0fc0fca5 | 90 | # Automatic dependency generation |
91 | DEPENDENCY_FILES = $(patsubst %.c,$(OBJDIR)/%.d,$(notdir $(THUMBSRC))) \ | |
92 | $(patsubst %.c,$(OBJDIR)/%.d,$(notdir $(ARMSRC))) \ | |
93 | $(patsubst %.s,$(OBJDIR)/%.d,$(notdir $(ASMSRC))) | |
94 | ||
95 | $(DEPENDENCY_FILES): Makefile ../common/Makefile.common | |
4271e82d | 96 | $(patsubst %.o,%.d,$(THUMBOBJ) $(ARMOBJ)): $(OBJDIR)/%.d: %.c |
8652988d | 97 | @$(CC) -MM -MT "$(@) $(@:.d=.o)" $(CFLAGS) $< > $@ |
4271e82d | 98 | $(patsubst %.o,%.d,$(ASMOBJ)):$(OBJDIR)/%.d: %.s |
8652988d | 99 | @$(CC) -MM -MT "$(@) $(@:.d=.o)" $(CFLAGS) $< > $@ |
0fc0fca5 | 100 | |
101 | -include $(DEPENDENCY_FILES) |