Merge pull request #1335 from rad1game/patch-1
[RRG-proxmark3.git] / common_arm / Makefile.hal
blobcda6ac1b9856167ad5c6abba8432d92abd9082df
1 # Default platform if no platform specified
2 PLATFORM?=PM3RDV4
4 # Standalone Mode info (path depends if make is called at top or from armsrc)
5 # Guard Makefile.hal against implicit rules: (with % to avoid being first goal)
6 %/Makefile.hal: ;
7 -include armsrc/Standalone/Makefile.hal
8 -include Standalone/Makefile.hal
9 ifndef DEFAULT_STANDALONE
10 $(error Could not find armsrc/Standalone/Makefile.hal)
11 endif
13 define KNOWN_PLATFORM_DEFINITIONS
15 Known definitions:
17 +============================================+
18 | PLATFORM        | DESCRIPTION              |
19 +============================================+
20 | PM3RDV4 (def)   | Proxmark3 RDV4           |
21 +--------------------------------------------+
22 | PM3GENERIC      | Proxmark3 generic target |
23 +--------------------------------------------+
25 +============================================+
26 | PLATFORM_EXTRAS | DESCRIPTION              |
27 +============================================+
28 | BTADDON         | Proxmark3 RDV4 BT add-on |
29 +--------------------------------------------+
31 endef
33 define HELP_DEFINITIONS
34 Options to define platform, platform extras and/or standalone mode:
35 (1) Run make with your PLATFORM, PLATFORM_EXTRAS and/or STANDALONE choices as follows:
36 make PLATFORM=PM3GENERIC STANDALONE=$(HELP_EXAMPLE_STANDALONE)
38 (2) Save a file called Makefile.platform with contents, e.g.:
39 PLATFORM=PM3GENERIC
41 or if you have a Proxmark 3 RDV4 with the BT add-on:
42 PLATFORM=PM3RDV4
43 PLATFORM_EXTRAS=BTADDON
45 Default standalone mode is $(DEFAULT_STANDALONE).
46 To disable standalone modes, set explicitly an empty STANDALONE:
47 STANDALONE=
49 For Proxmarks with only 256k, you can define
50 PLATFORM_SIZE=256
51 to be warned if the image is too big for your device
52 and you can specify which parts to skip in order to reduce the size:
53 SKIP_LF=1
54 SKIP_HITAG=1
55 SKIP_EM4x50=1
56 SKIP_ISO15693=1
57 SKIP_LEGICRF=1
58 SKIP_ISO14443b=1
59 SKIP_ISO14443a=1
60 SKIP_ICLASS=1
61 SKIP_FELICA=1
62 SKIP_NFCBARCODE=1
63 SKIP_HFSNIFF=1
64 SKIP_HFPLOT=1
65 endef
67 define KNOWN_DEFINITIONS
68 $(KNOWN_PLATFORM_DEFINITIONS)
69 $(KNOWN_STANDALONE_DEFINITIONS)
70 $(HELP_DEFINITIONS)
71 endef
73 PLTNAME = Unknown Platform
75 ifeq ($(PLATFORM),PM3RDV4)
76     PLATFORM_DEFS = -DWITH_SMARTCARD -DWITH_FLASH -DRDV4
77     PLTNAME = Proxmark3 RDV4
78 else ifeq ($(PLATFORM),PM3OTHER)
79     $(warning PLATFORM=PM3OTHER is deprecated, please use PLATFORM=PM3GENERIC)
80     PLTNAME = Proxmark3 generic target
81 else ifeq ($(PLATFORM),PM3GENERIC)
82     PLTNAME = Proxmark3 generic target
84 else
85     $(error Invalid or empty PLATFORM: $(PLATFORM). $(KNOWN_DEFINITIONS))
86 endif
88 # parsing additional PLATFORM_EXTRAS tokens
89 PLATFORM_EXTRAS_TMP:=$(PLATFORM_EXTRAS)
90 ifneq (,$(findstring BTADDON,$(PLATFORM_EXTRAS_TMP)))
91     PLATFORM_DEFS += -DWITH_FPC_USART_HOST
92     PLATFORM_EXTRAS_TMP := $(strip $(filter-out BTADDON,$(PLATFORM_EXTRAS_TMP)))
93 endif
94 ifneq (,$(findstring FPC_USART_DEV,$(PLATFORM_EXTRAS_TMP)))
95     PLATFORM_DEFS += -DWITH_FPC_USART_DEV
96     PLATFORM_EXTRAS_TMP := $(strip $(filter-out FPC_USART_DEV,$(PLATFORM_EXTRAS_TMP)))
97 endif
98 ifneq (,$(PLATFORM_EXTRAS_TMP))
99     $(error Unknown PLATFORM_EXTRAS token(s): $(PLATFORM_EXTRAS_TMP))
100 endif
102 # common LF support
103 ifneq ($(SKIP_LF),1)
104     PLATFORM_DEFS += -DWITH_LF
105 endif
106 ifneq ($(SKIP_HITAG),1)
107     PLATFORM_DEFS += -DWITH_HITAG
108 endif
109 ifneq ($(SKIP_EM4x50),1)
110     PLATFORM_DEFS += -DWITH_EM4x50
111 endif
112 ifneq ($(SKIP_EM4x70),1)
113     PLATFORM_DEFS += -DWITH_EM4x70
114 endif
116 # common HF support
117 ifneq ($(SKIP_ISO15693),1)
118     PLATFORM_DEFS += -DWITH_ISO15693
119 endif
120 ifneq ($(SKIP_LEGICRF),1)
121     PLATFORM_DEFS += -DWITH_LEGICRF
122 endif
123 ifneq ($(SKIP_ISO14443b),1)
124     PLATFORM_DEFS += -DWITH_ISO14443b
125 endif
126 ifneq ($(SKIP_ISO14443a),1)
127     PLATFORM_DEFS += -DWITH_ISO14443a
128 endif
129 ifneq ($(SKIP_ICLASS),1)
130     PLATFORM_DEFS += -DWITH_ICLASS
131 endif
132 ifneq ($(SKIP_FELICA),1)
133     PLATFORM_DEFS += -DWITH_FELICA
134 endif
135 ifneq ($(SKIP_NFCBARCODE),1)
136     PLATFORM_DEFS += -DWITH_NFCBARCODE
137 endif
138 ifneq ($(SKIP_HFSNIFF),1)
139     PLATFORM_DEFS += -DWITH_HFSNIFF
140 endif
141 ifneq ($(SKIP_HFPLOT),1)
142     PLATFORM_DEFS += -DWITH_HFPLOT
143 endif
144 ifeq ($(SKIP_COMPRESSION),1)
145     PLATFORM_DEFS += -DWITH_NO_COMPRESSION
146 endif
148 # Standalone mode
149 ifneq ($(strip $(filter $(PLATFORM_DEFS),$(STANDALONE_REQ_DEFS))),$(strip $(STANDALONE_REQ_DEFS)))
150     $(error Chosen Standalone mode $(STANDALONE) requires $(strip $(STANDALONE_REQ_DEFS)), unsupported by $(PLTNAME))
151 endif
152 ifneq (,$(STANDALONE_PLATFORM_DEFS))
153     PLATFORM_DEFS+=$(STANDALONE_PLATFORM_DEFS)
154 endif
156 $(info $(findstring WITH_STANDALONE_*,$(PLATFORM_DEFS)))
158 # Misc (LCD support)
159 ifneq (,$(findstring WITH_LCD,$(PLATFORM_DEFS)))
160     #PLATFORM_DEFS += -DWITH_LCD
161 endif
163 # Add flags dependencies :
165 # WITH_FPC_USART_* needs WITH_FPC_USART :
166 ifneq (,$(findstring WITH_FPC_USART_,$(PLATFORM_DEFS)))
167     PLATFORM_DEFS += -DWITH_FPC_USART
168 endif
170 PLATFORM_DEFS_INFO = $(strip $(filter-out STANDALONE%, $(subst -DWITH_,,$(PLATFORM_DEFS))))
171 PLATFORM_DEFS_INFO_STANDALONE = $(strip $(subst STANDALONE_,, $(filter STANDALONE%, $(subst -DWITH_,,$(PLATFORM_DEFS)))))
173 # Check that only one Standalone mode has been chosen
174 ifneq (,$(word 2, $(PLATFORM_DEFS_INFO_STANDALONE)))
175     $(error You must choose only one Standalone mode!: $(PLATFORM_DEFS_INFO_STANDALONE))
176 endif
178 PLATFORM_EXTRAS_INFO = $(PLATFORM_EXTRAS)
179 # info when no extra
180 ifeq (,$(PLATFORM_EXTRAS_INFO))
181     PLATFORM_EXTRAS_INFO = No extra selected
182 endif
184 # info when no standalone mode
185 ifeq (,$(PLATFORM_DEFS_INFO_STANDALONE))
186     PLATFORM_DEFS_INFO_STANDALONE = No standalone mode selected
187 endif
189 ifeq ($(PLATFORM_SIZE),)
190     PLATFORM_SIZE=512
191 endif
193 PLATFORM_CHANGED=false
194 ifneq ($(PLATFORM), $(CACHED_PLATFORM))
195     PLATFORM_CHANGED=true
196 else ifneq ($(PLATFORM_EXTRAS), $(CACHED_PLATFORM_EXTRAS))
197     PLATFORM_CHANGED=true
198 else ifneq ($(PLATFORM_DEFS), $(CACHED_PLATFORM_DEFS))
199     PLATFORM_CHANGED=true
200 endif
202 export PLATFORM
203 export PLATFORM_EXTRAS
204 export PLATFORM_EXTRAS_INFO
205 export PLATFORM_SIZE
206 export PLTNAME
207 export PLATFORM_DEFS
208 export PLATFORM_DEFS_INFO
209 export PLATFORM_DEFS_INFO_STANDALONE
210 export PLATFORM_CHANGED
212 $(info ===================================================================)
213 $(info Platform name:     $(PLTNAME))
214 $(info PLATFORM:          $(PLATFORM))
215 $(info PLATFORM_SIZE:     $(PLATFORM_SIZE))
216 $(info Platform extras:   $(PLATFORM_EXTRAS_INFO))
217 $(info Included options:  $(PLATFORM_DEFS_INFO))
218 $(info Standalone mode:   $(PLATFORM_DEFS_INFO_STANDALONE))
219 $(info ===================================================================)