CC=gcc
STRIP=strip
BIN=build
SRC=src
PREFIX=/usr

default: all

all: build

build: smol smol-pthreads smol-http smol-http-pthreads

smol:
	$(CC) -o $(BIN)/smol $(SRC)/smol.c -lcrypto -lssl

smol-pthreads:
	$(CC) -o $(BIN)/smol-pthreads $(SRC)/smol-pthreads.c -lcrypto -lssl

smol-http:
	$(CC) -o $(BIN)/smol-http $(SRC)/smol-http.c

smol-http-pthreads:
	$(CC) -o $(BIN)/smol-http-pthreads $(SRC)/smol-http-pthreads.c

clean:
	if [ -d $(BIN) ]; then rm -rv $(BIN);mkdir -pv $(BIN);fi

install:
	cp -v $(BIN)/* $(PREFIX)/bin/
	$(STRIP) $(PREFIX)/bin/smol
	$(STRIP) $(PREFIX)/bin/smol-pthreads
	$(STRIP) $(PREFIX)/bin/smol-http
	$(STRIP) $(PREFIX)/bin/smol-http-pthreads

uninstall: remove

remove:
	if [ -f $(PREFIX)/bin/smol ];then rm -v $(PREFIX)/bin/smol;fi
	if [ -f $(PREFIX)/bin/smol-pthreads ];then rm -v $(PREFIX)/bin/smol-pthreads;fi
	if [ -f $(PREFIX)/bin/smol-http ];then rm -v $(PREFIX)/bin/smol-http;fi
	if [ -f $(PREFIX)/bin/smol-http-pthreads ];then rm -v $(PREFIX)/bin/smol-http-pthreads;fi