mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
Detect and use system Lua. Makefile. Cmake todo
This commit is contained in:
parent
d7cfaae17f
commit
aef6d7e5f2
2 changed files with 73 additions and 42 deletions
114
client/Makefile
114
client/Makefile
|
@ -36,74 +36,63 @@ endif
|
||||||
|
|
||||||
# local libraries
|
# local libraries
|
||||||
LUALIBPATH = ./deps/liblua
|
LUALIBPATH = ./deps/liblua
|
||||||
|
LUALIBINC = -I$(LUALIBPATH)
|
||||||
LUALIB = $(LUALIBPATH)/liblua.a
|
LUALIB = $(LUALIBPATH)/liblua.a
|
||||||
JANSSONLIBPATH = ./deps/jansson
|
JANSSONLIBPATH = ./deps/jansson
|
||||||
|
JANSSONLIBINC = -I$(JANSSONLIBPATH)
|
||||||
JANSSONLIB = $(JANSSONLIBPATH)/libjansson.a
|
JANSSONLIB = $(JANSSONLIBPATH)/libjansson.a
|
||||||
CBORLIBPATH = ./deps/tinycbor
|
CBORLIBPATH = ./deps/tinycbor
|
||||||
|
CBORLIBINC = -I$(CBORLIBPATH)
|
||||||
CBORLIB = $(CBORLIBPATH)/tinycbor.a
|
CBORLIB = $(CBORLIBPATH)/tinycbor.a
|
||||||
REVENGLIBPATH = ./deps/reveng
|
REVENGLIBPATH = ./deps/reveng
|
||||||
|
REVENGLIBINC = -I$(REVENGLIBPATH)
|
||||||
REVENGLIB = $(REVENGLIBPATH)/libreveng.a
|
REVENGLIB = $(REVENGLIBPATH)/libreveng.a
|
||||||
AMIIBOLIBPATH = ./deps/amiitool
|
AMIIBOLIBPATH = ./deps/amiitool
|
||||||
|
AMIIBOLIBINC = -I$(AMIIBOLIBPATH)
|
||||||
AMIIBOLIB = $(AMIIBOLIBPATH)/libamiibo.a
|
AMIIBOLIB = $(AMIIBOLIBPATH)/libamiibo.a
|
||||||
HARDNESTEDLIBPATH = ./deps/hardnested
|
HARDNESTEDLIBPATH = ./deps/hardnested
|
||||||
|
HARDNESTEDLIBINC = -I$(HARDNESTEDLIBPATH)
|
||||||
HARDNESTEDLIB = $(HARDNESTEDLIBPATH)/libhardnested.a
|
HARDNESTEDLIB = $(HARDNESTEDLIBPATH)/libhardnested.a
|
||||||
CLIPARSERLIBPATH = ./deps/cliparser
|
CLIPARSERLIBPATH = ./deps/cliparser
|
||||||
|
CLIPARSERLIBINC = -I$(CLIPARSERLIBPATH)
|
||||||
CLIPARSERLIB = $(CLIPARSERLIBPATH)/libcliparser.a
|
CLIPARSERLIB = $(CLIPARSERLIBPATH)/libcliparser.a
|
||||||
WAILIBPATH = ./deps/whereami
|
WAILIBPATH = ./deps/whereami
|
||||||
|
WAILIBINC = -I$(WAILIBPATH)
|
||||||
WAILIB = $(WAILIBPATH)/libwhereami.a
|
WAILIB = $(WAILIBPATH)/libwhereami.a
|
||||||
|
|
||||||
|
LUAPLATFORM = generic
|
||||||
|
ifneq (,$(findstring MINGW,$(platform)))
|
||||||
|
LUAPLATFORM = mingw
|
||||||
|
else
|
||||||
|
ifeq ($(platform),Darwin)
|
||||||
|
LUAPLATFORM = macosx
|
||||||
|
else
|
||||||
|
LUALIB += -ldl
|
||||||
|
LUAPLATFORM = linux
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
# common libraries
|
# common libraries
|
||||||
MBEDTLSLIBPATH = ../common/mbedtls
|
MBEDTLSLIBPATH = ../common/mbedtls
|
||||||
MBEDTLSLIB = $(OBJDIR)/libmbedtls.a
|
MBEDTLSLIB = $(OBJDIR)/libmbedtls.a
|
||||||
ZLIBPATH = ../common/zlib
|
ZLIBPATH = ../common/zlib
|
||||||
ZLIB = $(OBJDIR)/libz.a
|
ZLIB = $(OBJDIR)/libz.a
|
||||||
|
|
||||||
LIBS = -I$(LUALIBPATH) -I$(MBEDTLSLIBPATH) -I$(JANSSONLIBPATH) -I$(CBORLIBPATH) -I$(ZLIBPATH) -I$(REVENGLIBPATH) -I$(AMIIBOLIBPATH) -I$(HARDNESTEDLIBPATH) -I$(CLIPARSERLIBPATH) -I$(WAILIBPATH)
|
# system libraries
|
||||||
INCLUDES_CLIENT += -I./src -I../include -I../common -I../common_fpga $(LIBS)
|
ifneq ($(SKIPLUASYSTEM),1)
|
||||||
CFLAGS ?= $(DEFCFLAGS)
|
LUAINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags lua5.2 2>/dev/null)
|
||||||
|
LUALDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs lua5.2 2>/dev/null)
|
||||||
# We cannot just use CFLAGS+=... because it has impact on sub-makes if CFLAGS is defined in env:
|
ifneq ($(LUAINCLUDES),)
|
||||||
PM3CFLAGS = $(CFLAGS) $(INCLUDES_CLIENT)
|
LUALIB = $(LUALDLIBS)
|
||||||
# WIP Testing
|
LUALIBINC = $(LUAINCLUDES)
|
||||||
#PM3CFLAGS = $(CFLAGS) -std=c11 -pedantic $(INCLUDES_CLIENT)
|
LUASYSTEM = 1
|
||||||
PREFIX ?= /usr/local
|
endif
|
||||||
ifneq (,$(findstring MINGW,$(platform)))
|
|
||||||
# Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
|
|
||||||
# and setting _ISOC99_SOURCE sets internally __USE_MINGW_ANSI_STDIO=1
|
|
||||||
# FTR __USE_MINGW_ANSI_STDIO seems deprecated in Mingw32
|
|
||||||
# but not Mingw64 https://fr.osdn.net/projects/mingw/lists/archive/users/2019-January/000199.html
|
|
||||||
PM3CFLAGS += -D_ISOC99_SOURCE
|
|
||||||
PM3CFLAGS += -mno-ms-bitfields -fexec-charset=cp850
|
|
||||||
endif
|
|
||||||
CXXFLAGS ?= -Wall -Werror -O3
|
|
||||||
PM3CXXFLAGS = $(CXXFLAGS) -I../include
|
|
||||||
|
|
||||||
LUAPLATFORM = generic
|
|
||||||
ifneq (,$(findstring MINGW,$(platform)))
|
|
||||||
LUAPLATFORM = mingw
|
|
||||||
else
|
|
||||||
ifeq ($(platform),Darwin)
|
|
||||||
LUAPLATFORM = macosx
|
|
||||||
OBJCSRCS = util_darwin.m
|
|
||||||
LDFLAGS += -framework Foundation -framework AppKit
|
|
||||||
LDLIBS := -L/usr/local/opt/readline/lib $(LDLIBS)
|
|
||||||
LIBS := -I/usr/local/opt/readline/include $(LIBS)
|
|
||||||
# cf brew info qt: qt not symlinked anymore
|
|
||||||
PKG_CONFIG_ENV := PKG_CONFIG_PATH=/usr/local/opt/qt/lib/pkgconfig
|
|
||||||
else
|
|
||||||
LUALIB += -ldl
|
|
||||||
LUAPLATFORM = linux
|
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq ($(SKIPBT),1)
|
ifneq ($(SKIPBT),1)
|
||||||
BTLDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs bluez 2>/dev/null)
|
BTLDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs bluez 2>/dev/null)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq ($(BTLDLIBS),)
|
|
||||||
PM3CFLAGS += -DHAVE_BLUEZ
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq ($(SKIPQT),1)
|
ifneq ($(SKIPQT),1)
|
||||||
# Check for correctly configured Qt5
|
# Check for correctly configured Qt5
|
||||||
QTINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags Qt5Core Qt5Widgets 2>/dev/null)
|
QTINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags Qt5Core Qt5Widgets 2>/dev/null)
|
||||||
|
@ -118,7 +107,7 @@ ifneq ($(SKIPQT),1)
|
||||||
UIC = $(shell $(PKG_CONFIG_ENV) pkg-config --variable=uic_location QtCore)
|
UIC = $(shell $(PKG_CONFIG_ENV) pkg-config --variable=uic_location QtCore)
|
||||||
else
|
else
|
||||||
# On OSX Qt5 is claiming for a C++11 compiler (gnu++14 works too, but if nothing it fails)
|
# On OSX Qt5 is claiming for a C++11 compiler (gnu++14 works too, but if nothing it fails)
|
||||||
PM3CXXFLAGS += -fPIC -std=c++11
|
QT5FOUND = 1
|
||||||
endif
|
endif
|
||||||
ifeq ($(QTINCLUDES), )
|
ifeq ($(QTINCLUDES), )
|
||||||
# if both pkg-config commands failed, search in common places
|
# if both pkg-config commands failed, search in common places
|
||||||
|
@ -128,7 +117,7 @@ ifneq ($(SKIPQT),1)
|
||||||
ifneq ($(wildcard $(QTDIR)/include/QtWidgets),)
|
ifneq ($(wildcard $(QTDIR)/include/QtWidgets),)
|
||||||
QTINCLUDES += -I$(QTDIR)/include/QtWidgets
|
QTINCLUDES += -I$(QTDIR)/include/QtWidgets
|
||||||
QTLDLIBS = -L$(QTDIR)/lib -lQt5Widgets -lQt5Gui -lQt5Core
|
QTLDLIBS = -L$(QTDIR)/lib -lQt5Widgets -lQt5Gui -lQt5Core
|
||||||
PM3CXXFLAGS += -fPIC -std=c++11
|
QT5FOUND = 1
|
||||||
endif
|
endif
|
||||||
MOC = $(QTDIR)/bin/moc
|
MOC = $(QTDIR)/bin/moc
|
||||||
UIC = $(QTDIR)/bin/uic
|
UIC = $(QTDIR)/bin/uic
|
||||||
|
@ -136,11 +125,47 @@ ifneq ($(SKIPQT),1)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
LIBS = $(LUALIBINC) $(MBEDTLSLIBINC) $(JANSSONLIBINC) $(CBORLIBINC) $(ZLIBINC) $(REVENGLIBINC) $(AMIIBOLIBINC) $(HARDNESTEDLIBINC) $(CLIPARSERLIBINC) $(WAILIBINC)
|
||||||
|
INCLUDES_CLIENT += -I./src -I../include -I../common -I../common_fpga $(LIBS)
|
||||||
|
CFLAGS ?= $(DEFCFLAGS)
|
||||||
|
|
||||||
|
# We cannot just use CFLAGS+=... because it has impact on sub-makes if CFLAGS is defined in env:
|
||||||
|
PM3CFLAGS = $(CFLAGS) $(INCLUDES_CLIENT)
|
||||||
|
# WIP Testing
|
||||||
|
#PM3CFLAGS = $(CFLAGS) -std=c11 -pedantic $(INCLUDES_CLIENT)
|
||||||
|
PREFIX ?= /usr/local
|
||||||
|
ifneq (,$(findstring MINGW,$(platform)))
|
||||||
|
# Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
|
||||||
|
# and setting _ISOC99_SOURCE sets internally __USE_MINGW_ANSI_STDIO=1
|
||||||
|
# FTR __USE_MINGW_ANSI_STDIO seems deprecated in Mingw32
|
||||||
|
# but not Mingw64 https://fr.osdn.net/projects/mingw/lists/archive/users/2019-January/000199.html
|
||||||
|
PM3CFLAGS += -D_ISOC99_SOURCE
|
||||||
|
PM3CFLAGS += -mno-ms-bitfields -fexec-charset=cp850
|
||||||
|
endif
|
||||||
|
ifeq ($(platform),Darwin)
|
||||||
|
OBJCSRCS = util_darwin.m
|
||||||
|
LDFLAGS += -framework Foundation -framework AppKit
|
||||||
|
LDLIBS := -L/usr/local/opt/readline/lib $(LDLIBS)
|
||||||
|
LIBS := -I/usr/local/opt/readline/include $(LIBS)
|
||||||
|
# cf brew info qt: qt not symlinked anymore
|
||||||
|
PKG_CONFIG_ENV := PKG_CONFIG_PATH=/usr/local/opt/qt/lib/pkgconfig
|
||||||
|
endif
|
||||||
|
|
||||||
|
CXXFLAGS ?= -Wall -Werror -O3
|
||||||
|
PM3CXXFLAGS = $(CXXFLAGS) -I../include
|
||||||
|
|
||||||
|
ifneq ($(BTLDLIBS),)
|
||||||
|
PM3CFLAGS += -DHAVE_BLUEZ
|
||||||
|
endif
|
||||||
|
|
||||||
ifneq ($(QTLDLIBS),)
|
ifneq ($(QTLDLIBS),)
|
||||||
QTGUISRCS = proxgui.cpp proxguiqt.cpp proxguiqt.moc.cpp
|
QTGUISRCS = proxgui.cpp proxguiqt.cpp proxguiqt.moc.cpp
|
||||||
QTGUIOBJS = $(OBJDIR)/proxgui.o $(OBJDIR)/proxguiqt.o $(OBJDIR)/proxguiqt.moc.o
|
QTGUIOBJS = $(OBJDIR)/proxgui.o $(OBJDIR)/proxguiqt.o $(OBJDIR)/proxguiqt.moc.o
|
||||||
PM3CFLAGS += -DHAVE_GUI
|
PM3CFLAGS += -DHAVE_GUI
|
||||||
PM3CXXFLAGS += -DQT_NO_DEBUG
|
PM3CXXFLAGS += -DQT_NO_DEBUG
|
||||||
|
ifeq ($(QT5FOUND),1)
|
||||||
|
PM3CXXFLAGS += -fPIC -std=c++11
|
||||||
|
endif
|
||||||
else
|
else
|
||||||
QTGUISRCS = guidummy.cpp
|
QTGUISRCS = guidummy.cpp
|
||||||
QTGUIOBJS = $(OBJDIR)/guidummy.o
|
QTGUIOBJS = $(OBJDIR)/guidummy.o
|
||||||
|
@ -162,6 +187,9 @@ $(info native BT support: Bluez found, enabled)
|
||||||
else
|
else
|
||||||
$(info native BT support: Bluez not found, disabled)
|
$(info native BT support: Bluez not found, disabled)
|
||||||
endif
|
endif
|
||||||
|
ifeq ($(LUASYSTEM),1)
|
||||||
|
$(info system LUA: Lua5.2 found)
|
||||||
|
endif
|
||||||
$(info compiler version: $(shell $(CC) --version|head -n 1))
|
$(info compiler version: $(shell $(CC) --version|head -n 1))
|
||||||
$(info ===================================================================)
|
$(info ===================================================================)
|
||||||
|
|
||||||
|
@ -385,8 +413,10 @@ tarbin: $(BINS)
|
||||||
|
|
||||||
# local libraries:
|
# local libraries:
|
||||||
liblua:
|
liblua:
|
||||||
|
ifneq ($(LUASYSTEM),1)
|
||||||
$(info [*] MAKE $@ for $(LUAPLATFORM))
|
$(info [*] MAKE $@ for $(LUAPLATFORM))
|
||||||
$(Q)$(MAKE) --no-print-directory -C $(LUALIBPATH) $(LUAPLATFORM)
|
$(Q)$(MAKE) --no-print-directory -C $(LUALIBPATH) $(LUAPLATFORM)
|
||||||
|
endif
|
||||||
|
|
||||||
jansson:
|
jansson:
|
||||||
$(info [*] MAKE $@)
|
$(info [*] MAKE $@)
|
||||||
|
|
|
@ -61,6 +61,7 @@ It's also possible to skip parts even if libraries are present in the compilatio
|
||||||
|
|
||||||
* `make client SKIPQT=1` to skip GUI even if Qt is present
|
* `make client SKIPQT=1` to skip GUI even if Qt is present
|
||||||
* `make client SKIPBT=1` to skip native Bluetooth support even if libbluetooth is present
|
* `make client SKIPBT=1` to skip native Bluetooth support even if libbluetooth is present
|
||||||
|
* `make client SKIPLUASYSTEM=1` to skip system Lua lib even if liblua5.2 is present, use embedded Lua lib instead
|
||||||
|
|
||||||
If you're cross-compiling, these ones might be useful:
|
If you're cross-compiling, these ones might be useful:
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue