123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- TARGET=demo
- # MacOS
- ifneq ("$(wildcard /Library/Frameworks/GLFW*)","")
- PACKAGE=MacOS
- CFLAGS=-I/Library/Frameworks/GLFW.framework/Headers -I/Library/Frameworks/GLFW.framework/Versions/A/Headers -D_MACOS_=1 -x objective-c -fobjc-exceptions
- LIBS=-F/Library/Frameworks -framework GLFW -framework GL -framework AppKit
- EXE=
- else
- ifneq ("$(wildcard glfw3/*)","")
- CFLAGS+=-I./glfw3/include
- EXTRA+=./glfw3/build/src/libglfw3.a
- LIBS+=-lGL
- else
- ifneq ("$(wildcard SDL3/*)","")
- CFLAGS+=-I./SDL3/include/SDL3 -I./SDL3/include
- EXTRA+=./SDL3/build/libSDL3.a
- ifneq ("$(wildcard /bin/*.exe)","")
- LIBS+=-lole32 -loleaut32 -lws2_32 -limm32 -lshlwapi -lwinmm -lsetupapi -lversion
- else
- LIBS+=-ldl -lpthread
- endif
- else
- ifneq ("$(wildcard SDL2/*)","")
- CFLAGS+=-I./SDL2/include
- EXTRA+=./SDL2/build/.libs/libSDL2.a
- ifneq ("$(wildcard /bin/*.exe)","")
- LIBS+=-lole32 -loleaut32 -lws2_32 -limm32 -lshlwapi -lwinmm -lsetupapi -lversion
- else
- LIBS+=-ldl -lpthread
- endif
- else
- ifeq ("$(wildcard /bin/*.exe)","")
- LIBS+=-lglfw
- endif
- endif
- endif
- endif
- # Windows MinGW
- ifneq ("$(wildcard /bin/*.exe)","")
- PACKAGE=Win
- LDFLAGS+=-mwindows -static-libgcc
- LIBS+=-Wl,--nxcompat -Wl,-Bstatic,--whole-archive -lwinpthread -lglfw3 -lglew32.dll -lopengl32 -Wl,--no-whole-archive
- LIBS+=-luser32 -lm
- EXE=.exe
- else
- # Linux
- PACKAGE=Linux
- LIBS+=-lGL -lm
- endif
- endif
- SRCS = $(filter-out ssfn.c,$(wildcard *.c))
- ifneq ($(wildcard ssfn.h),)
- SRCS+=ssfn.c
- endif
- OBJS = $(SRCS:.c=)
- ifneq ($(wildcard stb_image.h),)
- OBJS+=skin
- endif
- ifneq ($(wildcard /usr/include/SDL2/SDL.h),)
- OBJS+=sdldemo
- endif
- ifneq ($(wildcard /usr/include/X11/Xlib.h),)
- OBJS+=x11demo
- endif
- CFLAGS+=-ansi -Wall -Wextra -Wno-pragmas -ffunction-sections -I.. -I. -I../mods
- ifeq ($(DEBUG),)
- CFLAGS+=-O3 -ffast-math
- else
- CFLAGS+=-g -DDEBUG=1
- endif
- all: $(OBJS)
- ifneq ("$(wildcard glfw3/*)","")
- glfw3/build/src/libglfw3.a:
- ifeq ($(wildcard glfw3/build/Makefile),)
- @cd glfw3 && cmake -S . -B build -D GLFW_BUILD_EXAMPLES=OFF -D GLFW_BUILD_TESTS=OFF -D GLFW_BUILD_DOCS=0FF
- endif
- @make --no-print-directory -s -C glfw3/build all
- endif
- static-glfw3:
- git clone https://github.com/glfw/glfw.git
- mv glfw glfw3
- ifneq ("$(wildcard SDL2/*)","")
- SDL2/build/.libs/libSDL2.a:
- ifeq ($(wildcard SDL2/configure),)
- @cd SDL2 && ./autogen.sh
- endif
- ifeq ($(wildcard SDL2/Makefile),)
- @cd SDL2 && ./configure --disable-shared --enable-static --disable-dbus
- endif
- @make --no-print-directory -s -C SDL2 all
- endif
- static-sdl2:
- git clone --branch SDL2 https://github.com/libsdl-org/SDL.git
- mv SDL SDL2
- printf "#ifndef SDL_dynapi_h_\n#define SDL_dynapi_h_\n#define SDL_DYNAMIC_API 0\n#endif" >SDL2/src/dynapi/SDL_dynapi.h
- ifneq ("$(wildcard SDL3/*)","")
- SDL3/build/libSDL3.a:
- ifeq ($(wildcard SDL3/build/Makefile),)
- @cd SDL3 && mkdir build && cd build && cmake -S .. -B ../build && cmake . -DCMAKE_BUILD_TYPE=Release -DSDL_SHARED=false -DSDL_STATIC=true -DSDL_DBUS=false -DSDL_IBUS=false
- endif
- @make --no-print-directory -s -C SDL3/build all
- endif
- static-sdl3:
- git clone https://github.com/libsdl-org/SDL.git
- mv SDL SDL3
- %: %.c
- $(CC) $(CFLAGS) $< -c -o $@.o
- $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA) $(LIBS) -Wl,--gc-sections
- @rm $@.o
- skin: widgets.c
- $(CC) $(CFLAGS) -std=c99 -DSKIN=1 $< -c -o $@.o
- $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA) $(LIBS) -Wl,--gc-sections
- @rm $@.o
- sdldemo: demo.c
- $(CC) $(CFLAGS) -I/usr/include/SDL2 -include ui_sdl.h $< -c -o $@.o
- $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA) -lSDL2 -ldl -lpthread -lm -Wl,--gc-sections
- @rm $@.o
- x11demo: demo.c
- $(CC) $(CFLAGS) -I/usr/include/X11 -include ui_x11.h $< -c -o $@.o
- $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA) -lX11 -lXmu -lm -Wl,--gc-sections
- @rm $@.o
- clean:
- @rm $(OBJS) 2>/dev/null || true
- distclean: clean
- ifneq ("$(wildcard glfw3/*)","")
- @make --no-print-directory -s -C glfw3/build clean 2>/dev/null || true
- endif
- ifneq ("$(wildcard SDL2/*)","")
- @make --no-print-directory -s -C SDL2/build clean 2>/dev/null || true
- endif
- ifneq ("$(wildcard SDL3/*)","")
- @make --no-print-directory -s -C SDL3/build clean 2>/dev/null || true
- endif
|