$OpenBSD$

Add static lib target and default target for compilation
Remove hardcoded optimization flags and lto

Index: Makefile
--- Makefile.orig
+++ Makefile
@@ -1,3 +1,10 @@
+DESTDIR ?=
+
+prefix ?= "/usr/local"
+exec_prefix	?=	"$(prefix)"
+libdir ?=	"$(exec_prefix)/lib"
+includedir?=	"$(exec_prefix)/include/uSockets"
+
 # WITH_OPENSSL=1 enables OpenSSL 1.1+ support
 ifeq ($(WITH_OPENSSL),1)
 	override CFLAGS += -DLIBUS_USE_OPENSSL
@@ -33,18 +40,31 @@ ifeq ($(WITH_ASAN),1)
 endif
 
 override CFLAGS += -std=c11 -Isrc
-override LDFLAGS += uSockets.a
 
-# By default we build the uSockets.a static library
-default:
+static:
 	rm -f *.o
-	$(CC) $(CFLAGS) -flto -O3 -c src/*.c src/eventing/*.c src/crypto/*.c
-	$(AR) rvs uSockets.a *.o
+	$(CC) $(CFLAGS) -c src/*.c src/eventing/*.c src/crypto/*.c
+	$(AR) rvs libusockets.a *.o
 
+default: static
+
+install:
+	# install the folders needed  (making sure that the exist)
+	install -d "$(DESTDIR)$(libdir)" \
+	"$(DESTDIR)$(includedir)/internal/eventing" \
+	"$(DESTDIR)$(includedir)/internal/networking"
+	# install static library
+	install -m 755 libusockets.a "$(DESTDIR)$(libdir)/"
+	# we also install all the header files
+	install  src/*.h "$(DESTDIR)$(includedir)/"
+	install -m 644 src/internal/*.h "$(DESTDIR)$(includedir)/internal/"
+	install -m 644 src/internal/eventing/*.h "$(DESTDIR)$(includedir)/internal/eventing/"
+	install -m 644 src/internal/networking/*.h "$(DESTDIR)$(includedir)/internal/networking/"
+
 # Builds all examples
 .PHONY: examples
 examples: default
-	for f in examples/*.c; do $(CC) -flto -O3 $(CFLAGS) -o $$(basename "$$f" ".c") "$$f" $(LDFLAGS); done
+	for f in examples/*.c; do $(CC) $(CFLAGS) -o $$(basename "$$f" ".c") "$$f" $(LDFLAGS); done
 
 swift_examples:
 	swiftc -O -I . examples/swift_http_server/main.swift uSockets.a -o swift_http_server
