forked from B-Lang-org/bsc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
platform.mk
81 lines (67 loc) · 2.05 KB
/
platform.mk
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
## This Makefile fragment can be included in Makefiles throughout this repo
## to ensure that the following variables have canonical values:
##
## MACHTYPE = x86_64, i386, i486, i586, i686
## OSTYPE = Linux, Darwin
##
## It can also add values for the following variables:
##
## CFLAGS
## CXXFLAGS
##
## It requires the following variables be set:
##
## TOP = the location of this Makefile at the top of the repo
## --------------------
## Setup MACHTYPE
MACHTYPE = $(shell $(TOP)/platform.sh machtype)
export MACHTYPE
ifneq ($(MACHTYPE), $(findstring $(MACHTYPE), x86_64 i386 i486 i586 i686 ppc64le aarch64 arm64 armv7l))
$(error MACHTYPE environment not recognized: $(MACHTYPE))
endif
## --------------------
## Setup OSTYPE
OSTYPE = $(shell $(TOP)/platform.sh ostype)
export OSTYPE
ifneq ($(OSTYPE), $(findstring $(OSTYPE), Linux Darwin Freebsd))
$(error OSTYPE environment not recognized: $(OSTYPE))
endif
## --------------------
## Setup common C/C++ flags
ifeq ($(MACHTYPE), $(findstring $(MACHTYPE), i386 i486 i586 i686))
# Set -m32 to be sure that CC is generating 32-bit
CFLAGS ?= -m32
CXXFLAGS ?= -m32
else
ifeq ($(MACHTYPE), $(findstring $(MACHTYPE), x86_64))
# Set -m64 to be sure that CC is generating 64-bit
CFLAGS ?= -m64
CXXFLAGS ?= -m64
else
ifeq ($(MACHTYPE), $(findstring $(MACHTYPE), ppc64le aarch64 arm64 armv7l))
else
$(error MACHTYPE environment not recognized: $(MACHTYPE))
endif
endif
endif
export CFLAGS
export CXXFLAGS
## --------------------
## Set up the TCL shell and include paths
ifneq ($(WANT_TCL),)
TCLSH = $(shell $(TOP)/platform.sh tclsh)
ifeq ($(TCLSH), )
$(error Unable to find tclsh)
endif
$(info Using tclsh: $(TCLSH))
TCL_INC_FLAGS = $(shell $(TOP)/platform.sh tclinc 2> /dev/null || echo fail)
ifeq ($(TCL_INC_FLAGS), fail)
$(error Unable to find tcl include directory)
endif
$(info Using tcl include flags: $(TCL_INC_FLAGS))
TCL_LIB_FLAGS = $(shell $(TOP)/platform.sh tcllibs 2> /dev/null || echo fail)
ifeq ($(TCL_LIB_FLAGS), fail)
$(error Unable to find tcl library flags)
endif
$(info Using tcl library flags: $(TCL_LIB_FLAGS))
endif