]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
better make system
authorClyne Sullivan <tullivan99@gmail.com>
Wed, 2 Mar 2016 15:14:01 +0000 (10:14 -0500)
committerClyne Sullivan <tullivan99@gmail.com>
Wed, 2 Mar 2016 15:14:01 +0000 (10:14 -0500)
Makefile
setup.mk [new file with mode: 0644]
src/Makefile [deleted file]
src/threadpool.cpp
src/ui.cpp

index 81862c0df66f1db33ac01b1a3fee1ee422a82b7c..305d0d638eaff5b09d75a4302e175aadd457db6e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,32 +1,38 @@
-LIBS = -lpthread -lGL -lGLEW -lSDL2 -lfreetype -lSDL2_image -lSDL2_mixer\r
-\r
-WIN_LIBS = -lopengl32 -lglew32 -lmingw32 -lSDL2main -lSDL2 -lSDL2_image -lSDL2_mixer -lfreetype\r
-\r
-FLAGS = -std=c++11 -Iinclude -Iinclude/freetype2 -Wall -Wextra -Werror\r
-\r
-MFLAGS64 = 64\r
-\r
-all:\r
-       @echo "Building for 32-bit target"\r
-       @rm -f out/*.o\r
-       @cd src; $(MAKE) $(MFLAGS)\r
-       @echo "  CXX  main.cpp"\r
-       @g++ $(FLAGS) -m32 -o main main.cpp out/*.o $(LIBS) -lSDL2main\r
-\r
-64:\r
-       @echo "Building for 64-bit target"\r
-       @rm -f out64/*.o\r
-       @cd src; $(MAKE) $(MFLAGS64)\r
-       @echo "  CXX  main.cpp"\r
-       @g++ $(FLAGS) -m64 -o main main.cpp out64/*.o $(LIBS)\r
-\r
-win32:\r
-       @g++ $(FLAGS) -o main main.cpp src/*.cpp $(WIN_LIBS)\r
-\r
-clean:\r
-       @echo "  RM main"\r
-       @-rm -f main\r
-       @echo "  RM out/*.o"\r
-       @-rm -f out/*.o\r
-       @echo "  RM out64/*.o"\r
-       @-rm -f out64/*.o\r
+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 (file)
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 (file)
index 91743ef..0000000
+++ /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))
index d49217dbc4426e3ebf589449b470e4f50d0e4ef3..619f002cdbf4ffefa1a8049ba521ff00d7480a01 100644 (file)
@@ -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
+}
index 7029cd38ebd5a6c62caf3cc24edd2699957b9380..c755a59d0f1ad9f8cb72a9943db1b6611297a6f5 100644 (file)
@@ -12,7 +12,7 @@ extern SDL_Window *window;
 
 /*
  *     External references for updating player coords / current world.
-*/
+ */
 
 extern Player *player;
 extern World  *currentWorld;