<commit_before>#
# This Makefile is used to bootstrap Nu.
# Use it to build "mininush", a simpler and statically-linked
# version of nush, the Nu shell.
#

PREFIX?=/usr/local

ifeq ($(shell test -e /usr/lib/libffi.dylib && echo yes), yes)
	# Use the libffi that ships with OS X.
	FFI_LIB=-L/usr/lib -lffi
	FFI_INCLUDE=-I /usr/include/ffi
else
	# Use the libffi that is distributed with Nu.
	FFI_LIB=-L./libffi -lffi
	FFI_INCLUDE=-I ./libffi/include
endif

ifeq ($(shell test -e $(PREFIX)/lib/libpcre.dylib && echo yes), yes)
	# Use already-installed PCRE.
	PCRE_LIB=-L$(PREFIX)/lib -lpcre
	PCRE_INCLUDE=-I $(PREFIX)/include
else
	# Use PCRE in the Nu directory.
	PCRE_LIB=-Lpcre-7.5/.libs -lpcre
	PCRE_INCLUDE=-I pcre-7.5
endif

INCLUDES=$(FFI_INCLUDE) $(PCRE_INCLUDE) -I./include/Nu
LIBS=-lobjc -lreadline $(PCRE_LIB) $(FFI_LIB)
CFLAGS=-g -O2 -Wall -DDARWIN -DMACOSX -DMININUSH -std=gnu99 -DLEOPARD_OBJC2
MFLAGS=-fobjc-exceptions
LDFLAGS=-framework Cocoa $(LIBS)

# FIXME add PREFIX/lib and PREFIX/include if they exist

OBJS=$(patsubst %.m,%.o, $(wildcard objc/*.m)) $(patsubst %.c,%.o, $(wildcard objc/*.c))

all: nush

.m.o:
	gcc $(CFLAGS) $(MFLAGS) $(INCLUDES) -c $< -o $@

.c.o:
	gcc $(CFLAGS) $(INCLUDES) -c $< -o $@

.PHONY: nush
nush: mininush 
	mininush tools/nuke

mininush: $(OBJS)
	gcc $(OBJS) $(CFLAGS) $(MFLAGS) $(INCLUDES) main/main.m -o $@ $(LDFLAGS)
	install_name_tool -change /usr/local/lib/libpcre.0.dylib pcre-7.5/.libs/libpcre.0.dylib $@

# These actions assume that nush and nuke are installed somewhere safe, such as /usr/local/bin

.PHONY: clean
clean:
	rm -f objc/*.o mininush
	nuke clean

.PHONY: clobber
clobber: clean
	nuke clobber<commit_msg>Rewrote Makefile to copy the tasks of the Rakefile<commit_after>#
# This Makefile is used to bootstrap Nu.
# Use it to build "mininush", a simpler and statically-linked
# version of nush, the Nu shell.
#

SYSTEM = $(shell uname)

PREFIX ?= /usr/local

ifeq ($(SYSTEM), Darwin)
	ifeq ($(shell test -e /usr/lib/libffi.dylib && echo yes), yes)
		# Use the libffi that ships with OS X.
		FFI_LIB = -L/usr/lib -lffi
		FFI_INCLUDE = -I/usr/include/ffi
		LEOPARD_CFLAGS = -DLEOPARD_OBJC2
	else
		# Use the libffi that is distributed with Nu.
		FFI_LIB = -L./libffi -lffi
		FFI_INCLUDE = -I./libffi/include
		LEOPARD_CFLAGS =
	endif

else # Linux
	FFI_LIB=-lffi
	FFI_INCLUDE=
endif

INCLUDES = $(FFI_INCLUDE) -I./include/Nu

ifeq ($(SYSTEM), Darwin)
	ifeq ($(shell test -d $(PREFIX)/include && echo yes), yes)
		INCLUDES += -I$(PREFIX)/include
	endif
	FRAMEWORKS = -framework Cocoa
	LIBS = -lobjc -lpcre -lreadline
	LIBDIRS =
	ifeq ($(shell test -d $(PREFIX)/lib && echo yes), yes)
		LIBDIRS += -L$(PREFIX)/lib
	endif
else
	INCLUDES += -I/usr/local/include
	FRAMEWORKS =
	LIBS = -lm -lpcre -lreadline
	LIBDIRS =
endif

C_FILES = $(wildcard objc/*.c)
OBJC_FILES = $(wildcard objc/*.m) $(wildcard main/*.m)
GCC_FILES = $(OBJC_FILES) $(C_FILES)
GCC_OBJS = $(patsubst %.m, %.o, $(OBJC_FILES)) $(patsubst %.c, %.o, $(C_FILES))

CC = gcc
CFLAGS = -g -O2 -Wall -DMININUSH -std=gnu99
MFLAGS = -fobjc-exceptions

ifeq ($(SYSTEM), Darwin)
	CFLAGS += -DMACOSX -DDARWIN $(LEOPARD_CFLAGS)
else
	CFLAGS += -DLINUX
s	MFLAGS += -fconstant-string-class=NSConstantString
endif

LDFLAGS += $(FRAMEWORKS)
LDFLAGS += $(LIBS)
LDFLAGS += $(LIBDIRS)
LDFLAGS += $(FFI_LIB)

ifeq ($(SYSTEM), Linux)
	LDFLAGS += -lobjc -lNuFound
	LDFLAGS += -Wl,--rpath -Wl,/usr/local/lib
endif

all: mininush

%.o: %.m
	$(CC) $(CFLAGS) $(MFLAGS) $(INCLUDES) -c $< -o $@

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

.PHONY: mininush
mininush: $(GCC_OBJS)
	@echo "LDFLAGS: $(LDFLAGS)"
	@echo "INCLUDES: $(INCLUDES)"
	$(CC) $(GCC_OBJS) -g -O2 -o mininush $(LDFLAGS)

.PHONY: clean
clean:
	rm -f objc/*.o main/*.o

.PHONY: clobber
clobber: clean
	rm -f mininush
{'fraction_non_alphanumeric': 0.1656538969616909, 'fraction_numerical': 0.004491413474240423, 'mean_word_length': 3.7148194271481945, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2570165', 'n_tokens_mistral': 1706, 'n_tokens_neox': 1603, 'n_words': 422}