<commit_before>
## Configuration

HOST ?= avr
FORMAT ?= ihex
FORMAT_EXTENSION ?= hex
MATH_LIB ?= yes
PRINTF_LEVEL ?= standard
STD ?= gnu11

project_dir ?= .
src_dir ?= $(project_dir)
obj_dir ?= $(project_dir)/build
gen_dir ?= $(obj_dir)/gen


export HOST project_dir obj_dir gen_dir
export MCU


# Try to guess AVARIX_DIR from current Makefile path
ifeq ($(AVARIX_DIR),)
AVARIX_DIR := $(dir $(lastword $(MAKEFILE_LIST)))..
endif
# Use absolute paths, may help editors.
ABS_AVARIX_DIR := $(abspath $(AVARIX_DIR))
export AVARIX_DIR

# include/compute deps files only for build rules
clean_rules := clean clean-project clean-modules clean-builddeps clean-bootloader
ifeq ($(filter $(clean_rules),$(MAKECMDGOALS)),)
export use_deps := yes
endif


## Internal variables

this_makefile := $(lastword $(MAKEFILE_LIST))

# Module dependencies
modules_deps = $(obj_dir)/modules.deps
export modules_deps

-include $(modules_deps)
PROJECT_MODULES_PATHS = $(addprefix modules/,$(PROJECT_MODULES))
MODULES_PATHS = $(sort $(PROJECT_MODULES_PATHS) bootloader/module $(BOOTLOADER_MODULES_PATHS))

SRC_COBJS = $(SRCS:%.c=$(obj_dir)/%.$(HOST).o)
GEN_COBJS = $(GEN_SRCS:%.c=$(obj_dir)/%.$(HOST).o)
COBJS = $(SRC_COBJS) $(GEN_COBJS)
AOBJS = $(ASRCS:%.S=$(obj_dir)/%.$(HOST).o)
OBJS = $(COBJS) $(AOBJS)
DEPS = $(COBJS:.o=.d)
GEN_FILES_FULL = $(addprefix $(gen_dir)/,$(GEN_FILES))
PROJECT_MODULES_LIBS = $(foreach m,$(PROJECT_MODULES_PATHS),$(obj_dir)/$(m).$(HOST).a)
PROJECT_LIB = $(obj_dir)/$(TARGET).$(HOST).a
LINKER_SCRIPT = $(AVARIX_DIR)/mk/avarix.ld

## Programs and commands

ifeq ($(HOST),avr)
CC = avr-gcc
AR = avr-ar
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
SIZE = avr-size
NM = avr-nm
TARGET_OBJ = $(TARGET).elf
OUTPUTS = $(TARGET).$(FORMAT_EXTENSION) $(TARGET).eep
else
CC = gcc
AR = ar
OBJCOPY = objcopy
OBJDUMP = objdump
SIZE = size --format=Berkeley
NM = nm
TARGET_OBJ = $(TARGET)
OUTPUTS = $(TARGET_OBJ)
endif
PY_TEMPLATIZE = $(AVARIX_DIR)/mk/templatize.py
export CC AR OBJCOPY PY_TEMPLATIZE

# On Windows, default find.exe is not the POSIX find
ifeq ($(OS),Windows_NT)
ifeq ($(dir $(SHELL)),/bin/)  # assume MSYS or Cygwin
FIND_DIR_NAME = /usr/bin/find $(1) -name $(2)
else
FIND_DIR_NAME = cd $(1) && find /S /B $(2)
endif
else
FIND_DIR_NAME = find $(1) -name $(2)
endif

# Prog
AVRDUDE = avrdude
AVRDUDE_PART = $(patsubst atxmega%,x%,$(MCU))
AVRDUDE_CMD = $(AVRDUDE) -p $(AVRDUDE_PART)

-include $(AVARIX_DIR)/mk/common.mk


## Various flags

INCLUDE_DIRS += . $(ABS_AVARIX_DIR)/include $(ABS_AVARIX_DIR)/modules $(gen_dir)/modules

CPPFLAGS += -Wall $(if $(STD),-std=$(STD))
CPPFLAGS += $(addprefix -I,$(INCLUDE_DIRS))
CFLAGS += -O$(OPT)
CFLAGS += -Wextra -Wno-unused-parameter -Wstrict-prototypes
ASFLAGS +=

ifeq ($(HOST),avr)

CPPFLAGS += -mmcu=$(MCU)
CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
CFLAGS += -fdata-sections -ffunction-sections
ASFLAGS += -Wa,-gstabs
LDFLAGS += -mmcu=$(MCU) -Wl,--gc-sections,--script,$(LINKER_SCRIPT)

printf_LDFLAGS_minimal := -Wl,-u,vfprintf -lprintf_min
printf_LDFLAGS_standard :=
printf_LDFLAGS_advanced := -Wl,-u,vfprintf -lprintf_flt
PROJECT_LDFLAGS = $(LDFLAGS)
PROJECT_LDFLAGS += $(printf_LDFLAGS_$(PRINTF_LEVEL))

else<commit_msg>Don't use custom linker script for bootloader<commit_after>
## Configuration

