summaryrefslogtreecommitdiff
path: root/pkgtools/x11-links/Makefile
blob: a3bec01c0213375d6dc54886b32081f5d29f50ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# $NetBSD: Makefile,v 1.174 2017/01/25 02:51:35 mrg Exp $
#
# NOTE:	If you update this package, then you'll likely need to also update
#	the x11-links dependency in buildlink3.mk to the correct version,
#	usually the most recent.

PKGNAME=	x11-links-1.04
CATEGORIES=	pkgtools x11

MAINTAINER=	pkgsrc-users@NetBSD.org
HOMEPAGE=	http://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/doc/pkgsrc.html
COMMENT=	Shadow tree of links to native X11 headers and libraries
LICENSE=	original-bsd

.include "../../mk/bsd.prefs.mk"
.if ${OPSYS} == "OpenBSD"
CHECK_SHLIBS_SUPPORTED=	no
.endif

NOT_FOR_PLATFORM=	DragonFly-*-*

WRKSRC=			${WRKDIR}
USE_LANGUAGES=		# empty
USE_TOOLS+=		pax

PLIST_SRC.files=	${WRKDIR}/.PLIST_SRC.files
PLIST_SRC=		${PLIST_SRC_DFLT} ${PLIST_SRC.files}

OSVERSION_SPECIFIC=	yes

.include "../../mk/bsd.prefs.mk"

.if ${X11_TYPE} == "modular"
PKG_FAIL_REASON+=	"${PKGNAME} should only be used with X11_TYPE=native."
.elif !exists(${X11BASE}/include/X11/X.h)
PKG_FAIL_REASON+=	"pkgsrc has been configured to use a system provided X11 installation"
PKG_FAIL_REASON+=	"but one could not be found. Possible solutions:"
PKG_FAIL_REASON+=	""
PKG_FAIL_REASON+=	"	*) install X headers and libraries in X11BASE (currently ${X11BASE})"
PKG_FAIL_REASON+=	"	*) set X11_TYPE=modular in mk.conf to use X11 from pkgsrc"
PKG_FAIL_REASON+=	""
PKG_FAIL_REASON+=	"Please note that changing the value of X11_TYPE in existing"
PKG_FAIL_REASON+=	"pkgsrc installations is not supported!"
.endif

.if ${OPSYS} == "IRIX"
.  include "xsgi.mk"
.elif ${OPSYS} == "OSF1"
.  include "xdec.mk"
.elif !empty(X11BASE:M*openwin)
.  include "openwin.mk"
.elif exists(${X11BASE}/lib/X11/config/xorgversion.def) || \
      (exists(${X11BASE}/lib/X11/config/xorg.cf) && \
       exists(${X11BASE}/lib/X11/config/version.def)) || \
      exists(${X11BASE}/lib/pkgconfig/xorg-server.pc) || \
      exists(${X11BASE}/lib/pkgconfig/x11.pc) || \
      exists(${X11BASE}/lib${LIBABISUFFIX}/pkgconfig/xorg-server.pc) || \
      exists(${X11BASE}/lib${LIBABISUFFIX}/pkgconfig/x11.pc) || \
      exists(${X11BASE}/bin/Xquartz)
.  include "xorg.mk"
.else
.  include "xfree.mk"
.endif

X11_LINKS_SUBDIR=	share/x11-links
X11_LINKS_BUILD_DIR=	${WRKSRC}/${X11_LINKS_SUBDIR}
X11_LINKS_DIR=		${PREFIX}/${X11_LINKS_SUBDIR}

FILES_LIST_CMD=	${SED} -e "s/@ABI@/${ABI}/" ${FILES_LIST} | ${GREP} -v "^\#"

.if ${OPSYS} == "Linux" && !empty(LIBABISUFFIX)
FILES_LIST_CMD+=	| awk '/^lib\// { sub(/^lib\//, "lib${LIBABISUFFIX}/") } { print }'
.endif

CREATE_X11LINK?=	${LN} -fs $$src $$dest

.include "../../mk/x11.buildlink3.mk"

do-build:
	${MKDIR} ${X11_LINKS_BUILD_DIR}
	${CHMOD} ${PKGDIRMODE} ${X11_LINKS_BUILD_DIR}
	${FILES_LIST_CMD} | ${SED} -e 's,/[^/]*$$,,' | ${SORT} -u |	\
	while read dir; do						\
		if [ -d ${X11BASE}/$$dir ]; then			\
			${MKDIR} ${X11_LINKS_BUILD_DIR}/$$dir;		\
			${CHMOD} ${PKGDIRMODE} ${X11_LINKS_BUILD_DIR}/$$dir; \
		elif [ -d /usr/$$dir ]; then				\
			${MKDIR} ${X11_LINKS_BUILD_DIR}/$$dir;		\
			${CHMOD} ${PKGDIRMODE} ${X11_LINKS_BUILD_DIR}/$$dir; \
		fi;							\
	done
	${RM} -f ${PLIST_SRC.files}
	${FILES_LIST_CMD} | ${SORT} -u |				\
	while read file; do						\
		srcdir="";						\
		if ${TEST} -r ${X11BASE}/$$file; then			\
			srcdir="${X11BASE}";				\
		elif ${TEST} -r /usr/$$file; then			\
			srcdir="/usr";					\
		fi;							\
		if ${TEST} ! -z "$$srcdir"; then			\
			src="$$srcdir/$$file";				\
			dest="${X11_LINKS_BUILD_DIR}/$$file";		\
			${CREATE_X11LINK};				\
			${ECHO} "${X11_LINKS_SUBDIR}/$$file"		\
				>> ${PLIST_SRC.files};			\
			if (${ECHO} $$file | ${GREP} -q '\.la$$'); then \
				cd $${srcdir} && 			\
					${_LIBTOOL_EXPAND} $${file} | 	\
				while read lib; do			\
					src="$$srcdir/$$lib";		\
					dest="${X11_LINKS_BUILD_DIR}/$$lib"; \
					${CREATE_X11LINK};		\
					${ECHO} "${X11_LINKS_SUBDIR}/$$lib" \
						>> ${PLIST_SRC.files};	\
				done;					\
			fi;						\
		fi;							\
	done

do-install:
	${INSTALL_DATA_DIR} ${DESTDIR}${X11_LINKS_DIR}
	cd ${X11_LINKS_BUILD_DIR} && pax -rw . ${DESTDIR}${X11_LINKS_DIR}

.include "../../mk/bsd.pkg.mk"