+ Needs GNU make for Windows, a new release of the Windows development environment will follow
+ Is based on the Windows Makefile, so will build everything in Thumb mode, doesn't have flash commands (yet)
-PATH=..\..\devkitARM\bin;%PATH%\r
-CC = arm-elf-gcc\r
-AS = arm-elf-as\r
-LD = arm-elf-ld\r
-OBJCOPY = arm-elf-objcopy\r
+# Makefile for armsrc, see ../common/Makefile.common for common settings\r
+include ../common/Makefile.common\r
\r
-OBJDIR = obj\r
+APP_INCLUDES = apps.h\r
\r
-INCLUDE = -I../include\r
-\r
-INCLUDES = ../include/proxmark3.h ../include/at91sam7s128.h ../include/config_gpio.h ../include/usb_cmd.h apps.h\r
-LIB = "..\..\devkitARM\lib\gcc\arm-elf\4.1.0\interwork"\r
-\r
-# Add the "-DWITH_LCD" flag in CLFAGS to add support for LCD\r
+# Add the "-DWITH_LCD" flag in APP_CLFAGS to add support for LCD\r
# and add OBJLCD to OBJ too\r
-CFLAGS = -O6 -c $(INCLUDE) -Wall\r
+APP_CFLAGS = -O6\r
\r
OBJLCD = $(OBJDIR)/fonts.o \\r
$(OBJDIR)/LCD.o\r
$(OBJDIR)/iso14443.o \\r
$(OBJDIR)/iso14443a.o \\r
$(OBJDIR)/iso15693.o \\r
- $(OBJDIR)/util.o\r
+ $(OBJDIR)/util.o \\r
+ $(OBJDIR)/usb.o\r
\r
OBJFPGA = \\r
$(OBJDIR)/fpgaimg.o\r
\r
-OBJCOMMON = \\r
- $(OBJDIR)/usb.o\r
-\r
-all: osimage.s19\r
-\r
-$(OBJDIR)/fpgaimage.s19: $(OBJDIR)/fpgaimg.o\r
- @echo obj/fpgaimage.s19\r
- @$(LD) -g -Tldscript-fpga -o $(OBJDIR)\fpgaimage.elf -Map=obj/fpgaimage.map $(OBJDIR)/fpgaimg.o\r
- @$(OBJCOPY) -Osrec --srec-forceS3 $(OBJDIR)\fpgaimage.elf $(OBJDIR)\fpgaimage.s19\r
-\r
-$(OBJDIR)/osimage.s19: $(OBJ) $(OBJCOMMON)\r
- @echo obj/osimage.s19\r
- @$(LD) -g -Tldscript -o $(OBJDIR)\osimage.elf $(OBJ) $(OBJCOMMON) -Map=obj/osimage.map $(LIB)\libgcc.a\r
- @$(OBJCOPY) -Osrec --srec-forceS3 $(OBJDIR)\osimage.elf $(OBJDIR)\osimage.s19\r
+all: $(OBJDIR)/osimage.s19 $(OBJDIR)/fpgaimage.s19\r
\r
-osimage.s19: $(OBJDIR)/osimage.s19 $(OBJDIR)/fpgaimage.s19\r
- @echo osimage.s19\r
+$(OBJDIR)/fpgaimage.elf: $(OBJDIR)/fpgaimg.o\r
+ $(LD) -g -Tldscript-fpga -Map=$(patsubst %.elf,%.map,$@) -o $@ $^\r
\r
-$(OBJ): $(@B).c $(INCLUDES)\r
- @echo $(@B).c\r
- @$(CC) $(CFLAGS) -mthumb -mthumb-interwork $(@B).c -o $(OBJDIR)/$(@B).o\r
+$(OBJDIR)/osimage.elf: $(OBJ) $(OBJCOMMON) $(ARMLIB)/libgcc.a\r
+ $(LD) -g -Tldscript -Map=$(patsubst %.elf,%.map,$@) -o $@ $^\r
\r
-$(OBJCOMMON): ../common/$(@B).c $(INCLUDES)\r
- @echo $(@B).c\r
- @$(CC) $(CFLAGS) -mthumb -mthumb-interwork ../common/$(@B).c -o $(OBJDIR)/$(@B).o\r
+$(OBJDIR)/%.s19: $(OBJDIR)/%.elf\r
+ $(OBJCOPY) -Osrec --srec-forceS3 $^ $@\r
\r
-$(OBJFPGA): $(@B).c $(INCLUDES)\r
- @echo $(@B).c\r
- @$(CC) $(CFLAGS) -mthumb -mthumb-interwork $(@B).c -o $(OBJDIR)/$(@B).o\r
+$(OBJ) $(OBJFPGA): $(OBJDIR)/%.o: %.c $(INCLUDES)\r
+ $(CC) $(CFLAGS) -mthumb -mthumb-interwork $< -o $@\r
\r
clean:\r
- del /q obj\*.o\r
- del /q obj\*.elf\r
- del /q obj\*.s19\r
+ $(DELETE) $(OBJDIR)$(PATHSEP)*.o\r
+ $(DELETE) $(OBJDIR)$(PATHSEP)*.elf\r
+ $(DELETE) $(OBJDIR)$(PATHSEP)*.s19\r
+ $(DELETE) $(OBJDIR)$(PATHSEP)*.map\r
+\r
+.PHONY: all clean help\r
+help:\r
+ @echo Multi-OS Makefile, you are running on $(DETECTED_OS)\r
+ @echo Possible targets:\r
+ @echo + all - Make both:\r
+ @echo + osimage.s19 - The OS image\r
+ @echo + fpgaimage.s19 - The FPGA image\r
+ @echo + clean - Clean $(OBJDIR)\r
+++ /dev/null
-# This makefile needs to be edited to reflect the location
-# of your own arm-elf-gcc toolchain (ARMLIB variable)
-
-CC = arm-elf-gcc
-AS = arm-elf-as
-LD = arm-elf-ld
-OBJCOPY = arm-elf-objcopy
-
-# Indicate where your gnuarm toolchain libgcc.a interworking library is located
-# or set $ARMLIB in your environment:
-#ARMLIB = /usr/local/lib/gcc/arm-elf/4.3.3/interwork
-
-
-# Add -DWITH_LCD to EXTRA_CFLAGS if you want support for LCD
-# in your firmware (add OBJLCD to OBJ too!)
-#EXTRA_CFLAGS = -DWITH_LCD
-EXTRA_CFLAGS =
-
-### You should not need to edit below this line
-
-INCLUDE = -I../include
-INCLUDES = ../include/proxmark3.h ../include/at91sam7s128.h ../include/config_gpio.h ../include/usb_cmd.h apps.h
-CFLAGS_COMMON = -O6 -c $(INCLUDE) -Wall -mthumb-interwork
-CFLAGS = $(CFLAGS_COMMON) $(EXTRA_CFLAGS) -mthumb
-
-
-OBJDIR = obj
-
-OBJLCD = $(OBJDIR)/LCD.o\
- $(OBJDIR)/fonts.o
-
-OBJ = $(OBJDIR)/start.o \
- $(OBJDIR)/appmain.o \
- $(OBJDIR)/fpga.o \
- $(OBJDIR)/lfops.o \
- $(OBJDIR)/iso15693.o \
- $(OBJDIR)/util.o
-
-# To be compiled in ARM mode, not thumb mode: larger but faster
-# Alleviates the 'blew circular buffer' issues somehow...
-OBJFAST = $(OBJDIR)/iso14443.o \
- $(OBJDIR)/iso14443a.o
-
-OBJFPGA = $(OBJDIR)/fpgaimg.o
-
-OBJCOMMON = $(OBJDIR)/usb.o
-
-all: osimage.s19 fpgaimage.s19 fullimage.s19
-
-fpgaimage.s19: $(OBJFPGA)
- @echo fpgaimage.s19
- $(LD) -g -Tldscript-fpga -o $(OBJDIR)/fpgaimage.elf $^
- $(OBJCOPY) -Osrec --srec-forceS3 $(OBJDIR)/fpgaimage.elf fpgaimage.s19
-
-osimage.s19: $(OBJ) $(OBJFAST) $(OBJCOMMON)
- @echo osimage.s19
- $(LD) -g -Tldscript -o $(OBJDIR)/osimage.elf -Map=osimage.map $^ $(ARMLIB)/libgcc.a
- $(OBJCOPY) -Osrec --srec-forceS3 $(OBJDIR)/osimage.elf osimage.s19
-
-fullimage.s19: $(OBJ) $(OBJFAST) $(OBJCOMMON) $(OBJFAST) $(OBJFPGA)
- @echo fullimage.s19
- $(LD) -g -Tldscript-full -o $(OBJDIR)/fullimage.elf $^ $(ARMLIB)/libgcc.a
- $(OBJCOPY) -Osrec --srec-forceS3 $(OBJDIR)/fullimage.elf fullimage.s19
-
-# Directives to put the *.o in the OBJDIR directory:
-$(OBJ): $(OBJDIR)/%.o : %.c
- $(CC) $(CFLAGS) $< -o $@
-
-$(OBJFPGA): $(OBJDIR)/%.o : %.c
- $(CC) $(CFLAGS) $< -o $@
-
-$(OBJFAST): $(OBJDIR)/%.o : %.c
- $(CC) $(CFLAGS_COMMON) $< -o $@
-
-$(OBJCOMMON): $(OBJDIR)/%.o : ../common/%.c
- $(CC) $(CFLAGS) $< -o $@
-
-flash-both: flash flash-fpga
-
-flash-fpga: fpgaimage.s19
- ../linux/flasher fpga fpgaimage.s19
-
-flash: osimage.s19
- ../linux/flasher os osimage.s19
-
-# Those do not work on the current firmware !
-jtag-flash-full: fullimage.s19
- ../../OpenOCD/openocd -c "halt; flash write_image fullimage.s19 0x00100000; halt; reset; resume; poll; exit"
-
-jtag-flash-fpga: fpgaimage.s19
- ../../OpenOCD/openocd -c "halt; flash write_image fpgaimage.s19 0x00100000; halt; reset; resume; poll; exit"
-
-jtag-flash: osimage.s19
- ../../OpenOCD/openocd -c "halt; flash write_image osimage.s19 0x00100000; halt; reset; resume; poll; exit"
-
-clean:
- rm -f $(OBJDIR)/*.o $(OBJDIR)/*.elf *.s19 osimage.map
-
-.PHONY: all clean
-CC = arm-elf-gcc\r
-AS = arm-elf-as\r
-LD = arm-elf-ld\r
-OBJCOPY = arm-elf-objcopy\r
-\r
-OBJDIR = obj\r
-\r
-INCLUDE = -I../include\r
-\r
-INCLUDES = ../include/proxmark3.h ../include/at91sam7s128.h ../include/config_gpio.h ../include/usb_cmd.h\r
-\r
-CFLAGS = -g -c $(INCLUDE) -Wall\r
+# Makefile for bootrom, see ../common/Makefile.common for common settings\r
+include ../common/Makefile.common\r
\r
OBJJTAG = $(OBJDIR)/bootrom.o $(OBJDIR)/ram-reset.o $(OBJDIR)/usb.o\r
-\r
OBJFLASH = $(OBJDIR)/flash-reset.o $(OBJDIR)/fromflash.o\r
\r
-all: bootrom.s19\r
+THUMBSRC = usb.c fromflash.c bootrom.c\r
+ASMSRC = ram-reset.s flash-reset.s\r
\r
-bootrom.s19: $(OBJDIR)/bootrom.s19 $(OBJDIR)/bootrom-forjtag.s19\r
- @echo bootrom.s19\r
- @perl ..\tools\merge-srec.pl $(OBJDIR)\bootrom.s19 $(OBJDIR)\bootrom-forjtag.s19 > $(OBJDIR)\bootrom-merged.s19\r
- @perl ..\tools\srecswap.pl $(OBJDIR)\bootrom-forjtag.s19 > $(OBJDIR)\bootrom-forjtag-swapped.s19\r
+THUMBOBJ = $(patsubst %.c,$(OBJDIR)/%.o,$(THUMBSRC))\r
+ASMOBJ = $(patsubst %.s,$(OBJDIR)/%.o,$(ASMSRC))\r
\r
-$(OBJDIR)/bootrom.s19: $(OBJFLASH)\r
- @echo obj/bootrom.s19\r
- @$(LD) -g -Tldscript-flash --oformat elf32-littlearm -Map=obj/bootrom.map -o $(OBJDIR)/bootrom.elf $(OBJFLASH)\r
- @$(OBJCOPY) -Osrec --srec-forceS3 $(OBJDIR)/bootrom.elf $(OBJDIR)/bootrom.s19\r
+all: bootrom-merged.s19\r
\r
-$(OBJDIR)/bootrom-forjtag.s19: $(OBJJTAG)\r
- @echo obj/bootrom-forjtag.s19\r
- @$(LD) -g -Tldscript-ram-jtag --oformat elf32-littlearm -Map=obj/bootrom-forjtag.map -o $(OBJDIR)/bootrom-forjtag.elf $(OBJJTAG)\r
- @$(OBJCOPY) -Osrec --srec-forceS3 $(OBJDIR)/bootrom-forjtag.elf $(OBJDIR)/bootrom-forjtag.s19\r
+bootrom-merged.s19: $(OBJDIR)/bootrom.s19 $(OBJDIR)/bootrom-forjtag.s19\r
+ perl ../tools/merge-srec.pl $(OBJDIR)/bootrom.s19 $(OBJDIR)/bootrom-forjtag.s19 > bootrom-merged.s19\r
\r
-$(OBJDIR)/bootrom.o: bootrom.c $(INCLUDES)\r
- @echo $(@B).c\r
- @$(CC) $(CFLAGS) -mthumb -mthumb-interwork bootrom.c -o $(OBJDIR)/bootrom.o\r
+$(OBJDIR)/bootrom.elf: $(OBJFLASH)\r
+ $(LD) -g -Tldscript-flash --oformat elf32-littlearm -Map=$(patsubst %.elf,%.map,$@) -o $@ $^\r
\r
-$(OBJDIR)/fromflash.o: fromflash.c $(INCLUDES)\r
- @echo $(@B).c\r
- @$(CC) $(CFLAGS) -mthumb -mthumb-interwork fromflash.c -o $(OBJDIR)/fromflash.o\r
+$(OBJDIR)/bootrom-forjtag.elf: $(OBJJTAG)\r
+ $(LD) -g -Tldscript-ram-jtag --oformat elf32-littlearm -Map=$(patsubst %.elf,%.map,$@) -o $@ $^\r
\r
-$(OBJDIR)/usb.o: ../common/usb.c $(INCLUDES)\r
- @echo $(@B).c\r
- @$(CC) $(CFLAGS) -mthumb -mthumb-interwork ../common/usb.c -o $(OBJDIR)/usb.o\r
+$(OBJDIR)/%.s19: $(OBJDIR)/%.elf\r
+ $(OBJCOPY) -Osrec --srec-forceS3 $^ $@\r
\r
-$(OBJDIR)/ram-reset.o: ram-reset.s\r
- @echo $(@B).s\r
- @$(CC) $(CFLAGS) -mthumb-interwork -o $(OBJDIR)/ram-reset.o ram-reset.s\r
+$(THUMBOBJ): $(OBJDIR)/%.o: %.c $(INCLUDES)\r
+ $(CC) $(CFLAGS) -mthumb -mthumb-interwork -o $@ $< \r
\r
-$(OBJDIR)/flash-reset.o: flash-reset.s\r
- @echo $(@B).s\r
- @$(CC) $(CFLAGS) -mthumb-interwork -o $(OBJDIR)/flash-reset.o flash-reset.s\r
+$(ASMOBJ): $(OBJDIR)/%.o: %.s\r
+ $(CC) $(CFLAGS) -mthumb-interwork -o $@ $<\r
\r
clean:\r
- del /q obj\*.o\r
- del /q obj\*.elf\r
- del /q obj\*.s19\r
+ $(DELETE) $(OBJDIR)$(PATHSEP)*.o\r
+ $(DELETE) $(OBJDIR)$(PATHSEP)*.elf\r
+ $(DELETE) $(OBJDIR)$(PATHSEP)*.s19\r
+ $(DELETE) $(OBJDIR)$(PATHSEP)*.map\r
+ $(DELETE) bootrom-merged.s19\r
+\r
+.PHONY: all clean help\r
+help:\r
+ @echo Multi-OS Makefile, you are running on $(DETECTED_OS)\r
+ @echo Possible targets:\r
+ @echo + all - Make bootrom-merged.s19, the main bootrom\r
+ @echo + clean - Clean $(OBJDIR)\r
+++ /dev/null
-CC = arm-elf-gcc
-AS = arm-elf-as
-LD = arm-elf-ld
-OBJCOPY = arm-elf-objcopy
-
-OBJDIR = obj
-
-INCLUDE = -I../include
-
-INCLUDES = ../include/proxmark3.h ../include/at91sam7s128.h ../include/config_gpio.h ../include/usb_cmd.h
-
-CFLAGS = -g -c $(INCLUDE) -Wall
-
-OBJJTAG = $(OBJDIR)/bootrom.o $(OBJDIR)/ram-reset.o $(OBJDIR)/usb.o
-
-OBJFLASH = $(OBJDIR)/flash-reset.o $(OBJDIR)/fromflash.o
-
-all: bootrom.s19 bootrom-forjtag-swapped.s19
-
-bootrom-merged.s19: bootrom.s19 bootrom-forjtag.s19
- perl ../tools/merge-srec.pl bootrom.s19 bootrom-forjtag.s19 > bootrom-merged.s19
-
-bootrom-forjtag-swapped.s19: bootrom-merged.s19
- perl ../tools/srecswap.pl bootrom-forjtag.s19 > bootrom-forjtag-swapped.s19
-
-bootrom.s19: $(OBJFLASH)
- @echo bootrom.s19
- $(LD) -g -Tldscript-flash --oformat elf32-littlearm -o $(OBJDIR)/bootrom.elf $(OBJFLASH)
- $(OBJCOPY) -Osrec --srec-forceS3 $(OBJDIR)/bootrom.elf bootrom.s19
-
-bootrom-forjtag.s19: $(OBJJTAG)
- @echo bootrom-forjtag.s19
- $(LD) -g -Tldscript-ram-jtag --oformat elf32-littlearm -o $(OBJDIR)/bootrom-forjtag.elf $(OBJJTAG)
- $(OBJCOPY) -Osrec --srec-forceS3 $(OBJDIR)/bootrom-forjtag.elf bootrom-forjtag.s19
-
-$(OBJDIR)/bootrom.o: bootrom.c $(INCLUDES)
- @echo $@
- $(CC) $(CFLAGS) -mthumb -mthumb-interwork $< -o $@
-
-$(OBJDIR)/fromflash.o: fromflash.c $(INCLUDES)
- @echo $@
- $(CC) $(CFLAGS) -mthumb -mthumb-interwork $< -o $@
-
-$(OBJDIR)/usb.o: ../common/usb.c $(INCLUDES)
- @echo $@
- $(CC) $(CFLAGS) -mthumb -mthumb-interwork $< -o $@
-
-$(OBJDIR)/ram-reset.o: ram-reset.s
- @echo $@
- $(CC) $(CFLAGS) -mthumb-interwork -o $@ $<
-
-$(OBJDIR)/flash-reset.o: flash-reset.s
- @echo $@
- $(CC) $(CFLAGS) -mthumb-interwork -o $@ $<
-
-# Those do not work in this Firmware distribution!
-flash: bootrom-merged.s19
- ../linux/flasher bootrom bootrom-merged.s19
-
-jtag-flash: bootrom-merged.s19
- ../../OpenOCD/openocd -c "halt; flash write_image bootrom-merged.s19 0x00100000; halt; reset; resume; poll; exit"
-
-clean:
- rm -f $(OBJDIR)/*.o $(OBJDIR)/*.elf *.s19
-
--- /dev/null
+# This new makefile replaces the previous Makefile/Makefile.linux
+# with as much common code for both environments as possible.
+# Following is a short OS detection to set up variables, all the
+# remaining Makefile should be portable and only depend on these
+# variables
+
+# 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
+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
+PATHSEP=\\#
+ARMLIB ?= ../../devkitARM/lib/gcc/arm-elf/4.1.0/interwork
+DETECTED_OS=Windows
+endif
+
+CC = arm-elf-gcc
+AS = arm-elf-as
+LD = arm-elf-ld
+OBJCOPY = arm-elf-objcopy
+
+OBJDIR = obj
+
+INCLUDE = -I../include
+
+# Also search prerequisites in the common directory (for usb.c)
+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)