include common/Makefile

WSRC=http://jeisson.work/concurrente/2025b/material/taskc/prod_cons_pattern
# -q=quiet -r=recursive -np=no-parent -nd=no-directories -R=exclude (regex for Fedora)
WGARGS=-qr -np -nd --reject-regex='index.html*'

# Simulation
# DEFS += -DSIMULATION
# ARGS = 1000 3 1 -2 -1

# WebServer
DEPS+=httperf httpie libcrypto++-dev #cryptopp-devel

DEFS += -DWEBSERVER
HOST=localhost
PORT=8080
CONN=200
RATE=50
REQS=3
NUMS=1234,341660047565274461,-777,ab,2482518306917950913,+09,--5,400338803,878519711,18446744073709551617,0,192589268261,1,1il1,441333503666273,2,88000
APP=fact
URI=/$(APP)?number=$(NUMS)
TIMEOUT=3
HCH=
QSZ=
ARGS=$(strip $(PORT) $(HCH) $(QSZ))

.PHONY: stress crun kill
stress: # Stress test
	httperf --server $(HOST) --port $(PORT) --num-conns $(CONN) --rate $(RATE) --num-call $(REQS) --uri $(URI) --timeout $(TIMEOUT)

crun: # Client run
	time http http://$(HOST):$(PORT)$(URI)

# If src/ dir does not exist, fetch it
src: .gitignore readme.adoc_ src/common/~ src/http/~ src/network/~ src/prodcons/~ src/webapp/~ static/~
	echo '*.html*' >> .gitignore

%/~:
	wget $(WGARGS) $(WSRC)/$*/ -P $*/

kill:
	pkill -9 $(APPNAME)
