Eolisation de l'applicatif MSE

eole.mk 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. #
  2. # NE PAS EDITER CE FICHIER
  3. #
  4. # Utiliser <appli>.mk à inclure à la fin de Makefile
  5. #################
  6. # Sanity checks #
  7. #################
  8. ifeq (, $(DESTDIR))
  9. $(warning $$(DESTDIR) is empty, installation will be done in /)
  10. endif
  11. ifeq (, $(filter-out XXX-XXX, $(strip $(SOURCE))))
  12. $(error $$(SOURCE) variable has incorrect value '$(SOURCE)')
  13. endif
  14. #########################
  15. # Variables definitions #
  16. #########################
  17. INSTALL := install
  18. INSTALL_DATA := install -m 644
  19. INSTALL_PROGRAM := install -m 755
  20. INSTALL_DIRECTORY := install -m 755 -d
  21. INSTALL_RECURSIVE := cp -dr --no-preserve=ownership
  22. # Base
  23. eole_DIR := $(DESTDIR)/usr/share/eole
  24. ifeq ($(strip $(EOLE_VERSION)), 2.3)
  25. diagnose_PROG_DIR := $(eole_DIR)/diagnose/module
  26. else
  27. diagnose_PROG_DIR := $(eole_DIR)/diagnose/
  28. endif
  29. # Creole
  30. creole_DIR := $(eole_DIR)/creole
  31. dicos_DATA_DIR := $(creole_DIR)/dicos
  32. tmpl_DATA_DIR := $(creole_DIR)/distrib
  33. pretemplate_PROG_DIR := $(eole_DIR)/pretemplate
  34. posttemplate_PROG_DIR := $(eole_DIR)/posttemplate
  35. postservice_PROG_DIR := $(eole_DIR)/postservice
  36. firewall_DATA_DIR := $(eole_DIR)/firewall
  37. bacula_restore_DATA_DIR := $(eole_DIR)/bacula/restore
  38. bacula_fichier_DATA_DIR := $(DESTDIR)/etc/bacula/baculafichiers.d
  39. schedule_pre_PROG_DIR := $(eole_DIR)/schedule/pre
  40. schedule_post_PROG_DIR := $(eole_DIR)/schedule/post
  41. extra_REC_DIR := $(creole_DIR)/extra
  42. # Zéphir
  43. zephir_DATA_DIR := $(DESTDIR)/usr/share/zephir
  44. zephir_configs_DATA_DIR := $(zephir_DATA_DIR)/monitor/configs
  45. zephir_srv_DATA_DIR := $(zephir_configs_DATA_DIR)/services
  46. # SSO
  47. sso_DATA_DIR := $(DESTDIR)/usr/share/sso
  48. sso_filtres_DATA_DIR := $(sso_DATA_DIR)/app_filters
  49. sso_user-info_DATA_DIR := $(sso_DATA_DIR)/user_infos
  50. # EAD
  51. ead_DATA_DIR := $(DESTDIR)/usr/share/ead2/backend/config
  52. ead_actions_DATA_DIR := $(ead_DATA_DIR)/actions
  53. ead_perms_DATA_DIR := $(ead_DATA_DIR)/perms
  54. ead_roles_DATA_DIR := $(ead_DATA_DIR)/roles
  55. # Program libraries goes under /usr/lib/<PROGRAM>/
  56. lib_$(SOURCE)_DATA_DIR := $(DESTDIR)/usr/lib/$(SOURCE)
  57. # Scripts Eole
  58. scripts_PROG_DIR := $(eole_DIR)/sbin
  59. lib_eole_DATA_DIR := $(DESTDIR)/usr/lib/eole
  60. # LDAP
  61. ldap_passwords_DATA_DIR := $(eole_DIR)/annuaire/password_files
  62. # LXC
  63. lxc_DATA_DIR := $(eole_DIR)/lxc
  64. lxc_fstab_DATA_DIR := $(lxc_DATA_DIR)/fstab
  65. lxc_hosts_DATA_DIR := $(lxc_DATA_DIR)/hosts
  66. # SQL
  67. sql_DATA_DIR := $(eole_DIR)/mysql/$(SOURCE)
  68. sql_gen_DATA_DIR := $(sql_DATA_DIR)/gen
  69. sql_updates_DATA_DIR := $(sql_DATA_DIR)/updates
  70. sql_conf_gen_DATA_DIR := $(eole_DIR)/applications/gen
  71. sql_conf_passwords_DATA_DIR := $(eole_DIR)/applications/passwords
  72. sql_conf_updates_DATA_DIR := $(eole_DIR)/applications/updates/$(SOURCE)
  73. # Certifs
  74. certs_DATA_DIR := $(eole_DIR)/certs
  75. # Logrotate
  76. logrotate_DATA_DIR := $(DESTDIR)/etc/logrotate.d
  77. # Python modules
  78. ifneq ($(DESTDIR),)
  79. PYTHON_OPTS := --root $(DESTDIR)
  80. endif
  81. #############################################
  82. # Common directories and files installation #
  83. #############################################
  84. all:
  85. install:: install-dirs install-files
  86. # $1 = command to run
  87. # $2 = source directory
  88. # $3 = destination directory
  89. define fc_install_file
  90. if [ -d $2 ]; then \
  91. for file in `ls -1 $2/`; do \
  92. $1 $2/$$file $3 || true; \
  93. done; \
  94. fi
  95. endef
  96. ##
  97. ## Directory creation
  98. ##
  99. # use % to catch local name in $*
  100. # data, program and recursive directory require a corresponding
  101. # directory in local sources
  102. %_DATA_DIR %_PROG_DIR %REC_DIR:
  103. test ! -d $(subst _,/,$*) || $(INSTALL_DIRECTORY) $($@)
  104. # Create the directory referenced by the variable without a local one.
  105. %_DIR:
  106. $(INSTALL_DIRECTORY) $($@)
  107. ##
  108. ## Install files present directly under data, program and recursive directories
  109. ##
  110. # $* : name of variable
  111. # $($*): value of variable
  112. %-instdata:
  113. $(call fc_install_file, $(INSTALL_DATA), $(subst _,/,$(subst _DATA_DIR,,$*)), $($*))
  114. %-instprog:
  115. $(call fc_install_file, $(INSTALL_PROGRAM), $(subst _,/,$(subst _PROG_DIR,,$*)), $($*))
  116. %-instrec:
  117. $(call fc_install_file, $(INSTALL_RECURSIVE), $(subst _,/,$(subst _REC_DIR,,$*)), $($*))
  118. # Use second expansion as variables may be created in included
  119. # Makefiles
  120. .SECONDEXPANSION:
  121. # List of all directories
  122. installdirs_LIST = $(foreach V, $(filter %_DIR, $(.VARIABLES)), \
  123. $(if $(filter file, $(origin $(V))), \
  124. $(V)))
  125. # List of data directories
  126. installdata_LIST = $(filter %_DATA_DIR, $(installdirs_LIST))
  127. # List of program directories
  128. installprog_LIST = $(filter %_PROG_DIR, $(installdirs_LIST))
  129. # List of recursive directories
  130. installrec_LIST = $(filter %_REC_DIR, $(installdirs_LIST))
  131. # Expand directories to create as dependency
  132. # Use double-colon to permit user to define additionnal install-dirs
  133. install-dirs:: $$(installdirs_LIST)
  134. # Expand files to install as dependency
  135. # Use double-colon to permit user to define additionnal install-files
  136. install-files:: install-data-files install-prog-files install-rec-dirs
  137. install-data-files: $$(patsubst %,%-instdata,$$(installdata_LIST))
  138. install-prog-files: $$(patsubst %,%-instprog,$$(installprog_LIST))
  139. install-rec-dirs: $$(patsubst %,%-instrec,$$(installrec_LIST))
  140. # Installation of python modules
  141. ifeq ($(shell test -f setup.py && echo 0), 0)
  142. install-files::
  143. python setup.py install --no-compile --install-layout=deb $(PYTHON_OPTS)
  144. endif
  145. .PHONY: install install-dirs install-files install-data-files install-prog-files install-rec-dirs