diff --git a/demo/glfw/Makefile b/demo/glfw/Makefile index 16dc58b..53299f3 100644 --- a/demo/glfw/Makefile +++ b/demo/glfw/Makefile @@ -11,6 +11,13 @@ CFLAGS = -std=c89 -pedantic SRC = ../../zahnrad.c glfw.c OBJ = $(SRC:.c=.o) +ifeq ($(OS),Windows_NT) +BIN := $(BIN).exe +LIBS = -lglfw3 -lopengl32 -lm -lGLU32 -lGLEW32 +else +LIBS = -lglfw -lGL -lm -lGLU -lGLEW +endif + # Modes .PHONY: clang clang: CC = clang @@ -23,4 +30,4 @@ gcc: $(BIN) $(BIN): @mkdir -p bin rm -f bin/$(BIN) $(OBJS) - $(CC) $(SRC) $(CFLAGS) -o bin/$(BIN) -lglfw -lGL -lm -lGLU -lGLEW + $(CC) $(SRC) $(CFLAGS) -o bin/$(BIN) $(LIBS) diff --git a/demo/nanovg/Makefile b/demo/nanovg/Makefile index 0d8eeb2..c7dce5a 100644 --- a/demo/nanovg/Makefile +++ b/demo/nanovg/Makefile @@ -10,6 +10,13 @@ CFLAGS = -std=c99 SRC = nanovg.c ../../zahnrad.c OBJ = $(SRC:.c=.o) +ifeq ($(OS),Windows_NT) +BIN := $(BIN).exe +LIBS = -lmingw32 -lSDL2main -lSDL2 -lopengl32 -lm -lGLU32 -lGLEW32 +else +LIBS = -lSDL2 -lGL -lm -lGLU -lGLEW +endif + # Modes .PHONY: clang clang: CC = clang @@ -22,4 +29,4 @@ gcc: $(BIN) $(BIN): @mkdir -p bin rm -f bin/$(BIN) $(OBJS) - $(CC) $(SRC) $(CFLAGS) -o bin/$(BIN) -lSDL2 -lGL -lm -lGLU -lGLEW + $(CC) $(SRC) $(CFLAGS) -o bin/$(BIN) $(LIBS) diff --git a/demo/sdl/Makefile b/demo/sdl/Makefile index e0d64c8..cbf837f 100644 --- a/demo/sdl/Makefile +++ b/demo/sdl/Makefile @@ -11,6 +11,13 @@ CFLAGS = -std=c89 -pedantic SRC = ../../zahnrad.c sdl.c OBJ = $(SRC:.c=.o) +ifeq ($(OS),Windows_NT) +BIN := $(BIN).exe +LIBS = -lmingw32 -lSDL2main -lSDL2 -lopengl32 -lm -lGLU32 -lGLEW32 +else +LIBS = -lSDL2 -lGL -lm -lGLU -lGLEW +endif + # Modes .PHONY: clang clang: CC = clang @@ -23,4 +30,4 @@ gcc: $(BIN) $(BIN): @mkdir -p bin rm -f bin/$(BIN) $(OBJS) - $(CC) $(SRC) $(CFLAGS) -o bin/$(BIN) -lSDL2 -lGL -lm -lGLU -lGLEW + $(CC) $(SRC) $(CFLAGS) -o bin/$(BIN) $(LIBS) diff --git a/demo/win32/make.bat b/demo/win32/make-msvc.bat similarity index 100% rename from demo/win32/make.bat rename to demo/win32/make-msvc.bat diff --git a/demo/win32/win32.c b/demo/win32/win32.c index 4ed5a67..1f476d2 100644 --- a/demo/win32/win32.c +++ b/demo/win32/win32.c @@ -11,6 +11,9 @@ #include #include #include +#if defined(__MINGW32__) || defined(__MINGW64__) +# include +#endif /* macros */ #include "../../zahnrad.h" diff --git a/example/demo/Makefile b/example/demo/Makefile index 1bec73b..2cd51d9 100644 --- a/example/demo/Makefile +++ b/example/demo/Makefile @@ -9,6 +9,13 @@ CFLAGS = -std=c99 SRC = demo.c ../../zahnrad.c OBJ = $(SRC:.c=.o) +ifeq ($(OS),Windows_NT) +BIN := $(BIN).exe +LIBS = -lmingw32 -lSDL2main -lSDL2 -lopengl32 -lm -lGLU32 -lGLEW32 +else +LIBS = -lSDL2 -lGL -lm -lGLU -lGLEW +endif + # Modes .PHONY: clang clang: CC = clang @@ -21,5 +28,5 @@ gcc: $(BIN) $(BIN): @mkdir -p bin rm -f bin/$(BIN) $(OBJS) - $(CC) $(SRC) $(CFLAGS) -o bin/$(BIN) -lSDL2 -lGL -lm -lGLU -lGLEW + $(CC) $(SRC) $(CFLAGS) -o bin/$(BIN) $(LIBS) diff --git a/example/filex/Makefile b/example/filex/Makefile index 91635ca..359a3ef 100644 --- a/example/filex/Makefile +++ b/example/filex/Makefile @@ -17,6 +17,13 @@ CFLAGS += -Wswitch-enum -Winvalid-pch -Wbad-function-cast -fno-omit-frame-pointe SRC = filex.c ../../zahnrad.c OBJ = $(SRC:.c=.o) +ifeq ($(OS),Windows_NT) +BIN := $(BIN).exe +LIBS = -lmingw32 -lSDL2main -lSDL2 -lopengl32 -lm -lGLU32 -lGLEW32 +else +LIBS = -lSDL2 -lGL -lm -lGLU -lGLEW +endif + # Modes .PHONY: clang clang: CC = clang @@ -29,4 +36,4 @@ gcc: $(BIN) $(BIN): @mkdir -p bin rm -f bin/$(BIN) $(OBJS) - $(CC) $(SRC) $(CFLAGS) -D_POSIX_C_SOURCE=200809L -o bin/$(BIN) -lSDL2 -lGL -lm -lGLU -lGLEW + $(CC) $(SRC) $(CFLAGS) -D_POSIX_C_SOURCE=200809L -o bin/$(BIN) $(LIBS) diff --git a/example/filex/filex.c b/example/filex/filex.c index 0f53afe..c460a29 100644 --- a/example/filex/filex.c +++ b/example/filex/filex.c @@ -25,16 +25,14 @@ #include #include -#ifdef _WIN32 -#error "windows is not supported" -#else #include #include #include #include #include #include -#include +#ifndef _WIN32 +# include #endif #include @@ -430,6 +428,9 @@ file_browser_init(struct file_browser *browser, NVGcontext *vg, { /* load files and sub-directory list */ const char *home = getenv("HOME"); +#ifdef _WIN32 + if (!home) home = getenv("USERPROFILE"); +#else if (!home) home = getpwuid(getuid())->pw_dir; { size_t l; @@ -438,6 +439,7 @@ file_browser_init(struct file_browser *browser, NVGcontext *vg, strcpy(browser->home + l, "/"); strcpy(browser->directory, browser->home); } +#endif { size_t l; strcpy(browser->desktop, browser->home); diff --git a/example/nodedit/Makefile b/example/nodedit/Makefile index 1cf8993..edd4c7d 100644 --- a/example/nodedit/Makefile +++ b/example/nodedit/Makefile @@ -10,6 +10,13 @@ CFLAGS = -std=c99 -pedantic SRC = nodedit.c ../../zahnrad.c OBJ = $(SRC:.c=.o) +ifeq ($(OS),Windows_NT) +BIN := $(BIN).exe +LIBS = -lmingw32 -lSDL2main -lSDL2 -lopengl32 -lm -lGLU32 -lGLEW32 +else +LIBS = -lSDL2 -lGL -lm -lGLU -lGLEW +endif + # Modes .PHONY: clang clang: CC = clang @@ -22,4 +29,4 @@ gcc: $(BIN) $(BIN): @mkdir -p bin rm -f bin/$(BIN) $(OBJS) - $(CC) $(SRC) $(CFLAGS) -o bin/$(BIN) -lSDL2 -lGL -lm -lGLU -lGLEW + $(CC) $(SRC) $(CFLAGS) -o bin/$(BIN) $(LIBS)