From 5c89de5526cc84d26de9181cd93deb8f7efdddd6 Mon Sep 17 00:00:00 2001 From: Josh Angolano Date: Mon, 3 Jul 2017 11:27:48 -0500 Subject: [PATCH] Reorganized source to be seperate from compiled objects --- .gitignore | 2 + Makefile | 100 ++++++++++++++++++------- endportal.png => res/endportal.png | Bin fire.png => res/fire.png | Bin style.css => res/style.css | 0 template.html => res/template.html | 0 blockimages.cpp => src/blockimages.cpp | 0 blockimages.h => src/blockimages.h | 0 chunk.cpp => src/chunk.cpp | 0 chunk.h => src/chunk.h | 0 map.cpp => src/map.cpp | 0 map.h => src/map.h | 0 pigmap.cpp => src/pigmap.cpp | 0 region.cpp => src/region.cpp | 0 region.h => src/region.h | 0 render.cpp => src/render.cpp | 0 render.h => src/render.h | 0 rgba.cpp => src/rgba.cpp | 0 rgba.h => src/rgba.h | 0 tables.cpp => src/tables.cpp | 0 tables.h => src/tables.h | 0 utils.cpp => src/utils.cpp | 0 utils.h => src/utils.h | 0 world.cpp => src/world.cpp | 0 world.h => src/world.h | 0 25 files changed, 73 insertions(+), 29 deletions(-) create mode 100644 .gitignore rename endportal.png => res/endportal.png (100%) rename fire.png => res/fire.png (100%) rename style.css => res/style.css (100%) rename template.html => res/template.html (100%) rename blockimages.cpp => src/blockimages.cpp (100%) rename blockimages.h => src/blockimages.h (100%) rename chunk.cpp => src/chunk.cpp (100%) rename chunk.h => src/chunk.h (100%) rename map.cpp => src/map.cpp (100%) rename map.h => src/map.h (100%) rename pigmap.cpp => src/pigmap.cpp (100%) rename region.cpp => src/region.cpp (100%) rename region.h => src/region.h (100%) rename render.cpp => src/render.cpp (100%) rename render.h => src/render.h (100%) rename rgba.cpp => src/rgba.cpp (100%) rename rgba.h => src/rgba.h (100%) rename tables.cpp => src/tables.cpp (100%) rename tables.h => src/tables.h (100%) rename utils.cpp => src/utils.cpp (100%) rename utils.h => src/utils.h (100%) rename world.cpp => src/world.cpp (100%) rename world.h => src/world.h (100%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7de5508 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +obj +bin diff --git a/Makefile b/Makefile index 946daf5..c6741a0 100644 --- a/Makefile +++ b/Makefile @@ -1,29 +1,71 @@ -objects = pigmap.o blockimages.o chunk.o map.o render.o region.o rgba.o tables.o utils.o world.o - -pigmap : $(objects) - g++ $(objects) -o pigmap -l z -l png -l pthread -O3 - -pigmap.o : pigmap.cpp blockimages.h chunk.h map.h render.h rgba.h tables.h utils.h world.h - g++ -c pigmap.cpp -O3 -blockimages.o : blockimages.cpp blockimages.h rgba.h utils.h - g++ -c blockimages.cpp -O3 -chunk.o : chunk.cpp chunk.h map.h region.h tables.h utils.h - g++ -c chunk.cpp -O3 -map.o : map.cpp map.h utils.h - g++ -c map.cpp -O3 -render.o : render.cpp blockimages.h chunk.h map.h render.h rgba.h tables.h utils.h - g++ -c render.cpp -O3 -region.o : region.cpp map.h region.h tables.h utils.h - g++ -c region.cpp -O3 -rgba.o : rgba.cpp rgba.h utils.h - g++ -c rgba.cpp -O3 -tables.o : tables.cpp map.h tables.h utils.h - g++ -c tables.cpp -O3 -utils.o : utils.cpp utils.h - g++ -c utils.cpp -O3 -world.o : world.cpp map.h region.h tables.h world.h - g++ -c world.cpp -O3 - -clean : - rm -f *.o pigmap - \ No newline at end of file +#Compiler and Linker +CC := g++ + +#The Target Binary Program +TARGET := pigmap + +#The Directories, Source, Includes, Objects, Binary and Resources +SRCDIR := src +INCDIR := inc +BUILDDIR := obj +TARGETDIR := bin +SRCEXT := cpp +DEPEXT := d +RESDIR := res +OBJEXT := o + +#Flags, Libraries and Includes +CFLAGS := -O3 -g +LIB := +INC := -I$(INCDIR) -I/usr/local/include +INCDEP := -I$(INCDIR) + +#--------------------------------------------------------------------------------- +#DO NOT EDIT BELOW THIS LINE +#--------------------------------------------------------------------------------- +SOURCES := $(shell find $(SRCDIR) -type f -name \*.$(SRCEXT)) +OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.$(OBJEXT))) + +#Defauilt Make +all: resources $(TARGET) + +#Remake +remake: cleaner all + +#Copy Resources from Resources Directory to Target Directory +resources: directories + @cp $(RESDIR)/* $(TARGETDIR)/ + +#Make the Directories +directories: + @mkdir -p $(TARGETDIR) + @mkdir -p $(BUILDDIR) + +#Clean only Objecst +clean: + @$(RM) -rf $(BUILDDIR) + +#Full Clean, Objects and Binaries +cleaner: clean + @$(RM) -rf $(TARGETDIR) + +#Pull in dependency info for *existing* .o files +-include $(OBJECTS:.$(OBJEXT)=.$(DEPEXT)) + +#Link +$(TARGET): $(OBJECTS) + $(CC) -o $(TARGETDIR)/$(TARGET) $^ $(LIB) -l z -l png -l pthread -O3^ + + +#Compile +$(BUILDDIR)/%.$(OBJEXT): $(SRCDIR)/%.$(SRCEXT) + @mkdir -p $(dir $@) + $(CC) $(CFLAGS) $(INC) -c -o $@ $< + @$(CC) $(CFLAGS) $(INCDEP) -MM $(SRCDIR)/$*.$(SRCEXT) > $(BUILDDIR)/$*.$(DEPEXT) + @cp -f $(BUILDDIR)/$*.$(DEPEXT) $(BUILDDIR)/$*.$(DEPEXT).tmp + @sed -e 's|.*:|$(BUILDDIR)/$*.$(OBJEXT):|' < $(BUILDDIR)/$*.$(DEPEXT).tmp > $(BUILDDIR)/$*.$(DEPEXT) + @sed -e 's/.*://' -e 's/\\$$//' < $(BUILDDIR)/$*.$(DEPEXT).tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $(BUILDDIR)/$*.$(DEPEXT) + @rm -f $(BUILDDIR)/$*.$(DEPEXT).tmp + +#Non-File Targets +.PHONY: all remake clean cleaner resources diff --git a/endportal.png b/res/endportal.png similarity index 100% rename from endportal.png rename to res/endportal.png diff --git a/fire.png b/res/fire.png similarity index 100% rename from fire.png rename to res/fire.png diff --git a/style.css b/res/style.css similarity index 100% rename from style.css rename to res/style.css diff --git a/template.html b/res/template.html similarity index 100% rename from template.html rename to res/template.html diff --git a/blockimages.cpp b/src/blockimages.cpp similarity index 100% rename from blockimages.cpp rename to src/blockimages.cpp diff --git a/blockimages.h b/src/blockimages.h similarity index 100% rename from blockimages.h rename to src/blockimages.h diff --git a/chunk.cpp b/src/chunk.cpp similarity index 100% rename from chunk.cpp rename to src/chunk.cpp diff --git a/chunk.h b/src/chunk.h similarity index 100% rename from chunk.h rename to src/chunk.h diff --git a/map.cpp b/src/map.cpp similarity index 100% rename from map.cpp rename to src/map.cpp diff --git a/map.h b/src/map.h similarity index 100% rename from map.h rename to src/map.h diff --git a/pigmap.cpp b/src/pigmap.cpp similarity index 100% rename from pigmap.cpp rename to src/pigmap.cpp diff --git a/region.cpp b/src/region.cpp similarity index 100% rename from region.cpp rename to src/region.cpp diff --git a/region.h b/src/region.h similarity index 100% rename from region.h rename to src/region.h diff --git a/render.cpp b/src/render.cpp similarity index 100% rename from render.cpp rename to src/render.cpp diff --git a/render.h b/src/render.h similarity index 100% rename from render.h rename to src/render.h diff --git a/rgba.cpp b/src/rgba.cpp similarity index 100% rename from rgba.cpp rename to src/rgba.cpp diff --git a/rgba.h b/src/rgba.h similarity index 100% rename from rgba.h rename to src/rgba.h diff --git a/tables.cpp b/src/tables.cpp similarity index 100% rename from tables.cpp rename to src/tables.cpp diff --git a/tables.h b/src/tables.h similarity index 100% rename from tables.h rename to src/tables.h diff --git a/utils.cpp b/src/utils.cpp similarity index 100% rename from utils.cpp rename to src/utils.cpp diff --git a/utils.h b/src/utils.h similarity index 100% rename from utils.h rename to src/utils.h diff --git a/world.cpp b/src/world.cpp similarity index 100% rename from world.cpp rename to src/world.cpp diff --git a/world.h b/src/world.h similarity index 100% rename from world.h rename to src/world.h