aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2021-04-17 22:05:24 +0100
committerJuan J. Martinez <jjm@usebox.net>2021-04-17 22:05:24 +0100
commita5745813e442b66ae6eed30bba81d1b3dd5cf634 (patch)
treeb302db1780350dc44543b81d49bfc1b2d4dff6a8 /Makefile
downloadbeeper-int-zx-a5745813e442b66ae6eed30bba81d1b3dd5cf634.tar.gz
beeper-int-zx-a5745813e442b66ae6eed30bba81d1b3dd5cf634.zip
Initial public release
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile76
1 files changed, 76 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..1f5add0
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,76 @@
+# CONFIG
+IMGUI_DIR = $(HOME)/src/imgui
+IMGUI_FILE_DIALOG_DIR = $(HOME)/src/ImGuiFileDialog
+# END OF CONFIG
+
+TAG := $(shell git describe --abbrev=0 --tags ${TAG_COMMIT} 2>/dev/null || true)
+COMMIT := $(shell git rev-parse --short HEAD)
+DATE := $(shell git log -1 --format=%cd --date=format:"%Y%m%d")
+VERSION := $(TAG)
+
+ifeq ($(VERSION),)
+ VERSION := dev-$(COMMIT) ($(DATE))
+else
+ VERSION += ($(DATE))
+endif
+
+CFLAGS = -O2 -s -Wall `sdl2-config --cflags`
+CXXFLAGS = -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends -I$(IMGUI_FILE_DIALOG_DIR)
+CXXFLAGS += -O2 -s -Wall `sdl2-config --cflags` -DAPP_VERSION="\"$(VERSION)\""
+LIBS = -lGL -ldl `sdl2-config --libs`
+
+# cross-build for windows
+ifeq ($(CROSS_BUILD), Win) #LINUX
+ CC = i686-w64-mingw32-gcc
+ CXX = i686-w64-mingw32-g++
+ CFLAGS += -D__USE_MINGW_ANSI_STDIO
+ LIBS = -lgdi32 -lopengl32 -limm32 `sdl2-config --libs --static-libs` -static
+endif
+
+SOURCES = main.cpp sfx.c
+SOURCES += zymosis.c
+SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp
+SOURCES += $(IMGUI_DIR)/backends/imgui_impl_sdl.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl3.cpp
+SOURCES += $(IMGUI_FILE_DIALOG_DIR)/ImGuiFileDialog.cpp
+
+SOURCES += $(IMGUI_DIR)/examples/libs/gl3w/GL/gl3w.c
+CXXFLAGS += -I$(IMGUI_DIR)/examples/libs/gl3w -DIMGUI_IMPL_OPENGL_LOADER_GL3W
+
+BIN = sfxed
+OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
+
+all: $(BIN)
+
+%.o: %.c
+ $(CC) $(CFLAGS) $< -c -o $@
+
+%.o: %.cpp
+ $(CXX) $(CXXFLAGS) $< -c -o $@
+
+%.o:$(IMGUI_DIR)/%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:$(IMGUI_FILE_DIALOG_DIR)/%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:$(IMGUI_DIR)/backends/%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:$(IMGUI_DIR)/examples/libs/gl3w/GL/%.c
+ $(CC) $(CXXFLAGS) -c -o $@ $<
+
+%.o:$(IMGUI_DIR)/examples/libs/glad/src/%.c
+ $(CC) $(CXXFLAGS) -c -o $@ $<
+
+sfxed: $(OBJS)
+ $(CXX) $(OBJS) $(CXXFLAGS) $(LIBS) -o $@
+
+.PHONY: clean
+clean:
+ make -C player clean
+ rm -f $(BIN) $(OBJS) Makefile.deps
+
+Makefile.deps:
+ $(CXX) $(CXXFLAGS) -MM $(SOURCES) > Makefile.deps
+
+include Makefile.deps