@@ -58,9 +58,19 @@ H8300_LD ?= $(H8300_TOOLPREFIX)ld
58
58
H8300_AS ?= $(H8300_TOOLPREFIX ) as
59
59
H8300_OBJDUMP ?= $(H8300_TOOLPREFIX ) objdump
60
60
61
- H8300_FOUND := $(shell $(H8300_AS ) --version >/dev/null 2>&1 && echo found)
62
- ifneq ($(H8300_FOUND ) , found)
63
- $(warning h8300-hitachi-coff toolchain not found, using pre-built files)
61
+ H8300_FOUND := $(shell $(H8300_AS ) --version > /dev/null 2>&1 && echo found)
62
+ ifneq ($(H8300_FOUND ) ,found)
63
+ $(warning h8300-hitachi-coff binutils toolchain not found, using pre-built files)
64
+ endif
65
+
66
+ #
67
+ # Toolchain for Emscripten
68
+ #
69
+ EMSCRIPTEN_MAKE ?= emmake
70
+ # NOTE: "emmake --version" does not work as a test and returns a non-zero error code
71
+ EMSCRIPTEN_FOUND := $(shell which $(EMSCRIPTEN_MAKE ) > /dev/null 2>&1 && echo found)
72
+ ifneq ($(EMSCRIPTEN_FOUND ) ,found)
73
+ $(warning Emscripten "$(EMSCRIPTEN_MAKE)" toolchain not found, skipping Emscripten build)
64
74
endif
65
75
66
76
# installation defaults
@@ -119,6 +129,9 @@ GEN_DIR ?= $(BUILD_DIR)/$(GEN_SUBDIR_NAME)
119
129
USBOBJ ?= RCX_USBTowerPipe_none
120
130
TCPOBJ ?= RCX_TcpPipe_none
121
131
132
+ DEFAULT_USB_NAME ?= "/dev/usb/legousbtower0"
133
+ DEFAULT_DEVICE_NAME ?= "usb"
134
+
122
135
#
123
136
# Platform specific settings
124
137
#
@@ -144,61 +157,62 @@ ifneq (,$(strip $(findstring $(TARGETTYPE), JS-WebAssembly)))
144
157
# - Target JavaScript instead of WASM: -s WASM=0
145
158
CFLAGS_EXEC += --shell-file ./emscripten/webnqc_shell.html -s EXPORT_NAME=createWebNqc -s EXPORTED_RUNTIME_METHODS='["callMain","FS"]' \
146
159
-s INVOKE_RUN=false -s MODULARIZE=1 -s ENVIRONMENT=web -s SINGLE_FILE
147
- else
148
- ifneq (,$(strip $(findstring $(OSTYPE ) , Darwin) ) )
160
+ else ifneq (,$(strip $(findstring $(OSTYPE), Darwin)))
149
161
# Mac OS X
150
162
LIBS += -framework IOKit -framework CoreFoundation
151
163
USBOBJ = RCX_USBTowerPipe_osx
152
164
CXX = c++
153
165
CFLAGS += -O3 -std=c++11 -Wno-deprecated-register
154
- else
155
- ifneq (,$(strip $(findstring $(OSTYPE ) , Linux) ) )
166
+ else ifneq (,$(strip $(findstring $(OSTYPE), Linux)))
156
167
# Linux
157
168
USBOBJ = RCX_USBTowerPipe_linux
158
169
TCPOBJ = RCX_TcpPipe_linux
159
170
DEFAULT_SERIAL_NAME ?= "/dev/ttyS0"
160
171
# Timeout value is 200 in kernel driver module legousbtower.c
161
172
LEGO_TOWER_SET_READ_TIMEOUT ?= 200
162
173
CFLAGS += -DLEGO_TOWER_SET_READ_TIMEOUT='$(LEGO_TOWER_SET_READ_TIMEOUT)' -Wno-deprecated
163
- else
164
- ifneq (,$(findstring $(OSTYPE ) , SunOS) )
174
+ else ifneq (,$(strip $(findstring $(OSTYPE), CYGWIN)))
175
+ # Cygwin
176
+ # USBOBJ = RCX_USBTowerPipe_linux
177
+ TCPOBJ = RCX_TcpPipe_linux
178
+ DEFAULT_DEVICE_NAME ?= "tcp"
179
+ DEFAULT_SERIAL_NAME ?= "/dev/ttyS0"
180
+ # Timeout value is 200 in kernel driver module legousbtower.c
181
+ LEGO_TOWER_SET_READ_TIMEOUT ?= 200
182
+ CFLAGS += -DLEGO_TOWER_SET_READ_TIMEOUT='$(LEGO_TOWER_SET_READ_TIMEOUT)' -Wno-deprecated
183
+ else ifneq (,$(findstring $(OSTYPE), SunOS))
165
184
# Solaris
166
185
CFLAGS += -DSOLARIS
167
- else
168
- ifneq (,$(strip $(findstring $(OSTYPE ) , FreeBSD) ) )
186
+ else ifneq (,$(strip $(findstring $(OSTYPE), FreeBSD)))
169
187
# FreeBSD
170
188
USBOBJ = RCX_USBTowerPipe_fbsd
171
189
DEFAULT_SERIAL_NAME?= "/dev/cuad0"
172
190
CFLAGS += -Wno-deprecated
173
- else
174
- ifneq (,$(strip $(findstring $(OSTYPE ) , OpenBSD) ) )
191
+ else ifneq (,$(strip $(findstring $(OSTYPE), OpenBSD)))
175
192
# OpenBSD i386
176
193
DEFAULT_SERIAL_NAME ?= "/dev/cua00"
177
194
CFLAGS += -O2 -std=gnu++98 -pipe
178
195
else
179
196
# default Unix build without USB support
180
197
CFLAGS += -O2
181
198
endif
182
- endif
183
- endif
184
- endif
185
- endif
186
- endif
187
199
188
200
CXX: =$(TOOLPREFIX )$(CXX )
189
201
190
202
#
191
203
# If the serial port is explicitly set, use it.
192
204
#
193
205
ifneq ($(strip $(DEFAULT_SERIAL_NAME ) ) ,)
194
- CFLAGS += -DDEFAULT_SERIAL_NAME='$(DEFAULT_SERIAL_NAME)'
206
+ CFLAGS += -DDEFAULT_SERIAL_NAME='$(DEFAULT_SERIAL_NAME ) '
195
207
endif
196
208
197
- DEFAULT_USB_NAME ?= "/dev/usb/legousbtower0"
198
- CFLAGS += -DDEFAULT_USB_NAME='$(DEFAULT_USB_NAME ) '
209
+ ifneq ($(strip $(DEFAULT_USB_NAME ) ) ,)
210
+ CFLAGS += -DDEFAULT_USB_NAME='$(DEFAULT_USB_NAME ) '
211
+ endif
199
212
200
- DEFAULT_DEVICE_NAME ?= "usb"
213
+ ifneq ( $( strip $( DEFAULT_DEVICE_NAME ) ) ,)
201
214
CFLAGS += -DDEFAULT_DEVICE_NAME='$(DEFAULT_DEVICE_NAME ) '
215
+ endif
202
216
203
217
#
204
218
# Debug builds for most Clang/GCC environments.
@@ -251,7 +265,11 @@ $(EXEC_DIR)/nqc$(EXEC_EXT): compiler/parse.cpp $(OBJ)
251
265
# Emscripten build for WebAssembly
252
266
#
253
267
emscripten-emmake :
254
- if which emmake > /dev/null 2>&1 ; then emmake make exec TARGETTYPE=JS-WebAssembly ; else echo -e " WARNING: \" emmake\" not found; skipping Emscripten build" ; fi
268
+ ifeq ($(EMSCRIPTEN_FOUND ) , found)
269
+ $(EMSCRIPTEN_MAKE) make exec TARGETTYPE=JS-WebAssembly
270
+ else
271
+ @echo -e "WARNING: \"$(EMSCRIPTEN_MAKE)\" not found; skipping Emscripten build"
272
+ endif
255
273
256
274
#
257
275
# general rule for compiling
0 commit comments