forked from gridpoint-com/scenic_driver_local
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
197 lines (160 loc) · 5.25 KB
/
Makefile
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# Variables to override
#
# CC C compiler
# CROSSCOMPILE crosscompiler prefix, if any
# CFLAGS compiler flags for compiling all C files
# ERL_CFLAGS additional compiler flags for files using Erlang header files
# ERL_EI_INCLUDE_DIR include path to ei.h (Required for crosscompile)
# ERL_EI_LIBDIR path to libei.a (Required for crosscompile)
# LDFLAGS linker flags for linking all binaries
# ERL_LDFLAGS additional linker flags for projects referencing Erlang libraries
MIX = mix
PREFIX = $(MIX_APP_PATH)/priv
DEFAULT_TARGETS ?= $(PREFIX) $(PREFIX)/scenic_driver_local
# # Look for the EI library and header files
# # For crosscompiled builds, ERL_EI_INCLUDE_DIR and ERL_EI_LIBDIR must be
# # passed into the Makefile.
# ifeq ($(ERL_EI_INCLUDE_DIR),)
# ERL_ROOT_DIR = $(shell erl -eval "io:format(\"~s~n\", [code:root_dir()])" -s init stop -noshell)
# ifeq ($(ERL_ROOT_DIR),)
# $(error Could not find the Erlang installation. Check to see that 'erl' is in your PATH)
# endif
# ERL_EI_INCLUDE_DIR = "$(ERL_ROOT_DIR)/usr/include"
# ERL_EI_LIBDIR = "$(ERL_ROOT_DIR)/usr/lib"
# endif
# # Set Erlang-specific compile and linker flags
# ERL_CFLAGS ?= -I$(ERL_EI_INCLUDE_DIR)
# ERL_LDFLAGS ?= -L$(ERL_EI_LIBDIR) -lei
$(info SCENIC_LOCAL_TARGET: $(SCENIC_LOCAL_TARGET))
ifdef SCENIC_LOCAL_GL
$(info SCENIC_LOCAL_GL: $(SCENIC_LOCAL_GL))
endif
DEVICE_SRCS =
FONT_SRCS = \
c_src/font/font.c
IMAGE_SRCS = \
c_src/image/image.c
TOMMYDS_SRCS = \
c_src/tommyds/src/tommyhashlin.c \
c_src/tommyds/src/tommyhash.c
SCENIC_SRCS = \
c_src/scenic/comms.c \
c_src/scenic/ops/scenic_ops.c \
c_src/scenic/ops/script_ops.c \
c_src/scenic/script.c \
c_src/scenic/unix_comms.c \
c_src/scenic/utils.c
ifeq ($(SCENIC_LOCAL_TARGET),glfw)
CFLAGS = -O3 -std=c99
ifndef MIX_ENV
MIX_ENV = dev
endif
ifdef DEBUG
CFLAGS += -pedantic -Weverything -Wall -Wextra -Wno-unused-parameter -Wno-gnu
endif
ifeq ($(MIX_ENV),dev)
CFLAGS += -g
endif
LDFLAGS += `pkg-config --static --libs glfw3 glew`
CFLAGS += `pkg-config --static --cflags glfw3 glew`
ifneq ($(OS),Windows_NT)
CFLAGS += -fPIC
ifeq ($(shell uname),Darwin)
LDFLAGS += -framework Cocoa -framework OpenGL -Wno-deprecated
else
LDFLAGS += -lGL -lm -lrt
endif
endif
DEVICE_SRCS += \
c_src/device/glfw.c \
c_src/device/gl_helpers.c \
c_src/nanovg/nanovg.c
FONT_SRCS += c_src/font/nvg_font_ops.c
IMAGE_SRCS += c_src/image/nvg_image_ops.c
SCENIC_SRCS += c_src/scenic/ops/nvg_script_ops.c
else ifeq ($(SCENIC_LOCAL_TARGET),bcm)
LDFLAGS += -lGLESv2 -lEGL -lm -lvchostif -lbcm_host
CFLAGS ?= -O2 -Wall -Wextra -Wno-unused-parameter -pedantic
CFLAGS += -std=gnu99
DEVICE_SRCS += \
c_src/device/bcm.c \
c_src/device/gl_helpers.c \
c_src/nanovg/nanovg.c
FONT_SRCS += c_src/font/nvg_font_ops.c
IMAGE_SRCS += c_src/image/nvg_image_ops.c
SCENIC_SRCS += c_src/scenic/ops/nvg_script_ops.c
else ifeq ($(SCENIC_LOCAL_TARGET),drm)
# drm is the forward looking default
LDFLAGS += -lGLESv2 -lEGL -lm -lvchostif -ldrm -lgbm
CFLAGS ?= -O2 -Wall -Wextra -Wno-unused-parameter -pedantic
CFLAGS += -std=gnu99
CFLAGS += -fPIC -I$(NERVES_SDK_SYSROOT)/usr/include/drm
DEVICE_SRCS += \
c_src/device/drm.c \
c_src/device/gl_helpers.c \
c_src/nanovg/nanovg.c
FONT_SRCS += c_src/font/nvg_font_ops.c
IMAGE_SRCS += c_src/image/nvg_image_ops.c
SCENIC_SRCS += c_src/scenic/ops/nvg_script_ops.c
ifeq ($(SCENIC_LOCAL_GL),gles2)
CFLAGS += -DSCENIC_GLES2
else
CFLAGS += -DSCENIC_GLES3
endif
else ifeq ($(SCENIC_LOCAL_TARGET),cairo)
LDFLAGS += `pkg-config --static --libs freetype2 cairo`
CFLAGS += `pkg-config --static --cflags freetype2 cairo`
LDFLAGS += -lm
CFLAGS ?= -O2 -Wall -Wextra -Wno-unused-parameter -pedantic
CFLAGS += -std=gnu99
DEVICE_SRCS += c_src/device/cairo.c
FONT_SRCS += c_src/font/cairo_font_ops.c
IMAGE_SRCS += c_src/image/cairo_image_ops.c
SCENIC_SRCS += c_src/scenic/ops/cairo_script_ops.c
else
$(info ------ no SCENIC_LOCAL_TARGET set ------)
$(info If you get here, then you are probably using a custom Nerves system)
$(info Please export/set SCENIC_LOCAL_TARGET to one of [glfw, bcm, drm])
$(info If you are running on a desktop machine, pick: glfw)
$(info For any varient of rpi <= 3, pick: bcm)
$(info For any varient of rpi >= 4, pick: drm)
$(info For any varient of bbb, pick: drm)
$(info example for a custom rpi3 build system:)
$(info export SCENIC_LOCAL_TARGET=bcm)
$(info For bbb, you also need to set SCENIC_LOCAL_GL=gles2)
$(info For >= rpi4, you also need to set SCENIC_LOCAL_GL=gles3)
$(info ----------------------------------------)
endif
# ifeq ($(SCENIC_LOCAL_TARGET),drm_gles3)
# LDFLAGS += -lGLESv2 -lEGL -lm -lvchostif -ldrm -lgbm
# CFLAGS ?= -O2 -Wall -Wextra -Wno-unused-parameter -pedantic
# CFLAGS += -std=gnu99
# CFLAGS += -fPIC -I$(NERVES_SDK_SYSROOT)/usr/include/drm
# SRCS = c_src/device/drm_gles3.c
# endif
# $(info $(shell printenv))
CFLAGS += \
-Ic_src \
-Ic_src/device \
-Ic_src/font \
-Ic_src/image \
-Ic_src/nanovg \
-Ic_src/scenic \
-Ic_src/tommyds/src
SRCS = \
$(DEVICE_SRCS) \
$(FONT_SRCS) \
$(IMAGE_SRCS) \
$(TOMMYDS_SRCS) \
$(SCENIC_SRCS) \
c_src/main.c
calling_from_make:
mix compile
all: $(DEFAULT_TARGETS)
$(PREFIX):
mkdir -p $@
$(PREFIX)/scenic_driver_local: $(SRCS)
$(CC) $(CFLAGS) -o $@ $(SRCS) $(LDFLAGS)
clean:
$(RM) -rf $(PREFIX)
.PHONY: all clean calling_from_make