forked from lorabasics/basicstation
-
Notifications
You must be signed in to change notification settings - Fork 30
/
setup.gmk
176 lines (146 loc) · 6.4 KB
/
setup.gmk
1
2
3
4
5
6
7
8
9
10
11
12
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# --- Revised 3-Clause BSD License ---
# Copyright Semtech Corporation 2020. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the Semtech corporation nor the names of its
# software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION. BE LIABLE FOR ANY DIRECT,
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -*- makefile -*-
# Top dir of s2core
# - override accordingly in makefile including this setup.gmk
ifndef TD
$(error Need variable TD=../.... - must point to dir holding this setup.gmk)
endif
Q = $(if ${V},,@)
NQ = $(if ${V},>/dev/null,)
platform ?= linux
variant ?= std
arch ?= default
-include ${TD}/setup-${platform}.gmk
LOCAL_ARCH := $(shell gcc -dumpmachine)
ARCH.linux.default = x86_64-linux-gnu
ARCH.linuxV2.default = x86_64-linux-gnu
ARCH.linuxpico.default = x86_64-linux-gnu
ARCH.corecell.default = arm-linux-gnueabihf
ARCH.corecell.rpi = arm-linux-gnueabihf
ARCH.corecell.armv7hf = arm-linux-gnueabihf
ARCH.corecell.aarch64 = aarch64-linux-gnu
ARCH.rpi.default = arm-linux-gnueabihf
ARCH.rpi.rpi = arm-linux-gnueabihf
ARCH.rpi.armv7hf = arm-linux-gnueabihf
ARCH.rpi.aarch64 = aarch64-linux-gnu
ARCH.kerlink.default = arm-klk-linux-gnueabi
ARCH=${ARCH.${platform}.${arch}}
export TDfull := $(shell cd ${TD} && pwd)
TOOLCHAIN=${HOME}/toolchain-${platform}
ifeq (,$(wildcard ${TOOLCHAIN}))
# No toolchain for cross compile - only ok if we can build locally
ifeq (${LOCAL_ARCH},${ARCH})
TOOLPREFIX=
else
$(warning No toolchain for platform '${platform}' and local arch is not '${ARCH}')
TOOLPREFIX=NO-TOOLCHAIN-FOUND-
endif
else
# Found a matching cross compile toolchain
TOOLPREFIX=${TOOLCHAIN}/bin/${ARCH}-
endif
CC=${TOOLPREFIX}gcc
LD=${TOOLPREFIX}ld
AR=${TOOLPREFIX}ar
OD=${TOOLPREFIX}objdump
OC=${TOOLPREFIX}objcopy
ifeq (kerlink,${platform})
# Needed for loader to find libmpfr.so.4
export LD_LIBRARY_PATH=${TOOLCHAIN}/usr/lib
endif
# Everything being build is somewhere in here
BD=build-${platform}-${variant}
# -- Architecture specific
CFG.arm-linux-gnueabihf = linux
# CFG.x86_64-linux-gnu = linux
# -- Variant specific
# testsim runs libloragw inside master process
# testms uses a master slave model
CFG.testsim = logini_lvl=DEBUG selftests tlsdebug lgwsim ral_lgw
CFG.testms = logini_lvl=DEBUG selftests tlsdebug lgwsim ral_master_slave
CFG.testfs = logini_lvl=DEBUG selftests tlsdebug lgwsim ral_lgw
CFG.testpin = logini_lvl=INFO tlsdebug ral_lgw testpin
CFG.std = logini_lvl=INFO tlsdebug ral_lgw
CFG.stdn = logini_lvl=INFO tlsdebug ral_master_slave
CFG.debug = logini_lvl=DEBUG selftests tlsdebug ral_lgw
CFG.debugn = logini_lvl=DEBUG selftests tlsdebug ral_master_slave
# -- Platform specific
CFG.linux = linux lgw1 no_leds
CFG.linuxpico = linux lgw1 no_leds smtcpico
CFG.linuxV2 = linux lgw2 no_leds lgw2genkey
CFG.corecell = linux lgw1 no_leds sx1302
CFG.rpi = linux lgw1 no_leds
CFG.kerlink = linux lgw1 no_leds
SD.default = src-linux
SD = $(or ${SD.${platform}}, ${SD.default})
UTILS.linux = mtuns
UTILS = $(or ${UTILS.${platform}}, ${UTILS.default})
DEPS.default = mbedtls lgw
DEPS.linuxpico = mbedtls smtcpico
DEPS.linuxV2 = mbedtls lgw2
DEPS.corecell = mbedtls lgw1302
DEPS.rpi = mbedtls lgw
DEPS = $(or ${DEPS.${platform}}, ${DEPS.default})
PERSO.default =
PERSO = $(or ${PERSO.${platform}}, ${PERSO.default})
PERSOH = $(if ${PERSO},perso.h,)
# Paths to dependencies
MBEDLIBS = -lmbedtls -lmbedx509 -lmbedcrypto
# -lm: Needed for lgw which uses pow/ceil
ifneq (minihub,$(platform))
SYSLIBS = -lm
endif
CFLAGS.linuxpico.debug = -g -O0
CFLAGS.corecell.debug = -g -O0
CFLAGS.linuxpico.debugn = -g -O0
CFLAGS.linux.testsim = -g -O0 --coverage
CFLAGS.linux.testms = -g -O0 --coverage
CFLAGS.linux.testfs = -g -O0 --coverage
CFLAGS.linux.testpin = -g -O3
CFLAGS.linux.std = -g -O3
LIBS.linux = -llgw ${MBEDLIBS} -lpthread
LIBS.linuxV2 = -llgw2 ${MBEDLIBS} -lrt -lpthread -lspi
LIBS.linuxpico = -llgw ${MBEDLIBS} -lpthread
LIBS.corecell = -llgw1302 ${MBEDLIBS} -lpthread -lrt
LIBS.rpi = -llgw ${MBEDLIBS} -lpthread
LIBS.kerlink = -llgw ${MBEDLIBS} -lrt -lpthread
xCFG = ${CFG.${ARCH}} ${CFG.${platform}} ${CFG.${variant}} ${CFG.${platform}.${variant}}
xCFLAGS = ${CFLAGS.${ARCH}} ${CFLAGS.${platform}} ${CFLAGS.${variant}} ${CFLAGS.${platform}.${variant}}
xINCS = ${INCS.${ARCH}} ${INCS.${platform}} ${INCS.${variant}}
xLDFLAGS = ${LDFLAGS.${ARCH}} ${LDFLAGS.${platform}} ${LDFLAGS.${variant}}
xLIBS = ${LIBS.${ARCH}} ${LIBS.${platform}} ${LIBS.${variant}}
xFILES = ${FILES.${ARCH}} ${FILES.${platform}} ${FILES.${variant}}
xOCFLAGS = ${OCFLAGS.${ARCH}} ${OCFLAGS.${platform}} ${OCFLAGS.${variant}}
DEFS = -DCFG_platform_${platform} -DCFG_platform=\"${platform}\" -DCFG_variant_${variant} -DCFG_variant=\"${variant}\"
DEFS += -DCFG_bdate='"$(shell date -u '+%Y-%m-%d %H:%M:%S')"'
DEFS += -DCFG_version='"$(shell if [ -f ${TD}/VERSION.txt ]; then cat ${TD}/VERSION.txt; else git describe --tag; fi)(${platform}/${variant})"'
DEFS += -DCFG_commit='"$(shell if git rev-parse --git-dir >/dev/null 2>&1; then git rev-parse --short HEAD; else echo -; fi)"'
DEFS += ${xCFG:%=-DCFG_%}
INCS = ${VPATH:%=-I%} -I ${TD}/${BD}/include ${xINCS}
CFLAGS = -Wall -std=gnu11 ${INCS} ${DEFS} ${xCFLAGS}
LDFLAGS = -L ${TD}/${BD}/lib ${xLDFLAGS}
LIBS = ${xLIBS} ${SYSLIBS}
FILES = ${xFILES}
OCFLAGS = ${xOCFLAGS}