<commit_before>ifeq ($(PLATFORM), gcw0)
  CC := /opt/gcw0-toolchain/usr/bin/mipsel-linux-gcc
  STRIP := /opt/gcw0-toolchain/usr/bin/mipsel-linux-strip
  BACKEND := LINUX
endif

ifndef BACKEND
$(error Please specify BACKEND. Possible values: LINUX, OSX")
endif

LIBNAME      := libshake
SOVERSION    := 0

SRC := $(wildcard src/common/*.c)

ifeq ($(BACKEND), LINUX)
  LIBEXT := .so
  SONAME := $(LIBNAME)$(LIBEXT).$(SOVERSION)
  PREFIX ?= /usr
  LDFLAGS :=-Wl,-soname,$(SONAME)
  SRC += $(wildcard src/linux/*.c)
else ifeq ($(BACKEND), OSX)
  LIBEXT := .dylib
  SONAME := $(LIBNAME).$(SOVERSION)$(LIBEXT)
  PREFIX ?= /usr/local
  LDFLAGS := -Wl,-framework,Cocoa -framework IOKit -framework CoreFoundation -framework ForceFeedback -install_name $(SONAME)
  SRC += $(wildcard src/osx/*.c)
endif

CC ?= gcc
STRIP ?= strip
TARGET ?= $(SONAME)
SYSROOT := $(shell $(CC) --print-sysroot)
DESTDIR ?= $(SYSROOT)
CFLAGS := -fPIC
OBJ := $(SRC:.c=.o)

ifdef DEBUG
  CFLAGS += -ggdb -Wall -Werror
else
  CFLAGS += -O2
endif

.PHONY: all clean

all:	$(TARGET)

$(TARGET): $(OBJ)
	$(CC) $(LDFLAGS) -shared $(CFLAGS) $^ -o $@
ifdef DO_STRIP
	$(STRIP) $@
endif

%.o:	%.c
	$(CC) -c $(CFLAGS) $< -o $@ -I include

install-headers:
	cp include/*.h $(DESTDIR)$(PREFIX)/include/

install-lib:
	cp $(TARGET) $(DESTDIR)$(PREFIX)/lib/
	ln -sf $(DESTDIR)$(PREFIX)/lib/$(TARGET) $(DESTDIR)$(PREFIX)/lib/$(LIBNAME)$(LIBEXT)

install: $(TARGET) install-headers install-lib

clean:
	rm -Rf $(TARGET) $(OBJ)
<commit_msg>Restore object directory and improve it<commit_after>ifeq ($(PLATFORM), gcw0)
  CC         := /opt/gcw0-toolchain/usr/bin/mipsel-linux-gcc
  STRIP      := /opt/gcw0-toolchain/usr/bin/mipsel-linux-strip
  BACKEND    := LINUX
endif

ifndef BACKEND
$(error Please specify BACKEND. Possible values: LINUX, OSX")
endif

LIBNAME      := libshake
SOVERSION    := 0

SRCDIRS      := common

ifeq ($(BACKEND), LINUX)
  LIBEXT     := .so
  SONAME     := $(LIBNAME)$(LIBEXT).$(SOVERSION)
  PREFIX     ?= /usr
  LDFLAGS    :=-Wl,-soname,$(SONAME)
  SRCDIRS    += linux
else ifeq ($(BACKEND), OSX)
  LIBEXT     := .dylib
  SONAME     := $(LIBNAME).$(SOVERSION)$(LIBEXT)
  PREFIX     ?= /usr/local
  LDFLAGS    := -Wl,-framework,Cocoa -framework IOKit -framework CoreFoundation -framework ForceFeedback -install_name $(SONAME)
  SRCDIRS    += osx
endif

CC           ?= gcc
STRIP        ?= strip
TARGET       ?= $(SONAME)
SYSROOT      := $(shell $(CC) --print-sysroot)
MACHINE      ?= $(shell $(CC) -dumpmachine)
DESTDIR      ?= $(SYSROOT)
CFLAGS       := -fPIC
SRCDIR       := src
OBJDIR       := obj/$(MACHINE)
SRC          := $(foreach dir,$(SRCDIRS),$(sort $(wildcard $(addprefix $(SRCDIR)/,$(dir))/*.c)))
OBJ          := $(patsubst $(SRCDIR)/%.c,$(OBJDIR)/%.o,$(SRC))

ifdef DEBUG
  CFLAGS += -ggdb -Wall -Werror
else
  CFLAGS += -O2
endif

.PHONY: all clean

all:	$(TARGET)

$(TARGET): $(OBJ)
	$(CC) $(LDFLAGS) -shared $(CFLAGS) $^ -o $@
ifdef DO_STRIP
	$(STRIP) $@
endif

$(OBJ): $(OBJDIR)/%.o: $(SRCDIR)/%.c
	mkdir -p $(@D)
	$(CC) -c $(CFLAGS) $< -o $@ -I include

install-headers:
	cp include/*.h $(DESTDIR)$(PREFIX)/include/

install-lib:
	cp $(TARGET) $(DESTDIR)$(PREFIX)/lib/
	ln -sf $(DESTDIR)$(PREFIX)/lib/$(TARGET) $(DESTDIR)$(PREFIX)/lib/$(LIBNAME)$(LIBEXT)

install: $(TARGET) install-headers install-lib

clean:
	rm -Rf $(TARGET) $(OBJDIR)

{'fraction_non_alphanumeric': 0.19807923169267708, 'fraction_numerical': 0.003001200480192077, 'mean_word_length': 3.391304347826087, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1124996', 'n_tokens_mistral': 1369, 'n_tokens_neox': 1306, 'n_words': 295}