1### bps.objdir.mk -- Utilisation de OBJDIR
2
3# Author: Michael Grünewald
4# Date: Sam 15 mar 2008 20:51:30 CET
5# Cookie: SYNOPSIS TARGET VARIABLE EN DOCUMENTATION
6
7# BSD Owl Scripts (https://bitbucket.org/michipili/bsdowl)
8# This file is part of BSD Owl Scripts
9#
10# Copyright © 2005–2014 Michael Grünewald
11#
12# This file must be used under the terms of the CeCILL-B.
13# This source file is licensed as described in the file COPYING, which
14# you should have received as part of this distribution. The terms
15# are also available at
16# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt
17
18
19### SYNOPSIS
20
21# .include "bps.objdir.mk"
22
23
24### DESCRIPTION
25
26# Le programme BSD Make dispose de certaines fonctionnalités
27# permettant de produire le code objet dans un répertoire différent de
28# celui contenant le code source. Ce module propose une interface
29# simplifiée vers ces fonctionnalités.
30#
31# Note: Plus que tout autre, ce module de directives peut entraîner la
32#   perte de données par son utilisation maladroite.
33
34#
35# Description des variables
36#
37
38# MAKE_OBJDIR
39# MAKE_OBJDIRPREFIX
40# USE_OBJDIR
41
42### IMPLÉMENTATION
43
44.if !target(__<bps.objdir.mk>__)
45__<bps.objdir.mk>__:
46
47#
48# Contrôle de MAKEOBJDIRPREFIX et MAKEOBJDIR
49#
50
51# On vérifie que les variables MAKEOBJDIRPREFIX et MAKEOBJDIR n'ont
52# pas été positionnées sur la ligne de commande ou dans le fichier de
53# directives (cf. make(1), .OBJDIR).
54
55_MAKE_OBJDIRPREFIX!= ${ENVTOOL} -i PATH=${PATH} ${MAKE} \
56	${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} -f /dev/null -V MAKEOBJDIRPREFIX nothing
57
58.if !empty(_MAKE_OBJDIRPREFIX)
59.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\
60	(in make.conf(5)) or command-line variable.
61.endif
62
63_MAKE_OBJDIR!= ${ENVTOOL} -i PATH=${PATH} ${MAKE} \
64       ${.MAKEFLAGS:MMAKEOBJDIR=*} -f /dev/null -V MAKEOBJDIR nothing
65
66.if !empty(_MAKE_OBJDIR)
67.error MAKEOBJDIR can only be set in environment, not as a global\
68       (in bps.conf(5)) or command-line variable.
69.endif
70
71
72
73.undef _MAKE_OBJDIRPREFIX
74.undef _MAKE_OBJDIR
75
76
77#
78# Initialisation
79#
80
81.if defined(MAKEOBJDIR)||defined(MAKEOBJDIRPREFIX)
82USE_OBJDIR?= yes
83.else
84USE_OBJDIR?= no
85.endif
86
87#
88# User targets
89#
90
91.if ${USE_OBJDIR} == yes
92_MAKE_USERTARGET+= obj
93_MAKE_ALLSUBTARGET+= obj
94
95do-obj:
96.if defined(MAKEOBJDIRPREFIX)
97	${INSTALL_DIR} ${MAKEOBJDIRPREFIX}/${.CURDIR}
98.elif defined(MAKEOBJDIR)
99	${INSTALL_DIR} ${MAKEOBJDIR}
100.endif
101
102.if ${.OBJDIR} != ${.CURDIR}
103distclean:
104	@rm -Rf ${.OBJDIR}
105.endif
106
107.endif # USE_OBJDIR
108
109.endif # !target(__<bps.objdir.mk>__)
110
111### End of file `bps.objdir.mk'
112