Makefile 679 B

12345678910111213141516171819202122232425262728293031323334
  1. BIN_NAME := main
  2. CC = clang++
  3. SRC_POSTFIX := cc
  4. SRC_PATH := src
  5. BUILD_PATH := _build
  6. LIBS = gl glew glfw3
  7. CCFLAGS =
  8. LDFLAGS =
  9. rwildcard = $(foreach d, $(wildcard $1*), $(call rwildcard,$d/,$2) \
  10. $(filter $(subst *,%,$2), $d))
  11. CCFLAGS += `pkg-config --libs --cflags ${LIBS}`
  12. SOURCES := $(call rwildcard, $(SRC_PATH), *.$(SRC_POSTFIX))
  13. OBJECTS = $(SOURCES:$(SRC_PATH)/%.$(SRC_POSTFIX)=$(BUILD_PATH)/%.o)
  14. .PHONY: all build run clean dirs
  15. all: build
  16. build: dirs main
  17. ${BIN_NAME}: ${OBJECTS}
  18. ${CC} ${CCFLAGS} ${OBJECTS} -o $@
  19. ${BUILD_PATH}/%.o: ${SRC_PATH}/%.${SRC_POSTFIX}
  20. ${CC} ${LDFLAGS} -c $< -o $@
  21. dirs:
  22. mkdir -p $(dir ${OBJECTS})
  23. clean:
  24. rm -r ${BUILD_PATH}