<commit_before># set hal if not given by "hal=____"

ifeq ($(strip $(hal)),)
  hal=lpc2106-cmucam3
endif

HALDIR=../../hal/$(hal)

# include definitions (compiler, options, etc)
include $(HALDIR)/defs.mk


OBJDIR=$(HALNAME)_buildfiles
OBJS=$(patsubst %.c, $(OBJDIR)/%.o,$(CSOURCES))

# decide if we are building a project or a lib
ifneq ($(strip $(PROJECT)),)
 item=$(PROJECT)_$(HALNAME).hex
else
 PROJECT=$(LIB)
 item=lib$(PROJECT)_$(HALNAME).a
endif


# targets
all: $(item)

$(PROJECT)_$(HALNAME).hex: $(PROJECT)_$(HALNAME)
	@echo "  OBJCOPY $@"
	@$(OBJCOPY) -O ihex $< $@
	@$(SIZE) $<

LIBFILES=$(foreach lib,$(LIBS),../../lib/$(lib)/lib$(lib)_$(HALNAME).a)
LIBDIRS=$(foreach lib,$(LIBS),../../lib/$(lib))
LIBARGS=$(foreach lib,$(LIBS),-l$(lib)_$(HALNAME))

$(PROJECT)_$(HALNAME): $(OBJS) $(HALDIR)/$(HALLIB) $(LIBFILES)
	@echo "  CC      $@"
	@$(CC) -o $@ $(OBJS) -L$(HALDIR) \
	$(foreach ldir,$(LIBDIRS),-L$(ldir)) \
	-Wl,-whole-archive -lhal-$(HALNAME) \
	$(LIBARGS) \
	-Wl,-no-whole-archive $(LDFLAGS)

$(OBJS): $(OBJDIR)/%.o : %.c $(INCLUDES)
	@if [ ! -d $(OBJDIR) ]; then $(RM) $(OBJDIR); \
                                     echo "  MKDIR   $(OBJDIR)"; \
                                     mkdir $(OBJDIR); fi
	@echo "  CC      $@"
	@$(CC) $(CFLAGS) $(foreach ldir,$(LIBDIRS),-I$(ldir)) -o $@ -c $<


# if LIB = something
lib$(PROJECT)_$(HALNAME).a: $(OBJS)
	@echo "  AR      $@"
	@$(AR) rs $@ $^



clean:
	$(RM) *.hex
	$(RM) $(PROJECT)_$(HALNAME)
	$(RM) $(PROJECT)_$(HALNAME).exe
	$(RM) lib$(PROJECT)_$(HALNAME).a
	$(RM) -r $(OBJDIR)
<commit_msg>organize<commit_after># set hal if not given by "hal=____"

ifeq ($(strip $(hal)),)
  hal=lpc2106-cmucam3
endif

HALDIR=../../hal/$(hal)

# include definitions (compiler, options, etc)
include $(HALDIR)/defs.mk


OBJDIR=$(HALNAME)_buildfiles
OBJS=$(patsubst %.c, $(OBJDIR)/%.o,$(CSOURCES))

# decide if we are building a project or a lib
ifneq ($(strip $(PROJECT)),)
 item=$(PROJECT)_$(HALNAME).hex
else
 PROJECT=$(LIB)
 item=lib$(PROJECT)_$(HALNAME).a
endif


# targets
all: $(item)

$(PROJECT)_$(HALNAME).hex: $(PROJECT)_$(HALNAME)
	@echo "  OBJCOPY $@"
	@$(OBJCOPY) -O ihex $< $@
	@$(SIZE) $<

LIBFILES=$(foreach lib,$(LIBS),../../lib/$(lib)/lib$(lib)_$(HALNAME).a)
LIBDIRS=$(foreach lib,$(LIBS),../../lib/$(lib))
LIBARGS=$(foreach lib,$(LIBS),-l$(lib)_$(HALNAME))

$(PROJECT)_$(HALNAME): $(OBJS) $(HALDIR)/$(HALLIB) $(LIBFILES)
	@echo "  CC      $@"
	@$(CC) -o $@ $(OBJS) -L$(HALDIR) \
	$(foreach ldir,$(LIBDIRS),-L$(ldir)) \
	$(LIBARGS) \
	-Wl,-whole-archive \
	-lhal-$(HALNAME) \
	-Wl,-no-whole-archive \
	$(LDFLAGS)

$(OBJS): $(OBJDIR)/%.o : %.c $(INCLUDES)
	@if [ ! -d $(OBJDIR) ]; then $(RM) $(OBJDIR); \
                                     echo "  MKDIR   $(OBJDIR)"; \
                                     mkdir $(OBJDIR); fi
	@echo "  CC      $@"
	@$(CC) $(CFLAGS) $(foreach ldir,$(LIBDIRS),-I$(ldir)) -o $@ -c $<


# if LIB = something
lib$(PROJECT)_$(HALNAME).a: $(OBJS)
	@echo "  AR      $@"
	@$(AR) rs $@ $^



clean:
	$(RM) *.hex
	$(RM) $(PROJECT)_$(HALNAME)
	$(RM) $(PROJECT)_$(HALNAME).exe
	$(RM) lib$(PROJECT)_$(HALNAME).a
	$(RM) -r $(OBJDIR)

{'fraction_non_alphanumeric': 0.2615925807483211, 'fraction_numerical': 0.0031979533098816758, 'mean_word_length': 3.3504867872044506, 'pattern_counts': {'":': 0, '<': 9, '<?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': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '63772', 'n_tokens_mistral': 1350, 'n_tokens_neox': 1255, 'n_words': 244}