ref: 5a81468b2ce44bc6755a376863c3f9dce2d55042
parent: 055f32333fe720302175f0eafc6f111f27923de3
author: liffy <629075+lifning@users.noreply.github.com>
date: Tue Aug 30 18:21:15 EDT 2022
improve linux/unix build (#4) Co-authored-by: lifning <> Co-authored-by: snesrev <111028570+snesrev@users.noreply.github.com>
--- a/.gitignore
+++ b/.gitignore
@@ -12,5 +12,7 @@
/tables/zelda3.sfc
/tables/zelda3.smc
/saves/*.sav
+/zelda3
/.vs/
__pycache__
+*.o
\ No newline at end of file
--- /dev/null
+++ b/Makefile
@@ -1,0 +1,30 @@
+# adapted from original README.md:
+# `clang++ -I/usr/include/SDL2 -lSDL2 -O2 -ozelda3 *.cpp snes/*.cpp`
+
+ifneq (,$(shell command -v clang++))
+ CXX = clang++
+else ifneq (,$(shell command -v g++))
+ CXX = g++
+endif
+
+ifneq (,$(findstring clang,$(CXX)))
+ LTO = -flto=thin
+else ifneq (,$(findstring g++,$(CXX)))
+ LTO = -flto=auto
+endif
+
+override CXXFLAGS := -O2 -I/usr/include/SDL2 $(LTO) $(CXXFLAGS)
+override LDFLAGS := -lSDL2 $(LDFLAGS)
+
+override OBJS = $(patsubst %.cpp,%.o,$(wildcard *.cpp snes/*.cpp))
+override BIN = zelda3
+
+.PHONY: all clean
+
+all: $(BIN)
+
+clean:
+ $(RM) $(BIN) $(OBJS)
+
+$(BIN): $(OBJS)
+ $(CXX) $(CXXFLAGS) -o $(BIN) $(OBJS) $(LDFLAGS)
--- a/README.md
+++ b/README.md
@@ -40,6 +40,9 @@
```
clang++ `sdl2-config --cflags` -O2 -ozelda3 *.cpp snes/*.cpp `sdl2-config --libs`
```
+or
+`make -j$(nproc)`
+
## Usage and controls