Makefile 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. ##### THESE ARE THE REQUIRED LIBRARIES:
  2. UNAME := $(shell uname)
  3. ifeq ($(UNAME), Linux)
  4. LIBS = -L ~/SLlibs/petsc/arch-linux2-c-opt/lib -l openblas -l petsc -l slepc
  5. INCL = -I ~/SLlibs/petsc/include/petsc/mpiuni -I ~/SLlibs/petsc/arch-linux2-c-opt/externalpackages/git.openblas -I ~/SLlibs/petsc/include/ -I ~/SLlibs/petsc/arch-linux2-c-opt/include/
  6. endif
  7. ifeq ($(UNAME), Darwin)
  8. LIBS = -L ~/SLlibs/petsc/arch-darwin-c-opt/lib -l openblas -l petsc -l slepc
  9. INCL = -I ~/SLlibs/petsc/include/petsc/mpiuni -I ~/SLlibs/petsc/arch-darwin-c-opt/externalpackages/git.openblas -I ~/SLlibs/petsc/include/ -I ~/SLlibs/petsc/arch-darwin-c-opt/include/
  10. endif
  11. # $@ is the filename representing the target.
  12. # $< is the filename of the first prerequisite.
  13. # $^ the filenames of all the prerequisites.
  14. # $(@D) is the file path of the target file.
  15. # D can be added to all of the above.
  16. CXX = g++ -fopenmp # openmp is used for parallel sorting on Linux
  17. CXX_FLAGS= -std=c++11 -O3 -Wno-return-type # Do not warn when not returning anything (e.g. in virtual functions)
  18. # List of all directories containing the headers:
  19. INCLUDES = -I src -I src/field -I src/expression -I src/expression/operation -I src/shapefunction -I src/formulation -I src/shapefunction/hierarchical -I src/shapefunction/hierarchical/h1 -I src/shapefunction/hierarchical/hcurl -I src/shapefunction/hierarchical/meca -I src/gausspoint -I src/shapefunction/lagrange -I src/mesh -I src/io -I src/io/gmsh -I src/io/paraview -I src/io/nastran -I src/resolution -I src/geometry
  20. # List of all .cpp source files:
  21. CPPS= $(wildcard src/*.cpp) $(wildcard src/field/*.cpp) $(wildcard src/expression/*.cpp) $(wildcard src/expression/operation/*.cpp) $(wildcard src/shapefunction/*.cpp) $(wildcard src/formulation/*.cpp) $(wildcard src/shapefunction/hierarchical/*.cpp) $(wildcard src/shapefunction/hierarchical/h1/*.cpp) $(wildcard src/shapefunction/hierarchical/meca/*.cpp) $(wildcard src/shapefunction/hierarchical/hcurl/*.cpp) $(wildcard src/gausspoint/*.cpp) $(wildcard src/shapefunction/lagrange/*.cpp) $(wildcard src/mesh/*.cpp) $(wildcard src/io/*.cpp) $(wildcard src/io/gmsh/*.cpp) $(wildcard src/io/paraview/*.cpp) $(wildcard src/io/nastran/*.cpp) $(wildcard src/resolution/*.cpp) $(wildcard src/geometry/*.cpp)
  22. # Final binary name:
  23. BIN = sparselizard
  24. # Put all generated stuff to this build directory:
  25. BUILD_DIR = ./build
  26. # Same list as CPP but with the .o object extension:
  27. OBJECTS=$(CPPS:%.cpp=$(BUILD_DIR)/%.o)
  28. # Gcc/Clang will create these .d files containing dependencies.
  29. DEP = $(OBJECTS:%.o=%.d)
  30. all: $(OBJECTS)
  31. # The main is always recompiled (it could have been replaced):
  32. $(CXX) $(CXX_FLAGS) $(LIBS) $(INCL) $(INCLUDES) -c main.cpp -o $(BUILD_DIR)/main.o
  33. # Linking objects:
  34. $(CXX) $(BUILD_DIR)/main.o $(OBJECTS) $(LIBS) -o $(BIN)
  35. # Include all .d files
  36. -include $(DEP)
  37. $(BUILD_DIR)/%.o: %.cpp
  38. # Create the folder of the current target in the build directory:
  39. mkdir -p $(@D)
  40. # Compile .cpp file. MMD creates the dependencies.
  41. $(CXX) $(CXX_FLAGS) $(LIBS) $(INCL) $(INCLUDES) -MMD -c $< -o $@
  42. clean :
  43. # Removes all files created.
  44. rm -rf $(BUILD_DIR)
  45. rm -f $(BIN)