Merge from vendor branch TNF:
[pkgsrc.git] / mk / djbware.mk
1 # $NetBSD: djbware.mk,v 1.10 2005/08/24 05:10:35 schmonz Exp $
2 #
3 # Makefile fragment for packages with djb-style build machinery
4 #
5 # Common functions provided:
6 # * a boilerplate RESTRICTED clause
7 # * typical defaults for BUILD_TARGET and INSTALL_TARGET
8 # * typical values for conf-* files
9 # * replace inline definitions of errno with "#include <errno.h>"
10 #
11 # TODO:
12 # * centralize handling of third-party manpages
13 # * centralize MASTER_SITES and SITES_foo
14 # * centralize compiler hack for arm{,32}
15 # * common install script for compatibility with default conf-home pathnames
16 # * PKG_OPTIONS (default):
17 #     djbware-errno-hack (off)
18 #     djbware-pathname-compat (on)
19 #     inet6 (off)
20 #     pam (off)
21 # * set RESTRICTED automatically iff patches or other mods are applied
22 # * define "djb-nonlicense" and set LICENSE on affected packages
23 # * be unrestricted by default for bulk builds
24 #
25
26 .if !defined(DJBWARE_MK)
27 DJBWARE_MK=             # defined
28
29 DJB_RESTRICTED?=        YES
30 DJB_MAKE_TARGETS?=      YES
31 DJB_BUILD_TARGETS?=     # empty
32 DJB_INSTALL_TARGETS?=   # empty
33 DJB_CONFIG_PREFIX?=     ${PREFIX}
34 DJB_CONFIG_HOME?=       conf-home
35 DJB_CONFIG_CMDS?=       ${DO_NADA}
36
37 .if !empty(DJB_RESTRICTED:M[yY][eE][sS])
38 RESTRICTED=             "modified source and binaries may not be distributed"
39 NO_BIN_ON_CDROM=        ${RESTRICTED}
40 NO_BIN_ON_FTP=          ${RESTRICTED}
41 .endif
42
43 .if !empty(DJB_MAKE_TARGETS:M[yY][eE][sS])
44 BUILD_TARGET?=          it ${DJB_BUILD_TARGETS}
45 INSTALL_TARGET?=        setup check ${DJB_INSTALL_TARGETS}
46 .endif
47
48 .if !defined(NO_CONFIGURE) && !target(do-configure)
49 do-configure:
50         ${_PKG_SILENT}${_PKG_DEBUG}cd ${WRKSRC};                        \
51         for i in conf-*; do ${CP} $${i} $${i}.orig_dist; done;          \
52         [ -f ${DJB_CONFIG_HOME} ] && \
53                 ${ECHO} ${DJB_CONFIG_PREFIX} > ${DJB_CONFIG_HOME};      \
54         [ -f conf-cc ] && \
55                 ${ECHO} ${CC:Q} ${CFLAGS:Q} > conf-cc;                  \
56         [ -f conf-ld ] && \
57                 ${ECHO} ${CC:Q} ${_STRIPFLAG_CC} > conf-ld;             \
58         [ -f conf-bin ] && \
59                 ${ECHO} ${DJB_CONFIG_PREFIX}/bin > conf-bin;            \
60         [ -f conf-man ] && \
61                 ${ECHO} ${DJB_CONFIG_PREFIX}/man > conf-man;            \
62         [ -f conf-qmail ] && \
63                 ${ECHO} ${QMAILDIR} > conf-qmail;                       \
64         [ -f conf-bgincs ] && \
65                 ${ECHO} ${LOCALBASE}/include/bglibs > conf-bgincs;      \
66         [ -f conf-bglibs ] && \
67                 ${ECHO} ${LOCALBASE}/lib/bglibs > conf-bglibs;          \
68         ${DJB_CONFIG_CMDS}
69 .endif
70
71 PKG_SUPPORTED_OPTIONS+= djbware-errno-hack
72 PKG_SUGGESTED_OPTIONS+= djbware-errno-hack
73
74 .include "../../mk/bsd.prefs.mk"
75
76 .if exists(${PKGDIR}/options.mk)
77 . include "${PKGDIR}/options.mk"
78 .else
79 PKG_OPTIONS_VAR=        PKG_OPTIONS.${PKGBASE}
80 .include "../../mk/bsd.options.mk"
81 .endif
82
83 .if !empty(PKG_OPTIONS:Mdjbware-errno-hack)
84 SUBST_CLASSES+=         djbware
85 SUBST_STAGE.djbware=    do-configure
86 SUBST_FILES.djbware=    error.h
87 SUBST_SED.djbware=      -e 's|^extern\ int\ errno\;|\#include \<errno.h\>|'
88 SUBST_MESSAGE.djbware=  "Correcting definition of errno."
89 .endif
90
91 .endif  # DJBWARE_MK