HOST ?= avr
FORMAT ?= ihex
FORMAT_EXTENSION ?= hex
MATH_LIB ?= yes
PRINTF_LEVEL ?= standard
STD ?= gnu11

project_dir ?= .
src_dir ?= $(project_dir)
obj_dir ?= $(project_dir)/build
gen_dir ?= $(obj_dir)/gen


export HOST project_dir obj_dir gen_dir
export MCU


# Try to guess AVARIX_DIR from current Makefile path
ifeq ($(AVARIX_DIR),)
AVARIX_DIR := $(dir $(lastword $(MAKEFILE_LIST)))..
endif
# Use absolute paths, may help editors.
ABS_AVARIX_DIR := $(abspath $(AVARIX_DIR))
export AVARIX_DIR

# include/compute deps files only for build rules
clean_rules := clean clean-project clean-modules clean-builddeps clean-bootloader
ifeq ($(filter $(clean_rules),$(MAKECMDGOALS)),)
export use_deps := yes
endif


## Internal variables

this_makefile := $(lastword $(MAKEFILE_LIST))

# Module dependencies
modules_deps = $(obj_dir)/modules.deps
export modules_deps

-include $(modules_deps)
PROJECT_MODULES_PATHS = $(addprefix modules/,$(PROJECT_MODULES))
MODULES_PATHS = $(sort $(PROJECT_MODULES_PATHS) bootloader/module $(BOOTLOADER_MODULES_PATHS))

SRC_COBJS = $(SRCS:%.c=$(obj_dir)/%.$(HOST).o)
GEN_COBJS = $(GEN_SRCS:%.c=$(obj_dir)/%.$(HOST).o)
COBJS = $(SRC_COBJS) $(GEN_COBJS)
AOBJS = $(ASRCS:%.S=$(obj_dir)/%.$(HOST).o)
OBJS = $(COBJS) $(AOBJS)
DEPS = $(COBJS:.o=.d)
GEN_FILES_FULL = $(addprefix $(gen_dir)/,$(GEN_FILES))
PROJECT_MODULES_LIBS = $(foreach m,$(PROJECT_MODULES_PATHS),$(obj_dir)/$(m).$(HOST).a)
PROJECT_LIB = $(obj_dir)/$(TARGET).$(HOST).a
LINKER_SCRIPT = $(AVARIX_DIR)/mk/avarix.ld

## Programs and commands

ifeq ($(HOST),avr)
CC = avr-gcc
AR = avr-ar
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
SIZE = avr-size
NM = avr-nm
TARGET_OBJ = $(TARGET).elf
OUTPUTS = $(TARGET).$(FORMAT_EXTENSION) $(TARGET).eep
else
CC = gcc
AR = ar
OBJCOPY = objcopy
OBJDUMP = objdump
SIZE = size --format=Berkeley
NM = nm
TARGET_OBJ = $(TARGET)
OUTPUTS = $(TARGET_OBJ)
endif
PY_TEMPLATIZE = $(AVARIX_DIR)/mk/templatize.py
export CC AR OBJCOPY PY_TEMPLATIZE

# On Windows, default find.exe is not the POSIX find
ifeq ($(OS),Windows_NT)
ifeq ($(dir $(SHELL)),/bin/)  # assume MSYS or Cygwin
FIND_DIR_NAME = /usr/bin/find $(1) -name $(2)
else
FIND_DIR_NAME = cd $(1) && find /S /B $(2)
endif
else
FIND_DIR_NAME = find $(1) -name $(2)
endif

# Prog
AVRDUDE = avrdude
AVRDUDE_PART = $(patsubst atxmega%,x%,$(MCU))
AVRDUDE_CMD = $(AVRDUDE) -p $(AVRDUDE_PART)

-include $(AVARIX_DIR)/mk/common.mk


## Various flags

INCLUDE_DIRS += . $(ABS_AVARIX_DIR)/include $(ABS_AVARIX_DIR)/modules $(gen_dir)/modules

CPPFLAGS += -Wall $(if $(STD),-std=$(STD))
CPPFLAGS += $(addprefix -I,$(INCLUDE_DIRS))
CFLAGS += -O$(OPT)
CFLAGS += -Wextra -Wno-unused-parameter -Wstrict-prototypes
ASFLAGS +=

ifeq ($(HOST),avr)

CPPFLAGS += -mmcu=$(MCU)
CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
CFLAGS += -fdata-sections -ffunction-sections
ASFLAGS += -Wa,-gstabs
LDFLAGS += -mmcu=$(MCU)

printf_LDFLAGS_minimal := -Wl,-u,vfprintf -lprintf_min
printf_LDFLAGS_standard :=
printf_LDFLAGS_advanced := -Wl,-u,vfprintf -lprintf_flt
PROJECT_LDFLAGS = $(LDFLAGS) -Wl,--gc-sections,--script,$(LINKER_SCRIPT)
PROJECT_LDFLAGS += $(printf_LDFLAGS_$(PRINTF_LEVEL))

else
{'fraction_non_alphanumeric': 0.167805029493946, 'fraction_numerical': 0.0024837007140639552, 'mean_word_length': 5.59467758444217, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6666318', 'n_tokens_mistral': 2655, 'n_tokens_neox': 2556, 'n_words': 539}