makefile 763 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # project data
  2. NAME = climb_top
  3. VERSION = 0.1
  4. EXE = ${NAME}-${VERSION}
  5. # compiler flags
  6. CXXFLAGS = -Wall
  7. # linker flags
  8. SDL_LIB = -lSDL2 -lSDL2_image
  9. LDFLAGS = ${SDL_LIB}
  10. # engine
  11. ENGINE = engine/
  12. # files
  13. SRC = $(wildcard *.c)
  14. OBJ = ${SRC:.c=.o}
  15. HEADERS = $(wildcard ${ENGINE}*.h *.h)
  16. # default target
  17. all: ${EXE}
  18. ${EXE}: ${OBJ}
  19. ${MAKE} -C ${ENGINE}
  20. ${CC} $^ ${ENGINE}*.o ${LDFLAGS} -o $@
  21. # compile each file individually
  22. .c.o:
  23. ${CC} -c -o ${<:.c=.o} $< ${CXXFLAGS} -I ${ENGINE} -I .
  24. # all objects depend on all headers (for now)
  25. ${OBJ}: ${HEADERS}
  26. # remove all generated files
  27. clean:
  28. -rm -f ${OBJ} ${EXE}
  29. # remove all generated files, including from submodules
  30. clean_all:
  31. ${MAKE} -C ${ENGINE} clean
  32. -rm -rf ${OBJ} ${EXE}
  33. .PHONY: clean clean_all