Skip to content

Commit

Permalink
make install: half way
Browse files Browse the repository at this point in the history
  • Loading branch information
doegox committed Aug 30, 2019
1 parent b5f5b92 commit 4fdb5a2
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 58 deletions.
31 changes: 22 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,48 @@ ifneq ($(V),1)
endif
# To see full command lines, use make V=1

COPY=cp
CP = cp -a
GZIP=gzip
MKDIR = mkdir -p
RM = rm -f
RMDIR = rm -rf
-include Makefile.platform
-include .Makefile.options.cache
include common_arm/Makefile.hal

# preserve relative DESTDIR path for subdir makes
ifneq (,$(DESTDIR))
# realpath needs the directory to exist
$(shell $(MKDIR) $(DESTDIR))
MYDESTDIR:=$(realpath $(DESTDIR))
ifeq (,$(MYDESTDIR))
$(error Can't create $(DESTDIR))
endif
endif

all clean install uninstall: %: client/% bootrom/% armsrc/% recovery/% mfkey/% nonce2key/% fpga_compress/%

mfkey/%: FORCE
$(info [*] MAKE $@)
$(Q)$(MAKE) --no-print-directory -C tools/mfkey $(patsubst mfkey/%,%,$@)
$(Q)$(MAKE) --no-print-directory -C tools/mfkey $(patsubst mfkey/%,%,$@) DESTDIR=$(MYDESTDIR)
nonce2key/%: FORCE
$(info [*] MAKE $@)
$(Q)$(MAKE) --no-print-directory -C tools/nonce2key $(patsubst nonce2key/%,%,$@)
$(Q)$(MAKE) --no-print-directory -C tools/nonce2key $(patsubst nonce2key/%,%,$@) DESTDIR=$(MYDESTDIR)
fpga_compress/%: FORCE
$(info [*] MAKE $@)
$(Q)$(MAKE) --no-print-directory -C tools/fpga_compress $(patsubst fpga_compress/%,%,$@)
$(Q)$(MAKE) --no-print-directory -C tools/fpga_compress $(patsubst fpga_compress/%,%,$@) DESTDIR=$(MYDESTDIR)
bootrom/%: FORCE cleanifplatformchanged
$(info [*] MAKE $@)
$(Q)$(MAKE) --no-print-directory -C bootrom $(patsubst bootrom/%,%,$@)
$(Q)$(MAKE) --no-print-directory -C bootrom $(patsubst bootrom/%,%,$@) DESTDIR=$(MYDESTDIR)
armsrc/%: FORCE cleanifplatformchanged fpga_compress/%
$(info [*] MAKE $@)
$(Q)$(MAKE) --no-print-directory -C armsrc $(patsubst armsrc/%,%,$@)
$(Q)$(MAKE) --no-print-directory -C armsrc $(patsubst armsrc/%,%,$@) DESTDIR=$(MYDESTDIR)
client/%: FORCE
$(info [*] MAKE $@)
$(Q)$(MAKE) --no-print-directory -C client $(patsubst client/%,%,$@)
$(Q)$(MAKE) --no-print-directory -C client $(patsubst client/%,%,$@) DESTDIR=$(MYDESTDIR)
recovery/%: FORCE cleanifplatformchanged bootrom/% armsrc/%
$(info [*] MAKE $@)
$(Q)$(MAKE) --no-print-directory -C recovery $(patsubst recovery/%,%,$@)
$(Q)$(MAKE) --no-print-directory -C recovery $(patsubst recovery/%,%,$@) DESTDIR=$(MYDESTDIR)
FORCE: # Dummy target to force remake in the subdirectories, even if files exist (this Makefile doesn't know about the prerequisites)

.PHONY: all clean install uninstall help _test bootrom fullimage recovery client mfkey nonce2key style checks FORCE udev accessrights cleanifplatformchanged
Expand Down Expand Up @@ -77,7 +90,7 @@ nonce2key: nonce2key/all
fpga_compress: fpga_compress/all

newtarbin:
$(DELETE) proxmark3-$(platform)-bin.tar proxmark3-$(platform)-bin.tar.gz
$(RM) proxmark3-$(platform)-bin.tar proxmark3-$(platform)-bin.tar.gz
@touch proxmark3-$(platform)-bin.tar

tarbin: newtarbin client/tarbin armsrc/tarbin bootrom/tarbin
Expand Down
14 changes: 12 additions & 2 deletions Makefile.host
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ ifneq ($(V),1)
endif
# To see full command lines, use make V=1

INSTALLBINRELPATH = /bin/
INSTALLTOOLSRELPATH = /share/proxmark3/tools/

CC = gcc
LD = gcc
RM = rm -f
Expand Down Expand Up @@ -49,11 +52,18 @@ clean:
$(Q)$(RMDIR) $(OBJDIR)

install: all
$(info [@] Installing $(BINS) $(LIB_A) to $(PREFIX))
ifneq (,$(INSTALLTOOLS))
$(info [@] Installing $(BINS) to $(DESTDIR)$(PREFIX)...)
$(Q)$(MKDIR) $(DESTDIR)$(PREFIX)$(INSTALLTOOLSRELPATH)
$(Q)$(CP) $(INSTALLTOOLS) $(DESTDIR)$(PREFIX)$(INSTALLTOOLSRELPATH)
endif
@true

uninstall:
$(info [@] Uninstalling $(BINS) $(LIB_A) from $(PREFIX))
ifneq (,$(INSTALLTOOLS))
$(info [@] Uninstalling $(BINS) from $(DESTDIR)$(PREFIX)...)
$(Q)$(RM) $(foreach tool,$(INSTALLTOOLS),$(DESTDIR)$(PREFIX)$(INSTALLTOOLSRELPATH)$(notdir $(tool)))
endif
@true

.PHONY: all clean install uninstall
Expand Down
30 changes: 16 additions & 14 deletions armsrc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ include ../common_arm/Makefile.common

COMMON_FLAGS = -Os

INSTALLFW = $(OBJDIR)/fullimage.elf
OBJS = $(OBJDIR)/fullimage.s19
FPGA_COMPRESSOR = ../tools/fpga_compress/fpga_compress

Expand All @@ -144,7 +145,7 @@ all: $(OBJS)
# version.c should be remade on every time fullimage.stage1.elf should be remade
version.c: default_version.c $(OBJDIR)/fpga_version_info.o $(OBJDIR)/fpga_all.o $(THUMBOBJ) $(ARMOBJ)
$(info [-] GEN $@)
$(Q)sh ../tools/mkversion.sh > $@ || perl ../tools/mkversion.pl > $@ || $(COPY) $^ $@
$(Q)sh ../tools/mkversion.sh > $@ || perl ../tools/mkversion.pl > $@ || $(CP) $^ $@

fpga_version_info.c: $(FPGA_BITSTREAMS) | $(FPGA_COMPRESSOR)
$(info [-] GEN $@)
Expand Down Expand Up @@ -203,23 +204,24 @@ tarbin: $(OBJS)
$(Q)$(TAR) $(TARFLAGS) ../proxmark3-$(platform)-bin.tar $(OBJS:%=armsrc/%) $(OBJS:%.s19=armsrc/%.elf)

clean:
$(Q)$(DELETE) $(DEPENDENCY_FILES)
$(Q)$(DELETE) $(OBJDIR)$(PATHSEP)*.o
$(Q)$(DELETE) $(OBJDIR)$(PATHSEP)*.elf
$(Q)$(DELETE) $(OBJDIR)$(PATHSEP)*.s19
$(Q)$(DELETE) $(OBJDIR)$(PATHSEP)*.map
$(Q)$(DELETE) $(OBJDIR)$(PATHSEP)*.d
$(Q)$(DELETE) $(OBJDIR)$(PATHSEP)*.z
$(Q)$(DELETE) $(OBJDIR)$(PATHSEP)*.bin
$(Q)$(DELETE) version.c
$(Q)$(RM) $(DEPENDENCY_FILES)
$(Q)$(RM) $(OBJDIR)$(PATHSEP)*.o
$(Q)$(RM) $(OBJDIR)$(PATHSEP)*.elf
$(Q)$(RM) $(OBJDIR)$(PATHSEP)*.s19
$(Q)$(RM) $(OBJDIR)$(PATHSEP)*.map
$(Q)$(RM) $(OBJDIR)$(PATHSEP)*.d
$(Q)$(RM) $(OBJDIR)$(PATHSEP)*.z
$(Q)$(RM) $(OBJDIR)$(PATHSEP)*.bin
$(Q)$(RM) version.c

install: all
$(info [@] Installing fullimage to $(PREFIX))
@true
$(info [@] Installing fullimage to $(DESTDIR)$(PREFIX)...)
$(Q)$(MKDIR) $(DESTDIR)$(PREFIX)$(INSTALLFWRELPATH)
$(Q)$(CP) $(INSTALLFW) $(DESTDIR)$(PREFIX)$(INSTALLFWRELPATH)

uninstall:
$(info [@] Uninstalling fullimage from $(PREFIX))
@true
$(info [@] Uninstalling fullimage from $(DESTDIR)$(PREFIX)...)
$(Q)$(RM) $(foreach fw,$(INSTALLFW),$(DESTDIR)$(PREFIX)$(INSTALLFWRELPATH)$(notdir $(fw)))

.PHONY: all clean help install uninstall
help:
Expand Down
25 changes: 14 additions & 11 deletions bootrom/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ APP_CFLAGS += -fno-stack-protector -fno-pie
# Do not move this inclusion before the definition of {THUMB,ASM,ARM}SRC
include ../common_arm/Makefile.common

INSTALLFW = $(OBJDIR)/bootrom.elf

OBJS = $(OBJDIR)/bootrom.s19

# version.c should be remade on every compilation
version.c: default_version.c
$(info [=] GEN $@)
$(Q)sh ../tools/mkversion.sh > $@ || perl ../tools/mkversion.pl > $@ || $(COPY) $^ $@
$(Q)sh ../tools/mkversion.sh > $@ || perl ../tools/mkversion.pl > $@ || $(CP) $^ $@

all: $(OBJS)

Expand All @@ -49,20 +51,21 @@ $(OBJDIR)/bootrom.elf: $(VERSIONOBJ) $(ASMOBJ) $(ARMOBJ) $(THUMBOBJ)
$(Q)$(CC) $(LDFLAGS) -Wl,-T,ldscript-flash,-Map,$(patsubst %.elf,%.map,$@) -o $@ $^ $(LIBS)

clean:
$(Q)$(DELETE) $(OBJDIR)$(PATHSEP)*.o
$(Q)$(DELETE) $(OBJDIR)$(PATHSEP)*.elf
$(Q)$(DELETE) $(OBJDIR)$(PATHSEP)*.s19
$(Q)$(DELETE) $(OBJDIR)$(PATHSEP)*.map
$(Q)$(DELETE) $(OBJDIR)$(PATHSEP)*.d
$(Q)$(DELETE) version.c
$(Q)$(RM) $(OBJDIR)$(PATHSEP)*.o
$(Q)$(RM) $(OBJDIR)$(PATHSEP)*.elf
$(Q)$(RM) $(OBJDIR)$(PATHSEP)*.s19
$(Q)$(RM) $(OBJDIR)$(PATHSEP)*.map
$(Q)$(RM) $(OBJDIR)$(PATHSEP)*.d
$(Q)$(RM) version.c

install: all
$(info [@] Installing bootrom to $(PREFIX))
@true
$(info [@] Installing bootrom to $(DESTDIR)$(PREFIX)...)
$(Q)$(MKDIR) $(DESTDIR)$(PREFIX)$(INSTALLFWRELPATH)
$(Q)$(CP) $(INSTALLFW) $(DESTDIR)$(PREFIX)$(INSTALLFWRELPATH)

uninstall:
$(info [@] Uninstalling bootrom from $(PREFIX))
@true
$(info [@] Uninstalling bootrom from $(DESTDIR)$(PREFIX)...)
$(Q)$(RM) $(foreach fw,$(INSTALLFW),$(DESTDIR)$(PREFIX)$(INSTALLFWRELPATH)$(notdir $(fw)))

.PHONY: all clean help install
help:
Expand Down
25 changes: 23 additions & 2 deletions client/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ ifneq ($(V),1)
endif
# To see full command lines, use make V=1

INSTALLBINRELPATH = /bin/
INSTALLSHARERELPATH = /share/proxmark3/
#TODO INSTALLBIN = proxmark3 proxmark3-flasher
INSTALLBIN = proxmark3 flasher
INSTALLSHARE = lualibs luascripts resources dictionaries

CC = gcc
CXX = g++
LD = g++
Expand All @@ -27,6 +33,7 @@ MKDIR = mkdir -p
MV = mv
TOUCH = touch
FALSE = false
CP=cp -a

platform = $(shell uname)
ROOT_DIR:=$(dir $(realpath $(lastword $(MAKEFILE_LIST))))
Expand Down Expand Up @@ -335,11 +342,25 @@ clean:
$(Q)$(MAKE) --no-print-directory -C $(REVENGPATH) clean

install: all
$(info [@] Installing client to $(PREFIX))
$(info [@] Installing client to $(DESTDIR)$(PREFIX)...)
ifneq (,$(INSTALLBIN))
$(Q)$(MKDIR) $(DESTDIR)$(PREFIX)$(INSTALLBINRELPATH)
$(Q)$(CP) $(INSTALLBIN) $(DESTDIR)$(PREFIX)$(INSTALLBINRELPATH)
endif
ifneq (,$(INSTALLSHARE))
$(Q)$(MKDIR) $(DESTDIR)$(PREFIX)$(INSTALLSHARERELPATH)
$(Q)$(CP) $(INSTALLSHARE) $(DESTDIR)$(PREFIX)$(INSTALLSHARERELPATH)
endif
@true

uninstall:
$(info [@] Uninstalling client from $(PREFIX))
$(info [@] Uninstalling client from $(DESTDIR)$(PREFIX)...)
ifneq (,$(INSTALLBIN))
$(Q)$(RM) $(foreach tool,$(INSTALLBIN),$(DESTDIR)$(PREFIX)$(INSTALLBINRELPATH)$(notdir $(tool)))
endif
ifneq (,$(INSTALLSHARE))
$(Q)$(RMDIR) $(foreach tool,$(INSTALLSHARE),$(DESTDIR)$(PREFIX)$(INSTALLSHARERELPATH)$(notdir $(tool)))
endif
@true

tarbin: $(BINS)
Expand Down
9 changes: 5 additions & 4 deletions common_arm/Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ all:

platform = $(shell uname)
PREFIX?=/usr/local
INSTALLFWRELPATH = /share/proxmark3/firmware/

CROSS ?= arm-none-eabi-
CC = $(CROSS)gcc
Expand All @@ -40,10 +41,10 @@ INCLUDE = -I../include -I../common_arm -I../common_fpga -I../common -I.

TAR=tar
TARFLAGS = -C .. -rvf

DELETE=rm -rf
MOVE=mv
COPY=cp
RM=rm -f
RMDIR=rm -rf
CP=cp -a
MKDIR=mkdir -p
PATHSEP=/
DETECTED_OS=$(platform)

Expand Down
16 changes: 8 additions & 8 deletions fpga/Makefile
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
all: fpga_lf.bit fpga_hf.bit
clean:
$(Q)$(DELETE) *.bgn *.drc *.ncd *.ngd *_par.xrpt *-placed.* *-placed_pad.* *_usage.xml xst_hf.srp xst_lf.srp
$(Q)$(DELETE) *.map *.ngc *.xrpt *.pcf *.rbt *_auto_* *.bld *.mrp *.ngm *.unroutes *_summary.xml netlist.lst xst
$(Q)$(RM) *.bgn *.drc *.ncd *.ngd *_par.xrpt *-placed.* *-placed_pad.* *_usage.xml xst_hf.srp xst_lf.srp
$(Q)$(RM) *.map *.ngc *.xrpt *.pcf *.rbt *_auto_* *.bld *.mrp *.ngm *.unroutes *_summary.xml netlist.lst xst

fpga_hf.ngc: fpga_hf.v fpga.ucf xst_hf.scr util.v hi_simulate.v hi_read_tx.v hi_read_rx_xcorr.v hi_iso14443a.v hi_sniffer.v hi_flite.v
$(Q)$(DELETE) $@
$(Q)$(RM) $@
$(info [-] XST $@)
$(Q)$(XILINX_TOOLS_PREFIX)xst -ifn xst_hf.scr


fpga_lf.ngc: fpga_lf.v fpga.ucf xst_lf.scr util.v clk_divider.v lo_edge_detect.v lo_read.v lo_passthru.v lp20khz_1MSa_iir_filter.v min_max_tracker.v lf_edge_detect.v
$(Q)$(DELETE) $@
$(Q)$(RM) $@
$(info [-] XST $@)
$(Q)$(XILINX_TOOLS_PREFIX)xst -ifn xst_lf.scr

%.ngd: %.ngc
$(Q)$(DELETE) $@
$(Q)$(RM) $@
$(info [-] NGD $@)
$(Q)$(XILINX_TOOLS_PREFIX)ngdbuild -aul -p xc2s30-5-vq100 -nt timestamp -uc fpga.ucf $< $@

%.ncd: %.ngd
$(Q)$(DELETE) $@
$(Q)$(RM) $@
$(info [-] MAP $@)
$(Q)$(XILINX_TOOLS_PREFIX)map -p xc2s30-5-vq100 $<

%-placed.ncd: %.ncd
$(Q)$(DELETE) $@
$(Q)$(RM) $@
$(info [-] PAR $@)
$(Q)$(XILINX_TOOLS_PREFIX)par $< $@

%.bit: %-placed.ncd
$(Q)$(DELETE) $@ $*.drc $*.rbt
$(Q)$(RM) $@ $*.drc $*.rbt
$(info [=] BITGEN $@)
$(Q)$(XILINX_TOOLS_PREFIX)bitgen $< $@

Expand Down
18 changes: 10 additions & 8 deletions recovery/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
include ../common_arm/Makefile.common

BINS = bootrom.bin fullimage.bin proxmark3_recovery.bin
INSTALLFW = proxmark3_recovery.bin
BINS = bootrom.bin fullimage.bin $(INSTALLFW)

all: $(BINS)

Expand All @@ -17,14 +18,15 @@ proxmark3_recovery.bin: bootrom.bin fullimage.bin
$(Q)cat bootrom.bin fullimage.bin > $@

clean:
$(Q)rm -f $(BINS)
$(Q)$(RM) $(BINS)

install: all
$(info [@] Installing recovery to $(PREFIX))
@true
$(info [@] Installing recovery to $(DESTDIR)$(PREFIX)...)
$(Q)$(MKDIR) $(DESTDIR)$(PREFIX)$(INSTALLFWRELPATH)
$(Q)$(CP) $(INSTALLFW) $(DESTDIR)$(PREFIX)$(INSTALLFWRELPATH)

uninstall: all
$(info [@] Uninstalling recovery from $(PREFIX))
@true
uninstall:
$(info [@] Uninstalling recovery from $(DESTDIR)$(PREFIX)...)
$(Q)$(RM) $(foreach fw,$(INSTALLFW),$(DESTDIR)$(PREFIX)$(INSTALLFWRELPATH)$(notdir $(fw)))

PHONY: all clean install uninstall
.PHONY: all clean install uninstall
1 change: 1 addition & 0 deletions tools/mfkey/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ MYCFLAGS = -std=c99 -D_ISOC99_SOURCE
MYDEFS =

BINS = mfkey32 mfkey32v2 mfkey64
INSTALLTOOLS = $(BINS)

include ../../Makefile.host

Expand Down
1 change: 1 addition & 0 deletions tools/nonce2key/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ MYCFLAGS = -std=c99 -D_ISOC99_SOURCE
MYDEFS =

BINS = nonce2key
INSTALLTOOLS = $(BINS)

include ../../Makefile.host

Expand Down

0 comments on commit 4fdb5a2

Please sign in to comment.