diff options
-rw-r--r-- | Makefile | 70 | ||||
-rw-r--r-- | setup.mk | 5 | ||||
-rw-r--r-- | src/Makefile | 18 | ||||
-rw-r--r-- | src/threadpool.cpp | 6 | ||||
-rw-r--r-- | src/ui.cpp | 2 |
5 files changed, 49 insertions, 52 deletions
@@ -1,32 +1,38 @@ -LIBS = -lpthread -lGL -lGLEW -lSDL2 -lfreetype -lSDL2_image -lSDL2_mixer
-
-WIN_LIBS = -lopengl32 -lglew32 -lmingw32 -lSDL2main -lSDL2 -lSDL2_image -lSDL2_mixer -lfreetype
-
-FLAGS = -std=c++11 -Iinclude -Iinclude/freetype2 -Wall -Wextra -Werror
-
-MFLAGS64 = 64
-
-all:
- @echo "Building for 32-bit target"
- @rm -f out/*.o
- @cd src; $(MAKE) $(MFLAGS)
- @echo " CXX main.cpp"
- @g++ $(FLAGS) -m32 -o main main.cpp out/*.o $(LIBS) -lSDL2main
-
-64:
- @echo "Building for 64-bit target"
- @rm -f out64/*.o
- @cd src; $(MAKE) $(MFLAGS64)
- @echo " CXX main.cpp"
- @g++ $(FLAGS) -m64 -o main main.cpp out64/*.o $(LIBS)
-
-win32:
- @g++ $(FLAGS) -o main main.cpp src/*.cpp $(WIN_LIBS)
-
-clean:
- @echo " RM main"
- @-rm -f main
- @echo " RM out/*.o"
- @-rm -f out/*.o
- @echo " RM out64/*.o"
- @-rm -f out64/*.o
+include setup.mk + +CC = gcc +CXX = g++ + +ifeq ($(TARGET_OS),linux) + LIBS = -lpthread -lGL -lGLEW -lfreetype \ + -lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2main +endif +ifeq ($(TARGET_OS),win32) + LIBS = -lopengl32 -lglew32 -lmingw32 \ + -lSDL2main -lSDL2 -lSDL2_image -lSDL2_mixer -lfreetype +endif + +CXXFLAGS = -m$(TARGET_BITS) -std=c++11 +CXXINC = -Iinclude -Iinclude/freetype2 +CXXWARN = -Wall -Wextra -Werror + +CXXSRCDIR = src +CXXOUTDIR = out +CXXSRC = $(wildcard $(CXXSRCDIR)/*.cpp) +CXXOBJ = $(patsubst $(CXXSRCDIR)/%.cpp, $(CXXOUTDIR)/%.o, $(CXXSRC)) + +EXEC = main + +all: $(EXEC) + +clean: + rm -f $(EXEC) + rm -f out/*.o + +$(EXEC): $(CXXOUTDIR)/$(CXXOBJ) + @echo " CXX/LD main" + @$(CXX) $(CXXFLAGS) $(CXXINC) $(CXXWARN) -o $(EXEC) main.cpp out/*.o $(LIBS) + +$(CXXOUTDIR)/%.o: $(CXXSRCDIR)/%.cpp + @echo " CXX " $< + @$(CXX) $(CXXFLAGS) $(CXXINC) $(CXXWARN) $(LIBS) -c $< -o $@ diff --git a/setup.mk b/setup.mk new file mode 100644 index 0000000..89bb9c3 --- /dev/null +++ b/setup.mk @@ -0,0 +1,5 @@ +# Target OS, can be either 'linux' or 'win32' +TARGET_OS = linux + +# Bits setting, 32 or 64 +TARGET_BITS = 32 diff --git a/src/Makefile b/src/Makefile deleted file mode 100644 index 91743ef..0000000 --- a/src/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -LIBS = -lpthread -lGL -lSDL2 -lSDL2_image -lSDL2_mixer -lfreetype - -FLAGS = -std=c++11 -I../include -I../include/freetype2 -Wall -Wextra -Werror - -OUT = `echo "" $$(ls -c $(wildcard *.cpp)) | sed s/.cpp/.o/g | sed 's/ / ..\/out\//g'` -OUT64 = `echo "" $$(ls -c $(wildcard *.cpp)) | sed s/.cpp/.o/g | sed 's/ / ..\/out64\//g'` - -../out/%.o: - @echo " CXX " $(shell echo $@ | sed 's/..\/out\///g' | sed 's/\.o/\.cpp/') - @g++ $(FLAGS) -m32 -o $@ -c $(shell echo $@ | sed 's/..\/out\///g' | sed 's/\.o/\.cpp/') $(LIBS) -lSDL2main - -../out64/%.o: - @echo " CXX " $(shell echo $@ | sed 's/..\/out64\///g' | sed 's/\.o/\.cpp/') - @g++ $(FLAGS) -m64 -o $@ -c $(shell echo $@ | sed 's/..\/out64\///g' | sed 's/\.o/\.cpp/') $(LIBS) - -all: $(shell echo $(OUT)) - -64: $(shell echo $(OUT64)) diff --git a/src/threadpool.cpp b/src/threadpool.cpp index d49217d..619f002 100644 --- a/src/threadpool.cpp +++ b/src/threadpool.cpp @@ -1,5 +1,9 @@ #include "threadpool.h" +/** + * Stolen from some guy. + */ + // Constructor. ThreadPool::ThreadPool(int threads) : terminate(false), @@ -92,4 +96,4 @@ ThreadPool::~ThreadPool() { ShutDown(); } -}
\ No newline at end of file +} @@ -12,7 +12,7 @@ extern SDL_Window *window; /* * External references for updating player coords / current world. -*/ + */ extern Player *player; extern World *currentWorld; |