Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganized source to be seperate from compiled objects #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
obj
bin
100 changes: 71 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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

#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
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.