You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

217 lines
6.4KB

  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. # Standard path
  23. bin_PROG_DIR := $(DESTDIR)/usr/bin
  24. sbin_PROG_DIR := $(DESTDIR)/usr/sbin
  25. man8_DATA_DIR := $(DESTDIR)/usr/share/man/fr.UTF-8/man8
  26. # Base
  27. eole_DIR := $(DESTDIR)/usr/share/eole
  28. ifeq ($(strip $(EOLE_VERSION)), 2.3)
  29. diagnose_PROG_DIR := $(eole_DIR)/diagnose/module
  30. else
  31. diagnose_PROG_DIR := $(eole_DIR)/diagnose/
  32. endif
  33. # Creole
  34. creole_DIR := $(eole_DIR)/creole
  35. dicos_DATA_DIR := $(creole_DIR)/dicos
  36. tmpl_DATA_DIR := $(creole_DIR)/distrib
  37. preservice_PROG_DIR := $(eole_DIR)/preservice
  38. pretemplate_PROG_DIR := $(eole_DIR)/pretemplate
  39. posttemplate_PROG_DIR := $(eole_DIR)/posttemplate
  40. postservice_PROG_DIR := $(eole_DIR)/postservice
  41. ifeq ($(strip $(EOLE_VERSION)), 2.3)
  42. firewall_DATA_DIR := $(eole_DIR)/firewall
  43. endif
  44. bacula_restore_DATA_DIR := $(eole_DIR)/bacula/restore
  45. bacula_fichier_DATA_DIR := $(DESTDIR)/etc/bacula/baculafichiers.d
  46. ifeq ($(strip $(EOLE_VERSION)), 2.3)
  47. schedule_pre_PROG_DIR := $(eole_DIR)/schedule/pre
  48. schedule_post_PROG_DIR := $(eole_DIR)/schedule/post
  49. else
  50. schedule_scripts_PROG_DIR := $(eole_DIR)/schedule/scripts
  51. endif
  52. extra_REC_DIR := $(creole_DIR)/extra
  53. # Zéphir
  54. zephir_DATA_DIR := $(DESTDIR)/usr/share/zephir
  55. zephir_configs_DATA_DIR := $(zephir_DATA_DIR)/monitor/configs
  56. zephir_srv_DATA_DIR := $(zephir_configs_DATA_DIR)/services
  57. zephir_scripts_PROG_DIR := $(zephir_DATA_DIR)/scripts
  58. # SSO
  59. sso_DATA_DIR := $(DESTDIR)/usr/share/sso
  60. sso_filtres_DATA_DIR := $(sso_DATA_DIR)/app_filters
  61. sso_user-info_DATA_DIR := $(sso_DATA_DIR)/user_infos
  62. # EAD
  63. ead_DATA_DIR := $(DESTDIR)/usr/share/ead2/backend/config
  64. ead_actions_DATA_DIR := $(ead_DATA_DIR)/actions
  65. ead_perms_DATA_DIR := $(ead_DATA_DIR)/perms
  66. ead_roles_DATA_DIR := $(ead_DATA_DIR)/roles
  67. # Program libraries goes under /usr/lib/<PROGRAM>/
  68. lib_$(SOURCE)_DATA_DIR := $(DESTDIR)/usr/lib/$(SOURCE)
  69. # Scripts Eole
  70. scripts_PROG_DIR := $(eole_DIR)/sbin
  71. lib_eole_DATA_DIR := $(DESTDIR)/usr/lib/eole
  72. # LDAP
  73. ldap_passwords_DATA_DIR := $(eole_DIR)/annuaire/password_files
  74. # LXC
  75. lxc_DATA_DIR := $(eole_DIR)/lxc
  76. lxc_fstab_DATA_DIR := $(lxc_DATA_DIR)/fstab
  77. lxc_hosts_DATA_DIR := $(lxc_DATA_DIR)/hosts
  78. # SQL
  79. sql_DATA_DIR := $(eole_DIR)/mysql/$(SOURCE)
  80. sql_gen_DATA_DIR := $(sql_DATA_DIR)/gen
  81. sql_updates_DATA_DIR := $(sql_DATA_DIR)/updates
  82. sql_conf_gen_DATA_DIR := $(eole_DIR)/applications/gen
  83. sql_conf_passwords_DATA_DIR := $(eole_DIR)/applications/passwords
  84. sql_conf_updates_DATA_DIR := $(eole_DIR)/applications/updates/$(SOURCE)
  85. # Certifs
  86. certs_DATA_DIR := $(eole_DIR)/certs
  87. # Logrotate
  88. logrotate_DATA_DIR := $(DESTDIR)/etc/logrotate.d
  89. # Cron
  90. cron_PROG_DIR := $(DESTDIR)/etc/cron.daily
  91. # Python modules
  92. ifneq ($(DESTDIR),)
  93. PYTHON_OPTS := --root $(DESTDIR)
  94. endif
  95. # Translation
  96. TRANSLATION_SRC := translation
  97. TRANSLATION_DEST := $(DESTDIR)/usr/share/locale
  98. PO_FILES = $(wildcard $(TRANSLATION_SRC)/*/*.po)
  99. MO_FOLDERS = $(addprefix $(TRANSLATION_DEST), $(addsuffix LC_MESSAGES,$(subst $(TRANSLATION_SRC),,$(dir $(PO_FILES)))))
  100. #############################################
  101. # Common directories and files installation #
  102. #############################################
  103. all:
  104. $(MO_FOLDERS):
  105. $(INSTALL_DIRECTORY) $@
  106. $(PO_FILES): $(MO_FOLDERS)
  107. msgfmt -o $(TRANSLATION_DEST)$(subst $(TRANSLATION_SRC),,$(addsuffix LC_MESSAGES,$(dir $@)))/$(notdir $(@:.po=.mo)) $@
  108. install-lang: $(PO_FILES)
  109. install:: install-dirs install-files install-lang
  110. # $1 = command to run
  111. # $2 = source directory
  112. # $3 = destination directory
  113. define fc_install_file
  114. if [ -d $2 ]; then \
  115. for file in `ls -1 $2/`; do \
  116. $1 $2/$$file $3 || true; \
  117. done; \
  118. fi
  119. endef
  120. ##
  121. ## Directory creation
  122. ##
  123. # use % to catch local name in $*
  124. # data, program and recursive directory require a corresponding
  125. # directory in local sources
  126. %_DATA_DIR %_PROG_DIR %REC_DIR:
  127. test ! -d $(subst _,/,$*) || $(INSTALL_DIRECTORY) $($@)
  128. # Create the directory referenced by the variable without a local one.
  129. %_DIR:
  130. $(INSTALL_DIRECTORY) $($@)
  131. ##
  132. ## Install files present directly under data, program and recursive directories
  133. ##
  134. # $* : name of variable
  135. # $($*): value of variable
  136. %-instdata:
  137. $(call fc_install_file, $(INSTALL_DATA), $(subst _,/,$(subst _DATA_DIR,,$*)), $($*))
  138. %-instprog:
  139. $(call fc_install_file, $(INSTALL_PROGRAM), $(subst _,/,$(subst _PROG_DIR,,$*)), $($*))
  140. %-instrec:
  141. $(call fc_install_file, $(INSTALL_RECURSIVE), $(subst _,/,$(subst _REC_DIR,,$*)), $($*))
  142. # Use second expansion as variables may be created in included
  143. # Makefiles
  144. .SECONDEXPANSION:
  145. # List of all directories
  146. installdirs_LIST = $(foreach V, $(filter %_DIR, $(.VARIABLES)), \
  147. $(if $(filter file, $(origin $(V))), \
  148. $(V)))
  149. # List of data directories
  150. installdata_LIST = $(filter %_DATA_DIR, $(installdirs_LIST))
  151. # List of program directories
  152. installprog_LIST = $(filter %_PROG_DIR, $(installdirs_LIST))
  153. # List of recursive directories
  154. installrec_LIST = $(filter %_REC_DIR, $(installdirs_LIST))
  155. # Expand directories to create as dependency
  156. # Use double-colon to permit user to define additionnal install-dirs
  157. install-dirs:: $$(installdirs_LIST)
  158. # Expand files to install as dependency
  159. # Use double-colon to permit user to define additionnal install-files
  160. install-files:: install-data-files install-prog-files install-rec-dirs
  161. install-data-files: $$(patsubst %,%-instdata,$$(installdata_LIST))
  162. install-prog-files: $$(patsubst %,%-instprog,$$(installprog_LIST))
  163. install-rec-dirs: $$(patsubst %,%-instrec,$$(installrec_LIST))
  164. # Installation of python modules
  165. ifeq ($(shell test -f setup.py && echo 0), 0)
  166. install-files::
  167. python setup.py install --no-compile --install-layout=deb $(PYTHON_OPTS)
  168. endif
  169. .PHONY: install install-dirs install-files install-data-files install-prog-files install-rec-dirs