diff options
author | ancarola <raffaele.ancarola@epfl.ch> | 2018-11-17 22:46:15 +0100 |
---|---|---|
committer | ancarola <raffaele.ancarola@epfl.ch> | 2018-11-17 22:46:15 +0100 |
commit | ce7b39f47a1112941b3579f6502dd4e950cb099a (patch) | |
tree | 1d2a46f7dde690415302539c989f21067f270324 /makefile | |
download | flatland-ce7b39f47a1112941b3579f6502dd4e950cb099a.tar.gz flatland-ce7b39f47a1112941b3579f6502dd4e950cb099a.zip |
initialization
Diffstat (limited to 'makefile')
-rw-r--r-- | makefile | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/makefile b/makefile new file mode 100644 index 0000000..ff266b7 --- /dev/null +++ b/makefile @@ -0,0 +1,69 @@ +# Makefile for symkit 1.0 by Raffaele Ancarola +# C++ library for physics symulations + +NAME := flatland +BIN := bin/lib$(NAME).so +CC := g++ +CPP11 := -std=c++11 + +DIRS := engine +BACKUP := backup +INSTALL_DIR := /usr/lib + +INCLUDES := $(patsubst %,%/include,$(DIRS)) + +# other required libraries +LIBS := -lSDL2 #add libraries + +SRC := $(wildcard $(patsubst %,%/*.cpp,$(DIRS))) +OBJ := $(patsubst %.cpp,bin/%.o,$(SRC)) + +.PHONY: dirs clean install backup restore +all: $(BIN) + +# builds all binaries into the shared library + +$(BIN): dirs $(OBJ) + @printf "\nAssembling binaries\n\n" + $(CC) -shared -o $@ $(OBJ) -I $(INCLUDES) $(LIBS) $(CPP11) + @printf "\nCompilation successfully completed\n" + +# compile all sources + +$(OBJ): bin/%.o : %.cpp $(SRC) + @printf "\nCompiling $<\n" + $(CC) -c $< -fPIC -o $@ -I $(INCLUDES) $(LIBS) $(CPP11) + +# phony commands implementation + +# install the compiled library into your system +# be careful with this command because it could not work +install: + chmod +x install.sh + ./install.sh $(BIN) $(INSTALL_DIR) + +# generate all necessaries directories +dirs: + mkdir -p bin $(patsubst %,bin/%,$(DIRS)) + mkdir -p $(INCLUDES) $(BACKUP) + @printf "Default directories created\n" + +# clean all binaries +clean: + rm -rfv bin/* + @printf "Binary files cleaned\n" + +# backup the project in backup/symkit.zip +backup: + mkdir -p $(BACKUP) + rm -rfv $(BACKUP)/* + zip -r $(BACKUP)/symkit.zip $(DIRS) + @printf "Backup completed\n" + +# restore the last backup, backup/symkit.zip must be present +restore: + unzip $(BACKUP)/symkit.zip -d $(BACKUP) + rm -rfv $(DIRS) + mv $(patsubst %,$(BACKUP)/%,$(DIRS)) . + @printf "Backup restored\n" + |