From c2eb08bd5ef1dfc496fac5510d2419724ba32f80 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Mon, 26 May 2014 02:08:07 +1000 Subject: [PATCH] Restructured the common/ directory, and simplified the build process --- client/makefile | 10 ++---- client/scenes/makefile | 10 ++---- common/gameplay/makefile | 37 +++++++++++++++++++++++ common/{ => gameplay}/statistics.hpp | 0 common/graphics/makefile | 6 ---- common/makefile | 14 +++------ common/map/makefile | 8 +---- common/network/makefile | 8 +---- common/network/serial_packet.hpp | 2 +- common/script/makefile | 8 +---- common/ui/makefile | 6 ---- common/{ => utilities}/bbox.hpp | 0 common/{ => utilities}/config_utility.cpp | 0 common/{ => utilities}/config_utility.hpp | 0 common/{ => utilities}/frame_rate.hpp | 0 common/utilities/makefile | 37 +++++++++++++++++++++++ common/{ => utilities}/sql_utility.cpp | 0 common/{ => utilities}/sql_utility.hpp | 0 common/{ => utilities}/utility.cpp | 0 common/{ => utilities}/utility.hpp | 0 common/{ => utilities}/vector2.hpp | 0 makefile | 1 - server/makefile | 8 +---- 23 files changed, 88 insertions(+), 67 deletions(-) create mode 100644 common/gameplay/makefile rename common/{ => gameplay}/statistics.hpp (100%) rename common/{ => utilities}/bbox.hpp (100%) rename common/{ => utilities}/config_utility.cpp (100%) rename common/{ => utilities}/config_utility.hpp (100%) rename common/{ => utilities}/frame_rate.hpp (100%) create mode 100644 common/utilities/makefile rename common/{ => utilities}/sql_utility.cpp (100%) rename common/{ => utilities}/sql_utility.hpp (100%) rename common/{ => utilities}/utility.cpp (100%) rename common/{ => utilities}/utility.hpp (100%) rename common/{ => utilities}/vector2.hpp (100%) diff --git a/client/makefile b/client/makefile index 56a4184..e9c2091 100644 --- a/client/makefile +++ b/client/makefile @@ -1,17 +1,14 @@ #config -INCLUDES+=. scenes ../common ../common/graphics ../common/map ../common/network ../common/ui -LIBS+=libclient.a ../libcommon.a -lSDL_net -lwsock32 -liphlpapi -lmingw32 -lSDLmain -lSDL -llua -lsqlite3 +INCLUDES+=. scenes ../common ../common/gameplay ../common/graphics ../common/map ../common/network ../common/ui ../common/utilities +LIBS+=libclient.a ../libcommon.a -lSDL_net -lwsock32 -liphlpapi -lmingw32 -lSDLmain -lSDL -llua CXXFLAGS+=-std=c++11 -DDEBUG $(addprefix -I,$(INCLUDES)) -CFLAGS+=-DDEBUG $(addprefix -I,$(INCLUDES)) #source CXXSRC=$(wildcard *.cpp) -CSRC=$(wildcard *.c) #objects OBJDIR=obj OBJ+=$(addprefix $(OBJDIR)/,$(CXXSRC:.cpp=.o)) -OBJ+=$(addprefix $(OBJDIR)/,$(CSRC:.c=.o)) #output OUTDIR=../out @@ -35,9 +32,6 @@ $(OUTDIR): $(OBJDIR)/%.o: %.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< -$(OBJDIR)/%.o: %.c - $(CC) $(CFLAGS) -c -o $@ $< - clean: $(RM) *.o *.a *.exe diff --git a/client/scenes/makefile b/client/scenes/makefile index c0c815b..b436dff 100644 --- a/client/scenes/makefile +++ b/client/scenes/makefile @@ -1,17 +1,14 @@ #config -INCLUDES+=. .. ../../common ../../common/graphics ../../common/map ../../common/network ../../common/ui -LIBS+= +INCLUDES+=. .. ../../common ../../common/gameplay ../../common/graphics ../../common/map ../../common/network ../../common/ui ../../common/utilities +LIBS+=libclient.a ../libcommon.a -lSDL_net -lwsock32 -liphlpapi -lmingw32 -lSDLmain -lSDL -llua CXXFLAGS+=-std=c++11 -DDEBUG $(addprefix -I,$(INCLUDES)) -CFLAGS+=-DDEBUG $(addprefix -I,$(INCLUDES)) #source CXXSRC=$(wildcard *.cpp) -CSRC=$(wildcard *.c) #objects OBJDIR=obj OBJ+=$(addprefix $(OBJDIR)/,$(CXXSRC:.cpp=.o)) -OBJ+=$(addprefix $(OBJDIR)/,$(CSRC:.c=.o)) #output OUTDIR=.. @@ -34,9 +31,6 @@ $(OUTDIR): $(OBJDIR)/%.o: %.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< -$(OBJDIR)/%.o: %.c - $(CC) $(CFLAGS) -c -o $@ $< - clean: $(RM) *.o *.a *.exe diff --git a/common/gameplay/makefile b/common/gameplay/makefile new file mode 100644 index 0000000..e86cb16 --- /dev/null +++ b/common/gameplay/makefile @@ -0,0 +1,37 @@ +#config +INCLUDES+=. .. +LIBS+= +CXXFLAGS+=-std=c++11 -DDEBUG $(addprefix -I,$(INCLUDES)) + +#source +CXXSRC=$(wildcard *.cpp) + +#objects +OBJDIR=obj +OBJ+=$(addprefix $(OBJDIR)/,$(CXXSRC:.cpp=.o)) + +#output +OUTDIR=../.. +OUT=$(addprefix $(OUTDIR)/,libcommon.a) + +#targets +all: $(OBJ) $(OUT) + ar -crs $(OUT) $(OBJ) + +$(OBJ): | $(OBJDIR) + +$(OUT): | $(OUTDIR) + +$(OBJDIR): + mkdir $(OBJDIR) + +$(OUTDIR): + mkdir $(OUTDIR) + +$(OBJDIR)/%.o: %.cpp + $(CXX) $(CXXFLAGS) -c -o $@ $< + +clean: + $(RM) *.o *.a *.exe + +rebuild: clean all diff --git a/common/statistics.hpp b/common/gameplay/statistics.hpp similarity index 100% rename from common/statistics.hpp rename to common/gameplay/statistics.hpp diff --git a/common/graphics/makefile b/common/graphics/makefile index c1b2927..343f0f1 100644 --- a/common/graphics/makefile +++ b/common/graphics/makefile @@ -2,16 +2,13 @@ INCLUDES+=. .. ../map LIBS+= CXXFLAGS+=-std=c++11 -DDEBUG $(addprefix -I,$(INCLUDES)) -CFLAGS+=-DDEBUG $(addprefix -I,$(INCLUDES)) #source CXXSRC=$(wildcard *.cpp) -CSRC=$(wildcard *.c) #objects OBJDIR=obj OBJ+=$(addprefix $(OBJDIR)/,$(CXXSRC:.cpp=.o)) -OBJ+=$(addprefix $(OBJDIR)/,$(CSRC:.c=.o)) #output OUTDIR=../.. @@ -34,9 +31,6 @@ $(OUTDIR): $(OBJDIR)/%.o: %.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< -$(OBJDIR)/%.o: %.c - $(CC) $(CFLAGS) -c -o $@ $< - clean: $(RM) *.o *.a *.exe diff --git a/common/makefile b/common/makefile index 645ac13..3acd152 100644 --- a/common/makefile +++ b/common/makefile @@ -1,30 +1,29 @@ #config -INCLUDES+=. +INCLUDES+=. .. LIBS+= CXXFLAGS+=-std=c++11 -DDEBUG $(addprefix -I,$(INCLUDES)) -CFLAGS+=-DDEBUG $(addprefix -I,$(INCLUDES)) #source CXXSRC=$(wildcard *.cpp) -CSRC=$(wildcard *.c) #objects OBJDIR=obj OBJ+=$(addprefix $(OBJDIR)/,$(CXXSRC:.cpp=.o)) -OBJ+=$(addprefix $(OBJDIR)/,$(CSRC:.c=.o)) #output -OUTDIR=.. +OUTDIR=../.. OUT=$(addprefix $(OUTDIR)/,libcommon.a) #targets all: $(OBJ) $(OUT) ar -crs $(OUT) $(OBJ) + $(MAKE) -C gameplay $(MAKE) -C graphics $(MAKE) -C map - $(MAKE) -C script $(MAKE) -C network + $(MAKE) -C script $(MAKE) -C ui + $(MAKE) -C utilities $(OBJ): | $(OBJDIR) @@ -39,9 +38,6 @@ $(OUTDIR): $(OBJDIR)/%.o: %.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< -$(OBJDIR)/%.o: %.c - $(CC) $(CFLAGS) -c -o $@ $< - clean: $(RM) *.o *.a *.exe diff --git a/common/map/makefile b/common/map/makefile index c2cdfb3..1f25da1 100644 --- a/common/map/makefile +++ b/common/map/makefile @@ -1,17 +1,14 @@ #config -INCLUDES+=. .. ../graphics +INCLUDES+=. .. ../utilities LIBS+= CXXFLAGS+=-std=c++11 -DDEBUG $(addprefix -I,$(INCLUDES)) -CFLAGS+=-DDEBUG $(addprefix -I,$(INCLUDES)) #source CXXSRC=$(wildcard *.cpp) -CSRC=$(wildcard *.c) #objects OBJDIR=obj OBJ+=$(addprefix $(OBJDIR)/,$(CXXSRC:.cpp=.o)) -OBJ+=$(addprefix $(OBJDIR)/,$(CSRC:.c=.o)) #output OUTDIR=../.. @@ -34,9 +31,6 @@ $(OUTDIR): $(OBJDIR)/%.o: %.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< -$(OBJDIR)/%.o: %.c - $(CC) $(CFLAGS) -c -o $@ $< - clean: $(RM) *.o *.a *.exe diff --git a/common/network/makefile b/common/network/makefile index c1b2927..b5ac556 100644 --- a/common/network/makefile +++ b/common/network/makefile @@ -1,17 +1,14 @@ #config -INCLUDES+=. .. ../map +INCLUDES+=. .. ../gameplay ../map ../utilities LIBS+= CXXFLAGS+=-std=c++11 -DDEBUG $(addprefix -I,$(INCLUDES)) -CFLAGS+=-DDEBUG $(addprefix -I,$(INCLUDES)) #source CXXSRC=$(wildcard *.cpp) -CSRC=$(wildcard *.c) #objects OBJDIR=obj OBJ+=$(addprefix $(OBJDIR)/,$(CXXSRC:.cpp=.o)) -OBJ+=$(addprefix $(OBJDIR)/,$(CSRC:.c=.o)) #output OUTDIR=../.. @@ -34,9 +31,6 @@ $(OUTDIR): $(OBJDIR)/%.o: %.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< -$(OBJDIR)/%.o: %.c - $(CC) $(CFLAGS) -c -o $@ $< - clean: $(RM) *.o *.a *.exe diff --git a/common/network/serial_packet.hpp b/common/network/serial_packet.hpp index 8729674..1dd94a6 100644 --- a/common/network/serial_packet.hpp +++ b/common/network/serial_packet.hpp @@ -35,7 +35,7 @@ union SerialPacket { //types of packets - //TODO: readd the value definitions + //TODO: read the value definitions enum class Type { //default: there is something wrong NONE = 0, diff --git a/common/script/makefile b/common/script/makefile index c1b2927..7f9288d 100644 --- a/common/script/makefile +++ b/common/script/makefile @@ -1,17 +1,14 @@ #config -INCLUDES+=. .. ../map +INCLUDES+=. .. ../map ../utilities LIBS+= CXXFLAGS+=-std=c++11 -DDEBUG $(addprefix -I,$(INCLUDES)) -CFLAGS+=-DDEBUG $(addprefix -I,$(INCLUDES)) #source CXXSRC=$(wildcard *.cpp) -CSRC=$(wildcard *.c) #objects OBJDIR=obj OBJ+=$(addprefix $(OBJDIR)/,$(CXXSRC:.cpp=.o)) -OBJ+=$(addprefix $(OBJDIR)/,$(CSRC:.c=.o)) #output OUTDIR=../.. @@ -34,9 +31,6 @@ $(OUTDIR): $(OBJDIR)/%.o: %.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< -$(OBJDIR)/%.o: %.c - $(CC) $(CFLAGS) -c -o $@ $< - clean: $(RM) *.o *.a *.exe diff --git a/common/ui/makefile b/common/ui/makefile index c2cdfb3..95166fd 100644 --- a/common/ui/makefile +++ b/common/ui/makefile @@ -2,16 +2,13 @@ INCLUDES+=. .. ../graphics LIBS+= CXXFLAGS+=-std=c++11 -DDEBUG $(addprefix -I,$(INCLUDES)) -CFLAGS+=-DDEBUG $(addprefix -I,$(INCLUDES)) #source CXXSRC=$(wildcard *.cpp) -CSRC=$(wildcard *.c) #objects OBJDIR=obj OBJ+=$(addprefix $(OBJDIR)/,$(CXXSRC:.cpp=.o)) -OBJ+=$(addprefix $(OBJDIR)/,$(CSRC:.c=.o)) #output OUTDIR=../.. @@ -34,9 +31,6 @@ $(OUTDIR): $(OBJDIR)/%.o: %.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< -$(OBJDIR)/%.o: %.c - $(CC) $(CFLAGS) -c -o $@ $< - clean: $(RM) *.o *.a *.exe diff --git a/common/bbox.hpp b/common/utilities/bbox.hpp similarity index 100% rename from common/bbox.hpp rename to common/utilities/bbox.hpp diff --git a/common/config_utility.cpp b/common/utilities/config_utility.cpp similarity index 100% rename from common/config_utility.cpp rename to common/utilities/config_utility.cpp diff --git a/common/config_utility.hpp b/common/utilities/config_utility.hpp similarity index 100% rename from common/config_utility.hpp rename to common/utilities/config_utility.hpp diff --git a/common/frame_rate.hpp b/common/utilities/frame_rate.hpp similarity index 100% rename from common/frame_rate.hpp rename to common/utilities/frame_rate.hpp diff --git a/common/utilities/makefile b/common/utilities/makefile new file mode 100644 index 0000000..e86cb16 --- /dev/null +++ b/common/utilities/makefile @@ -0,0 +1,37 @@ +#config +INCLUDES+=. .. +LIBS+= +CXXFLAGS+=-std=c++11 -DDEBUG $(addprefix -I,$(INCLUDES)) + +#source +CXXSRC=$(wildcard *.cpp) + +#objects +OBJDIR=obj +OBJ+=$(addprefix $(OBJDIR)/,$(CXXSRC:.cpp=.o)) + +#output +OUTDIR=../.. +OUT=$(addprefix $(OUTDIR)/,libcommon.a) + +#targets +all: $(OBJ) $(OUT) + ar -crs $(OUT) $(OBJ) + +$(OBJ): | $(OBJDIR) + +$(OUT): | $(OUTDIR) + +$(OBJDIR): + mkdir $(OBJDIR) + +$(OUTDIR): + mkdir $(OUTDIR) + +$(OBJDIR)/%.o: %.cpp + $(CXX) $(CXXFLAGS) -c -o $@ $< + +clean: + $(RM) *.o *.a *.exe + +rebuild: clean all diff --git a/common/sql_utility.cpp b/common/utilities/sql_utility.cpp similarity index 100% rename from common/sql_utility.cpp rename to common/utilities/sql_utility.cpp diff --git a/common/sql_utility.hpp b/common/utilities/sql_utility.hpp similarity index 100% rename from common/sql_utility.hpp rename to common/utilities/sql_utility.hpp diff --git a/common/utility.cpp b/common/utilities/utility.cpp similarity index 100% rename from common/utility.cpp rename to common/utilities/utility.cpp diff --git a/common/utility.hpp b/common/utilities/utility.hpp similarity index 100% rename from common/utility.hpp rename to common/utilities/utility.hpp diff --git a/common/vector2.hpp b/common/utilities/vector2.hpp similarity index 100% rename from common/vector2.hpp rename to common/utilities/vector2.hpp diff --git a/makefile b/makefile index 3315bc2..27fd80e 100644 --- a/makefile +++ b/makefile @@ -1,4 +1,3 @@ -#TODO: The build process needs revising #for use on Windows: #MKDIR=mkdir diff --git a/server/makefile b/server/makefile index 9686a1c..5bfd158 100644 --- a/server/makefile +++ b/server/makefile @@ -1,17 +1,14 @@ #config -INCLUDES+=. ../common ../common/map ../common/script ../common/network +INCLUDES+=. ../common ../common/gameplay ../common/map ../common/network ../common/script ../common/utilities LIBS+=../libcommon.a -lSDL_net -lwsock32 -liphlpapi -lmingw32 -lSDLmain -lSDL -llua -lsqlite3 CXXFLAGS+=-std=c++11 -DDEBUG $(addprefix -I,$(INCLUDES)) -CFLAGS+=-DDEBUG $(addprefix -I,$(INCLUDES)) #source CXXSRC=$(wildcard *.cpp) -CSRC=$(wildcard *.c) #objects OBJDIR=obj OBJ+=$(addprefix $(OBJDIR)/,$(CXXSRC:.cpp=.o)) -OBJ+=$(addprefix $(OBJDIR)/,$(CSRC:.c=.o)) #output OUTDIR=../out @@ -34,9 +31,6 @@ $(OUTDIR): $(OBJDIR)/%.o: %.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< -$(OBJDIR)/%.o: %.c - $(CC) $(CFLAGS) -c -o $@ $< - clean: $(RM) *.o *.a *.exe