makefile 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #
  2. # CONFIGURATION GENERALE
  3. #
  4. EXEC = main test
  5. OBJETS = str.o json_parser.o json_encoder.o json_array.o error.o arraylist.o server_tcp.o server_udp.o bomberstudent_server.o client.o file.o handler.o player.o game.o delay.o object.o
  6. NOM_PROJET = Projet Reseau
  7. #
  8. # SUFFIXES
  9. #
  10. .SUFFIXES: .c .o
  11. #
  12. # OBJETS
  13. #
  14. EXEC_O = $(EXEC:=.o)
  15. OBJETS_O = $(OBJETS) $(EXEC_O)
  16. #
  17. # ARGUMENTS ET COMPILATEUR
  18. #
  19. CC = gcc
  20. CCFLAGS_STD = -Wall -O3 -Werror -ansi -pedantic -std=c11
  21. CCFLAGS_DEBUG = -D _DEBUG_
  22. CCFLAGS = $(CCFLAGS_STD)
  23. CCLIBS = -lm -pthread
  24. #
  25. # REGLES
  26. #
  27. all: msg $(OBJETS) $(EXEC_O)
  28. @echo "Creation des executables..."
  29. @for i in $(EXEC); do \
  30. $(CC) -o $$i $$i.o $(OBJETS) $(CCLIBS); \
  31. done
  32. @echo "Termine."
  33. msg:
  34. @echo "Creation des objets..."
  35. debug: CCFLAGS = $(CCFLAGS_STD) $(CCFLAGS_DEBUG)
  36. debug: all
  37. #
  38. # REGLES PAR DEFAUT
  39. #
  40. .c.o: .h
  41. @cd $(dir $<) && ${CC} ${CCFLAGS} -c $(notdir $<) -o $(notdir $@)
  42. #
  43. # REGLES GENERALES
  44. #
  45. clean:
  46. @echo "Suppresion des objets, des fichiers temporaires..."
  47. @rm -f $(OBJETS) $(EXEC_O)
  48. @rm -f *~ *#
  49. @rm -f $(EXEC)
  50. @rm -f dependances
  51. @rm -f *.log
  52. @echo "Termine."
  53. depend:
  54. @echo "Creation des dependances..."
  55. @sed -e "/^# DEPENDANCES/,$$ d" makefile > dependances
  56. @echo "# DEPENDANCES" >> dependances
  57. @for i in $(OBJETS_O); do \
  58. $(CC) -MM -MT $$i $(CCFLAGS) `echo $$i | sed "s/\(.*\)\\.o$$/\1.c/"` >> dependances; \
  59. done
  60. @cat dependances > makefile
  61. @rm dependances
  62. @echo "Termine."
  63. rmlog:
  64. @echo "Suppresion des fichiers de log"
  65. @rm -f *.log
  66. @echo "Termine."
  67. #
  68. # CREATION ARCHIVE
  69. #
  70. ARCHIVE_FILES = *
  71. archive: clean
  72. @echo "Creation de l'archive $(NOM_PROJET)$(shell date '+%y%m%d.tar.gz')..."
  73. @REP=`basename "$$PWD"`; cd .. && tar zcf $(NOM_PROJET)$(shell date '+%y%m%d.tar.gz') $(addprefix "$$REP"/,$(ARCHIVE_FILES))
  74. @echo "Termine."
  75. # DEPENDANCES
  76. str.o: str.c str.h
  77. json_parser.o: json_parser.c json.h str.h constante.h
  78. json_encoder.o: json_encoder.c json.h str.h constante.h
  79. json_array.o: json_array.c json.h str.h constante.h
  80. error.o: error.c str.h error.h
  81. arraylist.o: arraylist.c str.h arraylist.h constante.h server.h json.h
  82. server_tcp.o: server_tcp.c error.h server.h constante.h
  83. server_udp.o: server_udp.c error.h server.h constante.h
  84. bomberstudent_server.o: bomberstudent_server.c arraylist.h constante.h \
  85. server.h json.h str.h bomberstudent_server.h client.h error.h handler.h \
  86. game.h player.h
  87. client.o: client.c client.h constante.h server.h
  88. file.o: file.c error.h str.h file.h constante.h
  89. handler.o: handler.c error.h bomberstudent_server.h constante.h server.h \
  90. json.h str.h client.h player.h handler.h game.h
  91. player.o: player.c player.h constante.h client.h server.h json.h str.h
  92. game.o: game.c error.h str.h file.h constante.h game.h player.h client.h \
  93. server.h json.h bomberstudent_server.h
  94. delay.o: delay.c error.h delay.h constante.h game.h player.h client.h \
  95. server.h json.h str.h
  96. object.o: object.c object.h constante.h
  97. main.o: main.c error.h bomberstudent_server.h constante.h server.h json.h \
  98. str.h client.h main.h handler.h game.h player.h
  99. test.o: test.c json.h str.h constante.h arraylist.h server.h error.h \
  100. bomberstudent_server.h client.h file.h game.h player.h