Makefile 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. UNAME := $(shell uname)
  2. ifeq ($(UNAME), Linux)
  3. # With or without the GMSH API:
  4. ifneq ("$(wildcard ~/SLlibs/gmsh)","")
  5. LIBS = -L ~/SLlibs/petsc/arch-linux2-c-opt/lib -l openblas -l petsc -l slepc -L ~/SLlibs/gmsh/lib -l gmsh -D HAVE_GMSHAPI
  6. 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/ -I ~/SLlibs/gmsh/include
  7. else
  8. LIBS = -L ~/SLlibs/petsc/arch-linux2-c-opt/lib -l openblas -l petsc -l slepc
  9. 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/
  10. endif
  11. endif
  12. ifeq ($(UNAME), Darwin)
  13. LIBS = -L ~/SLlibs/petsc/arch-darwin-c-opt/lib -l openblas -l petsc -l slepc
  14. 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/
  15. endif
  16. # $@ is the filename representing the target.
  17. # $< is the filename of the first prerequisite.
  18. # $^ the filenames of all the prerequisites.
  19. # $(@D) is the file path of the target file.
  20. # D can be added to all of the above.
  21. CXX = g++ -fopenmp -fPIC -no-pie # openmp is used for parallel sorting on Linux
  22. CXX_FLAGS= -std=c++11 -O3 -Wno-return-type # Do not warn when not returning anything (e.g. in virtual functions)
  23. # List of all directories containing the headers:
  24. 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
  25. # List of all .cpp source files:
  26. 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)
  27. # Final binary name:
  28. BIN = sparselizard
  29. # Put all generated stuff to this build directory:
  30. BUILD_DIR = ./build
  31. # Same list as CPP but with the .o object extension:
  32. OBJECTS=$(CPPS:%.cpp=$(BUILD_DIR)/%.o)
  33. # Gcc/Clang will create these .d files containing dependencies.
  34. DEP = $(OBJECTS:%.o=%.d)
  35. all: $(OBJECTS) libsparselizard.so
  36. # The main is always recompiled (it could have been replaced):
  37. $(CXX) $(CXX_FLAGS) $(LIBS) $(INCL) $(INCLUDES) -c main.cpp -o $(BUILD_DIR)/main.o
  38. # Linking objects:
  39. $(CXX) $(BUILD_DIR)/main.o $(OBJECTS) $(LIBS) -o $(BIN)
  40. # Include all .d files
  41. -include $(DEP)
  42. $(BUILD_DIR)/%.o: %.cpp
  43. # Create the folder of the current target in the build directory:
  44. mkdir -p $(@D)
  45. # Compile .cpp file. MMD creates the dependencies.
  46. $(CXX) $(CXX_FLAGS) $(LIBS) $(INCL) $(INCLUDES) -MMD -c $< -o $@
  47. clean :
  48. # Removes all files created.
  49. rm -rf $(BUILD_DIR)
  50. rm -f $(BIN)
  51. rm -f libsparselizard.so
  52. # Make shared library
  53. LDFLAGS= -shared
  54. libsparselizard.so : $(OBJECTS)
  55. $(CXX) $(CXX_FLAGS) $(OBJECTS) -o $@ $(LDFLAGS)