mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-12-27 19:07:30 +08:00
Move most rules to Makefile.common
Add automatic dependency generation Compile ISO14443 files in ARM mode, as was the case with the Linux Makefile before
This commit is contained in:
parent
97a82e8f36
commit
0fc0fca583
3 changed files with 68 additions and 34 deletions
|
@ -1,47 +1,49 @@
|
|||
# Makefile for armsrc, see ../common/Makefile.common for common settings
|
||||
include ../common/Makefile.common
|
||||
|
||||
APP_INCLUDES = apps.h
|
||||
|
||||
# Add the "-DWITH_LCD" flag in APP_CLFAGS to add support for LCD
|
||||
# and add OBJLCD to OBJ too
|
||||
# and add SRC_LCD to SRC_MAIN
|
||||
APP_CFLAGS = -O6
|
||||
|
||||
OBJLCD = $(OBJDIR)/fonts.o \
|
||||
$(OBJDIR)/LCD.o
|
||||
SRC_LCD = fonts.c LCD.c
|
||||
|
||||
OBJ = $(OBJDIR)/start.o \
|
||||
$(OBJDIR)/appmain.o \
|
||||
$(OBJDIR)/fpga.o \
|
||||
$(OBJDIR)/lfops.o \
|
||||
$(OBJDIR)/iso14443.o \
|
||||
$(OBJDIR)/iso14443a.o \
|
||||
$(OBJDIR)/iso15693.o \
|
||||
$(OBJDIR)/util.o \
|
||||
$(OBJDIR)/usb.o
|
||||
SRC_MAIN = start.c \
|
||||
appmain.c \
|
||||
fpga.c \
|
||||
lfops.c \
|
||||
iso15693.c \
|
||||
util.c \
|
||||
usb.c
|
||||
|
||||
OBJFPGA = \
|
||||
$(OBJDIR)/fpgaimg.o
|
||||
# These are to be compiled in ARM mode
|
||||
SRC_MAIN_FAST = iso14443.c \
|
||||
iso14443a.c
|
||||
|
||||
SRC_FPGA = fpgaimg.c
|
||||
|
||||
THUMBSRC = $(SRC_MAIN) $(SRC_FPGA)
|
||||
ARMSRC = $(SRC_MAIN_FAST)
|
||||
|
||||
MAIN_OBJ = $(patsubst %.c,$(OBJDIR)/%.o,$(SRC_MAIN) $(SRC_MAIN_FAST))
|
||||
|
||||
# Do not move this inclusion before the definition of {THUMB,ASM,ARM}{OBJ,SRC}
|
||||
include ../common/Makefile.common
|
||||
|
||||
all: $(OBJDIR)/osimage.s19 $(OBJDIR)/fpgaimage.s19
|
||||
|
||||
$(OBJDIR)/fpgaimage.elf: $(OBJDIR)/fpgaimg.o
|
||||
$(LD) -g -Tldscript-fpga -Map=$(patsubst %.elf,%.map,$@) -o $@ $^
|
||||
|
||||
$(OBJDIR)/osimage.elf: $(OBJ) $(OBJCOMMON) $(ARMLIB)/libgcc.a
|
||||
$(OBJDIR)/osimage.elf: $(MAIN_OBJ) $(ARMLIB)/libgcc.a
|
||||
$(LD) -g -Tldscript -Map=$(patsubst %.elf,%.map,$@) -o $@ $^
|
||||
|
||||
$(OBJDIR)/%.s19: $(OBJDIR)/%.elf
|
||||
$(OBJCOPY) -Osrec --srec-forceS3 $^ $@
|
||||
|
||||
$(OBJ) $(OBJFPGA): $(OBJDIR)/%.o: %.c $(INCLUDES)
|
||||
$(CC) $(CFLAGS) -mthumb -mthumb-interwork $< -o $@
|
||||
|
||||
clean:
|
||||
$(DELETE) $(OBJDIR)$(PATHSEP)*.o
|
||||
$(DELETE) $(OBJDIR)$(PATHSEP)*.elf
|
||||
$(DELETE) $(OBJDIR)$(PATHSEP)*.s19
|
||||
$(DELETE) $(OBJDIR)$(PATHSEP)*.map
|
||||
$(DELETE) $(OBJDIR)$(PATHSEP)*.d
|
||||
|
||||
.PHONY: all clean help
|
||||
help:
|
||||
|
@ -51,3 +53,4 @@ help:
|
|||
@echo + osimage.s19 - The OS image
|
||||
@echo + fpgaimage.s19 - The FPGA image
|
||||
@echo + clean - Clean $(OBJDIR)
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
# Makefile for bootrom, see ../common/Makefile.common for common settings
|
||||
include ../common/Makefile.common
|
||||
|
||||
OBJJTAG = $(OBJDIR)/bootrom.o $(OBJDIR)/ram-reset.o $(OBJDIR)/usb.o
|
||||
OBJFLASH = $(OBJDIR)/flash-reset.o $(OBJDIR)/fromflash.o
|
||||
|
@ -7,8 +6,8 @@ OBJFLASH = $(OBJDIR)/flash-reset.o $(OBJDIR)/fromflash.o
|
|||
THUMBSRC = usb.c fromflash.c bootrom.c
|
||||
ASMSRC = ram-reset.s flash-reset.s
|
||||
|
||||
THUMBOBJ = $(patsubst %.c,$(OBJDIR)/%.o,$(THUMBSRC))
|
||||
ASMOBJ = $(patsubst %.s,$(OBJDIR)/%.o,$(ASMSRC))
|
||||
# Do not move this inclusion before the definition of {THUMB,ASM,ARM}{OBJ,SRC}
|
||||
include ../common/Makefile.common
|
||||
|
||||
all: bootrom-merged.s19
|
||||
|
||||
|
@ -21,20 +20,12 @@ $(OBJDIR)/bootrom.elf: $(OBJFLASH)
|
|||
$(OBJDIR)/bootrom-forjtag.elf: $(OBJJTAG)
|
||||
$(LD) -g -Tldscript-ram-jtag --oformat elf32-littlearm -Map=$(patsubst %.elf,%.map,$@) -o $@ $^
|
||||
|
||||
$(OBJDIR)/%.s19: $(OBJDIR)/%.elf
|
||||
$(OBJCOPY) -Osrec --srec-forceS3 $^ $@
|
||||
|
||||
$(THUMBOBJ): $(OBJDIR)/%.o: %.c $(INCLUDES)
|
||||
$(CC) $(CFLAGS) -mthumb -mthumb-interwork -o $@ $<
|
||||
|
||||
$(ASMOBJ): $(OBJDIR)/%.o: %.s
|
||||
$(CC) $(CFLAGS) -mthumb-interwork -o $@ $<
|
||||
|
||||
clean:
|
||||
$(DELETE) $(OBJDIR)$(PATHSEP)*.o
|
||||
$(DELETE) $(OBJDIR)$(PATHSEP)*.elf
|
||||
$(DELETE) $(OBJDIR)$(PATHSEP)*.s19
|
||||
$(DELETE) $(OBJDIR)$(PATHSEP)*.map
|
||||
$(DELETE) $(OBJDIR)$(PATHSEP)*.d
|
||||
$(DELETE) bootrom-merged.s19
|
||||
|
||||
.PHONY: all clean help
|
||||
|
|
|
@ -3,27 +3,38 @@
|
|||
# Following is a short OS detection to set up variables, all the
|
||||
# remaining Makefile should be portable and only depend on these
|
||||
# variables
|
||||
#
|
||||
|
||||
# Make sure that all is the default target
|
||||
# (The including Makefile still needs to define what 'all' is)
|
||||
all:
|
||||
|
||||
# Windows' echo echos its input verbatim, on Posix there is some
|
||||
# amount of shell command line parsing going on. echo "" on
|
||||
# Windows yields literal "", on Linux yields an empty line
|
||||
ifeq ($(shell echo ""),)
|
||||
|
||||
# This is properly a proper system, so we can use uname
|
||||
UNAME := $(shell uname)
|
||||
ifeq ($(UNAME), Linux)
|
||||
# Linux. (Todo: Add MacOS X if appropriate)
|
||||
DELETE=rm -rf
|
||||
MOVE=mv
|
||||
PATHSEP=/
|
||||
DETECTED_OS=Linux
|
||||
# You may/should set this in your environment
|
||||
ARMLIB ?= /usr/local/lib/gcc/arm-elf/4.3.3/interwork
|
||||
endif
|
||||
|
||||
else
|
||||
|
||||
# Assume that we are running on Windows.
|
||||
DELETE=del /q
|
||||
MOVE=ren
|
||||
PATHSEP=\\#
|
||||
ARMLIB ?= ../../devkitARM/lib/gcc/arm-elf/4.1.0/interwork
|
||||
DETECTED_OS=Windows
|
||||
|
||||
endif
|
||||
|
||||
CC = arm-elf-gcc
|
||||
|
@ -41,3 +52,32 @@ VPATH = . ../common/
|
|||
INCLUDES = ../include/proxmark3.h ../include/at91sam7s128.h ../include/config_gpio.h ../include/usb_cmd.h $(APP_INCLUDES)
|
||||
|
||||
CFLAGS = -c $(INCLUDE) -Wall $(APP_CFLAGS)
|
||||
|
||||
THUMBOBJ = $(patsubst %.c,$(OBJDIR)/%.o,$(THUMBSRC))
|
||||
ARMOBJ = $(patsubst %.c,$(OBJDIR)/%.o,$(ARMSRC))
|
||||
ASMOBJ = $(patsubst %.s,$(OBJDIR)/%.o,$(ASMSRC))
|
||||
|
||||
$(THUMBOBJ): $(OBJDIR)/%.o: %.c $(INCLUDES)
|
||||
$(CC) $(CFLAGS) -mthumb -mthumb-interwork -o $@ $<
|
||||
|
||||
$(ARMOBJ): $(OBJDIR)/%.o: %.c $(INCLUDES)
|
||||
$(CC) $(CFLAGS) -mthumb-interwork -o $@ $<
|
||||
|
||||
$(ASMOBJ): $(OBJDIR)/%.o: %.s
|
||||
$(CC) $(CFLAGS) -mthumb-interwork -o $@ $<
|
||||
|
||||
$(OBJDIR)/%.s19: $(OBJDIR)/%.elf
|
||||
$(OBJCOPY) -Osrec --srec-forceS3 $^ $@
|
||||
|
||||
# Automatic dependency generation
|
||||
DEPENDENCY_FILES = $(patsubst %.c,$(OBJDIR)/%.d,$(notdir $(THUMBSRC))) \
|
||||
$(patsubst %.c,$(OBJDIR)/%.d,$(notdir $(ARMSRC))) \
|
||||
$(patsubst %.s,$(OBJDIR)/%.d,$(notdir $(ASMSRC)))
|
||||
|
||||
$(DEPENDENCY_FILES): Makefile ../common/Makefile.common
|
||||
$(OBJDIR)/%.d: %.c
|
||||
$(CC) -MM -MT "$(@) $(@:.d=.o)" $(CFLAGS) $< > $@
|
||||
$(OBJDIR)/%.d: %.s
|
||||
$(CC) -MM -MT "$(@) $(@:.d=.o)" $(CFLAGS) $< > $@
|
||||
|
||||
-include $(DEPENDENCY_FILES)
|
||||
|
|
Loading…
Reference in a new issue