config.mk 3.7 KB
Newer Older
Jaromil's avatar
Jaromil committed
1
2
3
4
5
6
7
8
9
10
11
# included by makefile

pwd := $(shell pwd)
mil := ${pwd}/build/milagro
extras := ${pwd}/docs/demo

# --------
# defaults
gcc := gcc
ar := ar
ranlib := ranlib
12
ld := ld
Jaromil's avatar
Jaromil committed
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
cflags_protection := -fstack-protector-all -D_FORTIFY_SOURCE=2 -fno-strict-overflow
cflags := -O2 ${cflags_protection}
musl := ${pwd}/build/musl
platform := posix

# ------------
# lua settings
luasrc := ${pwd}/lib/lua53/src
ldadd := ${pwd}/lib/lua53/src/liblua.a
ldadd += ${pwd}/lib/lpeglabel/lpeglabel.a

# ----------------
# milagro settings
rsa_bits := ""
ecc_curves := ED25519,BLS383,GOLDILOCKS,SECP256K1
milagro_cmake_flags := -DBUILD_SHARED_LIBS=OFF -DBUILD_PYTHON=OFF -DBUILD_DOXYGEN=OFF -DWORD_SIZE=32 -DAMCL_CURVE=${ecc_curves} -DAMCL_RSA=${rsa_bits} -DCMAKE_SHARED_LIBRARY_LINK_FLAGS="" -DC99=1 -DPAIRING_FRIENDLY_BLS383='BLS'
milib := ${pwd}/lib/milagro-crypto-c/lib
ldadd += ${milib}/libamcl_curve_ED25519.a
ldadd += ${milib}/libamcl_curve_BLS383.a
ldadd += ${milib}/libamcl_pairing_BLS383.a
ldadd += ${milib}/libamcl_curve_GOLDILOCKS.a
ldadd += ${milib}/libamcl_curve_SECP256K1.a
ldadd += ${milib}/libamcl_core.a

# ------------------------
# target specific settings

ifneq (,$(findstring win,$(MAKECMDGOALS)))
gcc := x86_64-w64-mingw32-gcc
ar  := x86_64-w64-mingw32-ar
ranlib := x86_64-w64-mingw32-ranlib
44
45
ld := x86_64-w64-mingw32-ld
system := Windows
Jaromil's avatar
Jaromil committed
46
47
48
49
50
51
52
53
54
55
cflags := ${cflags_protection} -D'ARCH=\"WIN\"' -DARCH_WIN -O3 -Wall -Wextra -pedantic -std=gnu99
ldflags := -L/usr/x86_64-w64-mingw32/lib
ldadd += ${ldadd} -l:libm.a -l:libpthread.a -lssp
endif


ifneq (,$(findstring musl,$(MAKECMDGOALS)))
gcc := musl-gcc
cflags := -Os -static -Wall -std=gnu99 -fPIC ${cflags_protection} -D'ARCH=\"MUSL\"' -D__MUSL__ -DARCH_MUSL
ldflags := -static
56
system := Linux
Jaromil's avatar
Jaromil committed
57
58
59
60
61
endif

ifneq (,$(findstring linux,$(MAKECMDGOALS)))
cflags := ${cflags} -fPIC ${cflags_protection} -D'ARCH=\"LINUX\"' -DARCH_LINUX
ldflags := -lm -lpthread
62
system := Linux
Jaromil's avatar
Jaromil committed
63
64
65
66
67
endif

ifneq (,$(findstring osx,$(MAKECMDGOALS)))
cflags := ${cflags} -fPIC ${cflags_protection} -D'ARCH=\"OSX\"' -DARCH_OSX
ldflags := -lm
68
system := Darwin
Jaromil's avatar
Jaromil committed
69
70
endif

Jaromil's avatar
Jaromil committed
71
ifneq (,$(findstring javascript,$(MAKECMDGOALS)))
Jaromil's avatar
Jaromil committed
72
73
gcc := ${EMSCRIPTEN}/emcc
ar := ${EMSCRIPTEN}/emar
74
75
ld := ${gcc}
system:= Javascript
Jaromil's avatar
Jaromil committed
76
ldflags := -s "EXPORTED_FUNCTIONS='[\"_zenroom_exec\",\"_zenroom_exec_tobuf\",\"_zenroom_parse_ast\",\"_set_debug\"]'" -s "EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\",\"cwrap\"]'" -s USE_SDL=0 -s USE_PTHREADS=0 -lm
Jaromil's avatar
Jaromil committed
77
78
79
cflags := -O2 -Wall -I ${EMSCRIPTEN}/system/include/libc -DLIBRARY
endif

80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
ifneq (,$(findstring esp32,$(MAKECMDGOALS)))
gcc := ${pwd}/build/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc
ld  := ${pwd}/build/xtensa-esp32-elf/bin/xtensa-esp32-elf-ld
ar  := ${pwd}/build/xtensa-esp32-elf/bin/xtensa-esp32-elf-ar
ranlib := ${pwd}/build/xtensa-esp32-elf/bin/xtensa-esp32-elf-ranlib
system := Generic
# TODO: not working, cmake doesn't uses the specified linked (bug?)
milagro_cmake_flags := -DCMAKE_LINKER=${ld} -DCMAKE_C_LINK_EXECUTABLE="<CMAKE_LINKER> <FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>"
cflags := -I. -mlongcalls  #${cflags_protection} -D'ARCH=\"LINUX\"' -DARCH_LINUX
ldflags += -L${pwd}/build/xtensa-esp32-elf/lib -Teagle.app.v6.ld
ldadd += ${ldadd} -nostdlib -Wl,--start-group -lmain -lc -Wl,--end-group -lgcc
# ldadd += ${ldadd} -l:libm.a -l:libpthread.a -lssp
endif


Jaromil's avatar
Jaromil committed
95

Jaromil's avatar
Jaromil committed
96
97
98
99
100
101
102
103
104
# ifneq (,$(findstring ios,$(MAKECMDGOALS)))
# gcc := $(shell xcrun --sdk iphoneos -f gcc 2>/dev/null)
# ar := $(shell xcrun --sdk iphoneos -f ar 2>/dev/null)
# ld := $(shell xcrun --sdk iphoneos -f ld 2>/dev/null)
# ldflags := lm
# ranlib := $(shell xcrun --sdk iphoneos -f ranlib 2>/dev/null)
# SDK := $(shell xcrun --sdk iphoneos --show-sdk-path 2>/dev/null)
# cflags := -O2 -fPIC ${cflags_protection} -D'ARCH=\"OSX\"' -isysroot ${SDK} -arch ${ARCH} -D NO_SYSTEM -DARCH_OSX
# endif