]>
Commit | Line | Data |
---|---|---|
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 | # 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 ""),) | |
16 | ||
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) | |
21 | DELETE=rm -rf | |
22 | MOVE=mv | |
23 | PATHSEP=/ | |
24 | DETECTED_OS=Linux | |
25 | # You may/should set this in your environment | |
26 | ARMLIB ?= /usr/local/lib/gcc/arm-elf/4.3.3/interwork | |
27 | endif | |
28 | ||
29 | else | |
30 | ||
31 | # Assume that we are running on Windows. | |
32 | DELETE=del /q | |
33 | MOVE=ren | |
34 | PATHSEP=\\# | |
35 | ARMLIB ?= ../../devkitARM/lib/gcc/arm-elf/4.1.0/interwork | |
36 | DETECTED_OS=Windows | |
37 | ||
38 | endif | |
39 | ||
40 | CC = arm-elf-gcc | |
41 | AS = arm-elf-as | |
42 | LD = arm-elf-ld | |
43 | OBJCOPY = arm-elf-objcopy | |
44 | ||
45 | OBJDIR = obj | |
46 | ||
47 | INCLUDE = -I../include | |
48 | ||
49 | # Also search prerequisites in the common directory (for usb.c) | |
50 | VPATH = . ../common/ | |
51 | ||
52 | INCLUDES = ../include/proxmark3.h ../include/at91sam7s128.h ../include/config_gpio.h ../include/usb_cmd.h $(APP_INCLUDES) | |
53 | ||
54 | CFLAGS = -c $(INCLUDE) -Wall $(APP_CFLAGS) | |
55 | ||
56 | THUMBOBJ = $(patsubst %.c,$(OBJDIR)/%.o,$(THUMBSRC)) | |
57 | ARMOBJ = $(patsubst %.c,$(OBJDIR)/%.o,$(ARMSRC)) | |
58 | ASMOBJ = $(patsubst %.s,$(OBJDIR)/%.o,$(ASMSRC)) | |
59 | ||
60 | $(THUMBOBJ): $(OBJDIR)/%.o: %.c $(INCLUDES) | |
61 | $(CC) $(CFLAGS) -mthumb -mthumb-interwork -o $@ $< | |
62 | ||
63 | $(ARMOBJ): $(OBJDIR)/%.o: %.c $(INCLUDES) | |
64 | $(CC) $(CFLAGS) -mthumb-interwork -o $@ $< | |
65 | ||
66 | $(ASMOBJ): $(OBJDIR)/%.o: %.s | |
67 | $(CC) $(CFLAGS) -mthumb-interwork -o $@ $< | |
68 | ||
69 | $(OBJDIR)/%.s19: $(OBJDIR)/%.elf | |
70 | $(OBJCOPY) -Osrec --srec-forceS3 $^ $@ | |
71 | ||
72 | # Automatic dependency generation | |
73 | DEPENDENCY_FILES = $(patsubst %.c,$(OBJDIR)/%.d,$(notdir $(THUMBSRC))) \ | |
74 | $(patsubst %.c,$(OBJDIR)/%.d,$(notdir $(ARMSRC))) \ | |
75 | $(patsubst %.s,$(OBJDIR)/%.d,$(notdir $(ASMSRC))) | |
76 | ||
77 | $(DEPENDENCY_FILES): Makefile ../common/Makefile.common | |
78 | $(OBJDIR)/%.d: %.c | |
79 | @$(CC) -MM -MT "$(@) $(@:.d=.o)" $(CFLAGS) $< > $@ | |
80 | $(OBJDIR)/%.d: %.s | |
81 | @$(CC) -MM -MT "$(@) $(@:.d=.o)" $(CFLAGS) $< > $@ | |
82 | ||
83 | -include $(DEPENDENCY_FILES) |