<commit_before>OS  = $(shell uname -s)

ifeq ($(OS), Darwin)
	LDFLAGS += -framework CoreFoundation -framework Security
endif

all: examples

examples: example-c example-python

example-c: build/gohttp-c

example-c-static: build/gohttp-c-static

example-python: examples/python/gohttp/_gohttplib.py


build/:
	mkdir build

build/libgohttp.a: *.go
	go build -buildmode=c-archive -o $@

build/libgohttp.so: *.go build
	go build -buildmode=c-shared -o libgohttp.so && mv libgohttp.* $(dir $@)

build/gohttp-c-static: examples/c/ build/libgohttp.a
	gcc -o $@ examples/c/main.c build/libgohttp.a $(LDFLAGS) -lpthread

build/gohttp-c: examples/c/ build/libgohttp.so
	gcc -o $@ examples/c/main.c -Lbuild -lgohttp -lpthread $(LDFLAGS)

examples/python/gohttp/libgohttp.so: build/libgohttp.so
	cp $< $@

examples/python/gohttp/_gohttplib.py: examples/python/gohttp/build_gohttplib.py examples/python/gohttp/libgohttp.so
	cd examples/python && python gohttp/build_gohttplib.py

clean:
	rm -rf build/<commit_msg>benchmark helper<commit_after>OS  = $(shell uname -s)

ifeq ($(OS), Darwin)
	LDFLAGS += -framework CoreFoundation -framework Security
endif

all: examples

examples: example-c example-python

example-c: build/gohttp-c

example-c-static: build/gohttp-c-static

example-python: examples/python/gohttp/_gohttplib.py


build/:
	mkdir build

build/libgohttp.a: *.go
	go build -buildmode=c-archive -o $@

build/libgohttp.so: *.go build
	go build -buildmode=c-shared -o libgohttp.so && mv libgohttp.* $(dir $@)

build/gohttp-c-static: examples/c/ build/libgohttp.a
	gcc -o $@ examples/c/main.c build/libgohttp.a $(LDFLAGS) -lpthread

build/gohttp-c: examples/c/ build/libgohttp.so
	gcc -o $@ examples/c/main.c -Lbuild -lgohttp -lpthread $(LDFLAGS)

examples/python/gohttp/libgohttp.so: build/libgohttp.so
	cp $< $@

examples/python/gohttp/_gohttplib.py: examples/python/gohttp/build_gohttplib.py examples/python/gohttp/libgohttp.so
	cd examples/python && python gohttp/build_gohttplib.py

clean:
	rm -rf build/

benchmark:
	ab -n 10000 -c 10 -s 3 http://127.0.0.1:$(PORT)/
{'fraction_non_alphanumeric': 0.14382566585956416, 'fraction_numerical': 0.006779661016949152, 'mean_word_length': 4.0390243902439025, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '6084336', 'n_tokens_mistral': 825, 'n_tokens_neox': 784, 'n_words': 163}