diff --git a/Makefile b/Makefile index f74932ccc..d2d4ca643 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,5 @@ -# Hide full compilation line: -ifneq ($(V),1) - Q?=@ -endif -# To see full command lines, use make V=1 -CP = cp -a -GZIP=gzip -MKDIR = mkdir -p -RM = rm -f -RMDIR = rm -rf +include Makefile.defs -include Makefile.platform -include .Makefile.options.cache include common_arm/Makefile.hal diff --git a/Makefile.defs b/Makefile.defs new file mode 100644 index 000000000..d69b58b33 --- /dev/null +++ b/Makefile.defs @@ -0,0 +1,42 @@ +# Hide full compilation line: +ifneq ($(V),1) + Q?=@ +endif +# To see full command lines, use make V=1 + +# been here +DEFSBEENHERE = true + +CP = cp -a +GZIP = gzip +MKDIR = mkdir -p +RM = rm -f +RMDIR = rm -rf +MV = mv +TOUCH = touch +FALSE = false +TAR = tar +TARFLAGS ?= -v --ignore-failed-read -r +TARFLAGS += -C .. -f +CROSS ?= arm-none-eabi- +CC = gcc +CXX = g++ +LD = g++ + +PATHSEP=/ +PREFIX ?= /usr/local +INSTALLBINRELPATH = /bin/ +INSTALLSHARERELPATH = /share/proxmark3/ +INSTALLFWRELPATH = /share/proxmark3/firmware/ +INSTALLTOOLSRELPATH = /share/proxmark3/tools/ + +platform = $(shell uname) +DETECTED_OS=$(platform) + +ifeq ($(platform),Darwin) + AR= /usr/bin/ar rcs + RANLIB= /usr/bin/ranlib +else + AR= ar rcs + RANLIB= ranlib +endif diff --git a/Makefile.host b/Makefile.host index 861e697fb..8fb6fceed 100644 --- a/Makefile.host +++ b/Makefile.host @@ -1,36 +1,19 @@ -# Hide full compilation line: -ifneq ($(V),1) - Q?=@ +# This Makefile might have been called from various subdirs, trying to find our Makefile.defs +ifeq ($(DEFSBEENHERE),) + -include Makefile.defs +endif +ifeq ($(DEFSBEENHERE),) + -include ../Makefile.defs +endif +ifeq ($(DEFSBEENHERE),) + -include ../../Makefile.defs +endif +ifeq ($(DEFSBEENHERE),) + $(error Can't find Makefile.defs) endif -# To see full command lines, use make V=1 - -INSTALLBINRELPATH = /bin/ -INSTALLTOOLSRELPATH = /share/proxmark3/tools/ - -CC = gcc -LD = gcc -RM = rm -f -MV = mv -CP = cp -a -MKDIR = mkdir -p -TOUCH = touch -FALSE = false CFLAGS ?= -Wall -Werror -O3 CFLAGS += $(MYDEFS) $(MYCFLAGS) $(MYINCLUDES) -PREFIX ?= /usr/local - -platform = $(shell uname) - -ifeq ($(platform),Darwin) -AR= /usr/bin/ar rcs -RANLIB= /usr/bin/ranlib -else -AR= ar rcs -RANLIB= ranlib -endif -RM= rm -f -RMDIR= rm -rf vpath %.c $(MYSRCPATHS) diff --git a/client/Makefile b/client/Makefile index 5157e3e57..4c5d53c9c 100644 --- a/client/Makefile +++ b/client/Makefile @@ -9,34 +9,14 @@ # Add -DNOFORCE to disable the -F switch # Add -DPRESETS to compile with preset models (edit config.h) -# Hide full compilation line: -ifneq ($(V),1) - Q?=@ -endif -# To see full command lines, use make V=1 +# Must be called before any Makefile include +ROOT_DIR:=$(dir $(realpath $(lastword $(MAKEFILE_LIST)))) + +include ../Makefile.defs -INSTALLBINRELPATH = /bin/ -INSTALLSHARERELPATH = /share/proxmark3/ INSTALLBIN = proxmark3 proxmark3-flasher INSTALLSHARE = lualibs luascripts resources dictionaries -CC = gcc -CXX = g++ -LD = g++ -TAR = tar -TARFLAGS ?= -v --ignore-failed-read -r -TARFLAGS += -C .. -f -RM = rm -f -RMDIR= rm -rf -MKDIR = mkdir -p -MV = mv -TOUCH = touch -FALSE = false -CP=cp -a - -platform = $(shell uname) -ROOT_DIR:=$(dir $(realpath $(lastword $(MAKEFILE_LIST)))) - VPATH = ../common uart vpath %.dic dictionaries OBJDIR = obj diff --git a/common_arm/Makefile.common b/common_arm/Makefile.common index 5af77bcf7..52ec2ebd2 100644 --- a/common_arm/Makefile.common +++ b/common_arm/Makefile.common @@ -6,48 +6,34 @@ # Common makefile functions for all platforms #----------------------------------------------------------------------------- -# 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 -# - -ifneq ($(V),1) - Q?=@ -endif -# To see full command lines, use make V=1 - # Make sure that all is the default target # (The including Makefile still needs to define what 'all' is) all: -platform = $(shell uname) -PREFIX?=/usr/local -INSTALLFWRELPATH = /share/proxmark3/firmware/ +# This Makefile might have been called from various subdirs, trying to find our Makefile.defs +ifeq ($(DEFSBEENHERE),) + -include Makefile.defs +endif +ifeq ($(DEFSBEENHERE),) + -include ../Makefile.defs +endif +ifeq ($(DEFSBEENHERE),) + -include ../../Makefile.defs +endif +ifeq ($(DEFSBEENHERE),) + $(error Can't find Makefile.defs) +endif -CROSS ?= arm-none-eabi- CC = $(CROSS)gcc AS = $(CROSS)as LD = $(CROSS)ld OBJCOPY = $(CROSS)objcopy -GZIP=gzip -MV=mv OBJDIR = obj INCLUDE = -I../include -I../common_arm -I../common_fpga -I../common -I. -TAR=tar -TARFLAGS = -C .. -rvf -RM=rm -f -RMDIR=rm -rf -CP=cp -a -MKDIR=mkdir -p -PATHSEP=/ -DETECTED_OS=$(platform) - # Also search prerequisites in the common directory (for usb.c), the fpga directory (for fpga.bit), and the zlib directory VPATH = . ../common_arm ../common ../common/crapto1 ../common/mbedtls ../common/zlib ../fpga ../armsrc/Standalone