makefile 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. ### variables ###
  2. #
  3. # project stats
  4. #
  5. PROJECT_NAME=avdl-cengine
  6. PROJECT_VERSION=1.0.0
  7. #
  8. # directories
  9. #
  10. #
  11. # SRC: source files directory
  12. # BUILD: compiled build directory (everything compiled belongs here)
  13. # OBJ: compiled objects directory
  14. # DIRECTORIES: directories that should be created if they don't exist
  15. #
  16. DIRECTORY_SRC=src
  17. DIRECTORY_BUILD=build
  18. DIRECTORY_OBJ=${DIRECTORY_BUILD}/objects
  19. DIRECTORIES=${DIRECTORY_BUILD} ${DIRECTORY_OBJ}
  20. #
  21. # source files
  22. #
  23. SRC=$(wildcard ${DIRECTORY_SRC}/*.c)
  24. OBJ=${SRC:${DIRECTORY_SRC}/%.c=${DIRECTORY_OBJ}/%.o}
  25. HEADERS=$(wildcard include/*.h)
  26. #
  27. # compiler flags
  28. #
  29. COMPILER_FLAGS=-Wall -Werror -Wpedantic
  30. #
  31. # output library
  32. #
  33. STATIC_OUT=${DIRECTORY_BUILD}/lib${PROJECT_NAME}.a
  34. #
  35. # install data
  36. #
  37. PREFIX=
  38. ### recipes ###
  39. #
  40. # compile the whole library
  41. #
  42. all: ${DIRECTORIES} ${STATIC_OUT}
  43. #
  44. # create static library
  45. #
  46. ${STATIC_OUT}: ${OBJ}
  47. ar rcs $@ $^
  48. #
  49. # make sure compiled build directories exist
  50. #
  51. ${DIRECTORIES}:
  52. mkdir $@
  53. #
  54. # compile source files to object files
  55. #
  56. ${DIRECTORY_OBJ}/%.o: ${DIRECTORY_SRC}/%.c ${HEADERS}
  57. ${CC} ${COMPILER_FLAGS} -Iinclude -DDD_PLATFORM_NATIVE -o $@ -c $<
  58. #
  59. # install library
  60. #
  61. install: ${STATIC_OUT}
  62. mkdir -p ${PREFIX}/usr/include
  63. install -m644 ${HEADERS} ${PREFIX}/usr/include
  64. mkdir -p ${PREFIX}/usr/lib
  65. install -m755 ${STATIC_OUT} ${PREFIX}/usr/lib
  66. #
  67. # clean working directory
  68. #
  69. clean:
  70. rm -r ${DIRECTORY_BUILD}
  71. #
  72. # phony recipes
  73. #
  74. .PHONY: clean