FLAGS=-fPIC --shared -Wall -Wextra

LINUX_FILES=src/openwindow.c deps/lib/glad_linux.a

WINDOWS_LIBS=-lopengl32 -lgdi32
WINDOWS_FILES=src/openwindow.c deps/lib/glad_windows.a

OUTPUT=lib/

all: libopenwindow.so libopenwindow.dll

libopenwindow.so: glad_linux.a
	mkdir -p ${OUTPUT}
	gcc ${FLAGS} -o ${OUTPUT}libopenwindow.so ${LINUX_FILES} -lX11 -lGLX -lOpenGL

libopenwindow.dll: glad_windows.a
	mkdir -p ${OUTPUT}
	x86_64-w64-mingw32-gcc ${FLAGS} -o ${OUTPUT}libopenwindow.dll ${WINDOWS_FILES} ${WINDOWS_LIBS}

GLAD_FLAGS=-fPIC -c
GLAD_FILES=deps/src/glad.c

glad_linux.a:   deps/src/glad.c
	gcc ${GLAD_FLAGS} -o deps/lib/glad_linux.o ${GLAD_FILES}
	ar rcs deps/lib/glad_linux.a deps/lib/glad_linux.o

glad_windows.a: deps/src/glad.c
	x86_64-w64-mingw32-gcc ${GLAD_FLAGS} -o deps/lib/glad_windows.o ${GLAD_FILES}
	ar rcs deps/lib/glad_windows.a deps/lib/glad_windows.o
