@@ -40,7 +40,7 @@ include boards/$(BOARD)/mpconfigboard.mk
4040# Port-specific
4141include mpconfigport.mk
4242# CircuitPython-specific
43- include .. /circuitpy-common/mpconfig_circuitpy.mk
43+ include $( TOP ) /ports /circuitpy-common/mpconfig_circuitpy.mk
4444
4545# qstr definitions (must come before including py.mk)
4646QSTR_DEFS = qstrdefsport.h
@@ -50,6 +50,9 @@ include $(TOP)/py/py.mk
5050
5151include $(TOP ) /supervisor/supervisor.mk
5252
53+ # Include make rules and variables common across CircuitPython builds.
54+ include $(TOP ) /ports/circuitpy-common/circuitpy_defns.mk
55+
5356CROSS_COMPILE = arm-none-eabi-
5457
5558HAL_DIR =hal/$(MCU_SERIES )
@@ -79,36 +82,6 @@ INC += -I. \
7982 -I../../supervisor/shared/usb \
8083 -I$(BUILD )
8184
82- BASE_CFLAGS = \
83- -fsingle-precision-constant \
84- -fno-strict-aliasing \
85- -Wdouble-promotion \
86- -Wno-endif-labels \
87- -Wstrict-prototypes \
88- -Werror-implicit-function-declaration \
89- -Wfloat-equal \
90- -Wundef \
91- -Wshadow \
92- -Wwrite-strings \
93- -Wsign-compare \
94- -Wmissing-format-attribute \
95- -Wno-deprecated-declarations \
96- -Wnested-externs \
97- -Wunreachable-code \
98- -Wcast-align \
99- -Wno-error=lto-type-mismatch \
100- -D__$(CHIP_VARIANT ) __ \
101- -ffunction-sections \
102- -fdata-sections \
103- -fshort-enums \
104- -DCIRCUITPY_SOFTWARE_SAFE_MODE=0x0ADABEEF \
105- -DCIRCUITPY_CANARY_WORD=0xADAF00 \
106- -DCIRCUITPY_SAFE_RESTART_WORD=0xDEADBEEF \
107- --param max-inline-insns-single=500
108-
109- # Use these flags to debug build times and header includes.
110- # -ftime-report
111- # -H
11285
11386# NDEBUG disables assert() statements. This reduces code size pretty dramatically, per tannewt.
11487
@@ -169,22 +142,7 @@ CFLAGS += \
169142 -DSAMD51
170143endif
171144
172- ifneq ($(FROZEN_DIR ) ,)
173- # To use frozen source modules, put your .py files in a subdirectory (eg scripts/)
174- # and then invoke make with FROZEN_DIR=scripts (be sure to build from scratch).
175- CFLAGS += -DMICROPY_MODULE_FROZEN_STR
176- CFLAGS += -Wno-error=lto-type-mismatch
177- endif
178-
179- # To use frozen bytecode, put your .py files in a subdirectory (eg frozen/) and
180- # then invoke make with FROZEN_MPY_DIR=frozen or FROZEN_MPY_DIRS="dir1 dir2"
181- # (be sure to build from scratch).
182145
183- ifneq ($(FROZEN_MPY_DIRS ) ,)
184- CFLAGS += -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool
185- CFLAGS += -DMICROPY_MODULE_FROZEN_MPY
186- CFLAGS += -Wno-error=lto-type-mismatch
187- endif
188146
189147LDFLAGS = $(CFLAGS ) -nostartfiles -fshort-enums -Wl,-nostdlib -Wl,-T,$(LD_FILE ) -Wl,-Map=$@ .map -Wl,-cref -Wl,-gc-sections -specs=nano.specs
190148LIBS := -lgcc -lc
@@ -194,20 +152,6 @@ ifndef INTERNAL_LIBM
194152LIBS += -lm
195153endif
196154
197- # Propagate longint choice from .mk to C. There's no easy string comparison
198- # in cpp coniditionals, so we #define separate names for each.
199- ifeq ($(LONGINT_IMPL ) ,NONE)
200- CFLAGS += -DLONGINT_IMPL_NONE
201- endif
202-
203- ifeq ($(LONGINT_IMPL ) ,MPZ)
204- CFLAGS += -DLONGINT_IMPL_MPZ
205- endif
206-
207- ifeq ($(LONGINT_IMPL ) ,LONGLONG)
208- CFLAGS += -DLONGINT_IMPL_LONGLONG
209- endif
210-
211155ifeq ($(CHIP_FAMILY ) , samd21)
212156LDFLAGS += -mthumb -mcpu=cortex-m0plus -Lasf/thirdparty/CMSIS/Lib/GCC/
213157BOOTLOADER_SIZE := 0x2000
@@ -302,6 +246,7 @@ SRC_C = \
302246 supervisor/shared/memory.c \
303247 tick.c \
304248
249+
305250ifeq ($(CIRCUITPY_NETWORK ) ,1)
306251CFLAGS += -DMICROPY_PY_NETWORK=1
307252
@@ -322,231 +267,6 @@ SRC_MOD += $(addprefix $(WIZNET5K_DIR)/,\
322267endif # MICROPY_PY_WIZNET5K
323268endif # CIRCUITPY_NETWORK
324269
325- ifeq ($(CIRCUITPY_ANALOGIO ) ,1)
326- SRC_PATTERNS += analogio/%
327- endif
328- ifeq ($(CIRCUITPY_AUDIOBUSIO ) ,1)
329- SRC_PATTERNS += audiobusio/%
330- endif
331- ifeq ($(CIRCUITPY_AUDIOIO ) ,1)
332- SRC_PATTERNS += audioio/%
333- endif
334- ifeq ($(CIRCUITPY_BITBANGIO ) ,1)
335- SRC_PATTERNS += bitbangio/%
336- endif
337- ifeq ($(CIRCUITPY_BOARD ) ,1)
338- SRC_PATTERNS += board/%
339- endif
340- ifeq ($(CIRCUITPY_BUSIO ) ,1)
341- SRC_PATTERNS += busio/% bitbangio/OneWire.%
342- endif
343- ifeq ($(CIRCUITPY_DIGITALIO ) ,1)
344- SRC_PATTERNS += digitalio/%
345- endif
346- ifeq ($(CIRCUITPY_DISPLAYIO ) ,1)
347- SRC_PATTERNS += displayio/% terminalio/%
348- endif
349- ifeq ($(CIRCUITPY_GAMEPAD ) ,1)
350- SRC_PATTERNS += gamepad/%
351- endif
352- ifeq ($(CIRCUITPY_I2CSLAVE ) ,1)
353- SRC_PATTERNS += i2cslave/%
354- endif
355- ifeq ($(CIRCUITPY_MATH ) ,1)
356- SRC_PATTERNS += math/%
357- endif
358- ifeq ($(CIRCUITPY_MICROCONTROLLER ) ,1)
359- SRC_PATTERNS += microcontroller/%
360- endif
361- ifeq ($(CIRCUITPY_NEOPIXEL_WRITE ) ,1)
362- SRC_PATTERNS += neopixel_write/%
363- endif
364- ifeq ($(CIRCUITPY_NETWORK ) ,1)
365- SRC_PATTERNS += network/% socket/%
366- endif
367- ifeq ($(CIRCUITPY_NVM ) ,1)
368- SRC_PATTERNS += nvm/%
369- endif
370- ifeq ($(CIRCUITPY_OS ) ,1)
371- SRC_PATTERNS += os/%
372- endif
373- ifeq ($(CIRCUITPY_PIXELBUF ) ,1)
374- SRC_PATTERNS += _pixelbuf/%
375- endif
376- ifeq ($(CIRCUITPY_PULSEIO ) ,1)
377- SRC_PATTERNS += pulseio/%
378- endif
379- ifeq ($(CIRCUITPY_RANDOM ) ,1)
380- SRC_PATTERNS += random/%
381- endif
382- ifeq ($(CIRCUITPY_ROTARYIO ) ,1)
383- SRC_PATTERNS += rotaryio/%
384- endif
385- ifeq ($(CIRCUITPY_RTC ) ,1)
386- SRC_PATTERNS += rtc/%
387- endif
388- ifeq ($(CIRCUITPY_SAMD ) ,1)
389- SRC_PATTERNS += samd/%
390- endif
391- ifeq ($(CIRCUITPY_STAGE ) ,1)
392- SRC_PATTERNS += _stage/%
393- endif
394- ifeq ($(CIRCUITPY_STORAGE ) ,1)
395- SRC_PATTERNS += storage/%
396- endif
397- ifeq ($(CIRCUITPY_STRUCT ) ,1)
398- SRC_PATTERNS += struct/%
399- endif
400- ifeq ($(CIRCUITPY_SUPERVISOR ) ,1)
401- SRC_PATTERNS += supervisor/%
402- endif
403- ifeq ($(CIRCUITPY_TIME ) ,1)
404- SRC_PATTERNS += time/%
405- endif
406- ifeq ($(CIRCUITPY_TOUCHIO ) ,1)
407- SRC_PATTERNS += touchio/%
408- endif
409- ifeq ($(CIRCUITPY_UHEAP ) ,1)
410- SRC_PATTERNS += uheap/%
411- endif
412- ifeq ($(CIRCUITPY_USB_HID ) ,1)
413- SRC_PATTERNS += usb_hid/%
414- endif
415- ifeq ($(CIRCUITPY_USB_MIDI ) ,1)
416- SRC_PATTERNS += usb_midi/%
417- endif
418- ifeq ($(CIRCUITPY_USTACK ) ,1)
419- SRC_PATTERNS += ustack/%
420- endif
421-
422- # All possible sources are listed here, and are filtered by SRC_PATTERNS.
423- SRC_COMMON_HAL = \
424- $(filter $(SRC_PATTERNS ) , \
425- analogio/AnalogIn.c \
426- analogio/AnalogOut.c \
427- analogio/__init__.c \
428- audiobusio/__init__.c \
429- audiobusio/I2SOut.c \
430- audiobusio/PDMIn.c \
431- audioio/__init__.c \
432- audioio/AudioOut.c \
433- board/__init__.c \
434- busio/I2C.c \
435- busio/SPI.c \
436- busio/UART.c \
437- busio/__init__.c \
438- digitalio/DigitalInOut.c \
439- digitalio/__init__.c \
440- displayio/ParallelBus.c \
441- i2cslave/I2CSlave.c \
442- i2cslave/__init__.c \
443- microcontroller/Pin.c \
444- microcontroller/Processor.c \
445- microcontroller/__init__.c \
446- neopixel_write/__init__.c \
447- nvm/ByteArray.c \
448- nvm/__init__.c \
449- os/__init__.c \
450- pulseio/PWMOut.c \
451- pulseio/PulseIn.c \
452- pulseio/PulseOut.c \
453- pulseio/__init__.c \
454- rotaryio/IncrementalEncoder.c \
455- rotaryio/__init__.c \
456- rtc/RTC.c \
457- rtc/__init__.c \
458- supervisor/Runtime.c \
459- supervisor/__init__.c \
460- time/__init__.c \
461- touchio/TouchIn.c \
462- touchio/__init__.c \
463- )
464-
465- # These don't have corresponding files in each port but are still located in
466- # shared-bindings to make it clear what the contents of the modules are.
467- # All possible sources are listed here, and are filtered by SRC_PATTERNS.
468- SRC_BINDINGS_ENUMS = \
469- $(filter $(SRC_PATTERNS ) , \
470- digitalio/Direction.c \
471- digitalio/DriveMode.c \
472- digitalio/Pull.c \
473- displayio/Glyph.c \
474- microcontroller/RunMode.c \
475- math/__init__.c \
476- supervisor/__init__.c \
477- )
478-
479- SRC_BINDINGS_ENUMS += \
480- help.c \
481- util.c
482-
483- # All possible sources are listed here, and are filtered by SRC_PATTERNS.
484- SRC_SHARED_MODULE = \
485- $(filter $(SRC_PATTERNS ) , \
486- _pixelbuf/PixelBuf.c \
487- _pixelbuf/__init__.c \
488- _stage/Layer.c \
489- _stage/Text.c \
490- _stage/__init__.c \
491- audioio/__init__.c \
492- audioio/Mixer.c \
493- audioio/RawSample.c \
494- audioio/WaveFile.c \
495- bitbangio/I2C.c \
496- bitbangio/OneWire.c \
497- bitbangio/SPI.c \
498- bitbangio/__init__.c \
499- busio/OneWire.c \
500- displayio/Bitmap.c \
501- displayio/BuiltinFont.c \
502- displayio/ColorConverter.c \
503- displayio/Display.c \
504- displayio/FourWire.c \
505- displayio/Group.c \
506- displayio/OnDiskBitmap.c \
507- displayio/Palette.c \
508- displayio/Shape.c \
509- displayio/TileGrid.c \
510- displayio/__init__.c \
511- gamepad/GamePad.c \
512- gamepad/__init__.c \
513- os/__init__.c \
514- random/__init__.c \
515- socket/__init__.c \
516- network/__init__.c \
517- storage/__init__.c \
518- struct/__init__.c \
519- terminalio/Terminal.c \
520- terminalio/__init__.c \
521- uheap/__init__.c \
522- ustack/__init__.c \
523- )
524-
525- ifeq ($(INTERNAL_LIBM ) ,1)
526- SRC_LIBM = \
527- $(addprefix lib/,\
528- libm/math.c \
529- libm/roundf.c \
530- libm/fmodf.c \
531- libm/nearbyintf.c \
532- libm/ef_sqrt.c \
533- libm/kf_rem_pio2.c \
534- libm/kf_sin.c \
535- libm/kf_cos.c \
536- libm/kf_tan.c \
537- libm/ef_rem_pio2.c \
538- libm/sf_sin.c \
539- libm/sf_cos.c \
540- libm/sf_tan.c \
541- libm/sf_frexp.c \
542- libm/sf_modf.c \
543- libm/sf_ldexp.c \
544- libm/asinfacosf.c \
545- libm/atanf.c \
546- libm/atan2f.c \
547- )
548- endif
549-
550270ifeq ($(CIRCUITPY_NETWORK ) ,1)
551271ifneq ($(MICROPY_PY_WIZNET5K ) ,0)
552272SRC_SHARED_MODULE += wiznet/__init__.c wiznet/wiznet5k.c
@@ -577,7 +297,7 @@ endif
577297OBJ += $(addprefix $(BUILD ) /, $(SRC_S:.s=.o ) )
578298OBJ += $(addprefix $(BUILD ) /, $(SRC_MOD:.c=.o ) )
579299
580- SRC_QSTR += $(SRC_C ) $(SRC_SUPERVISOR ) $(SRC_COMMON_HAL_EXPANDED ) $(SRC_SHARED_MODULE_EXPANDED ) $( STM_SRC_C )
300+ SRC_QSTR += $(SRC_C ) $(SRC_SUPERVISOR ) $(SRC_COMMON_HAL_EXPANDED ) $(SRC_SHARED_MODULE_EXPANDED )
581301# Sources that only hold QSTRs after pre-processing.
582302SRC_QSTR_PREPROCESSOR += peripherals/samd/$(CHIP_FAMILY ) /clocks.c
583303
0 commit comments