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