summaryrefslogtreecommitdiff
path: root/share/mk/bsd.xorg.mk
blob: fe2de925e430a740ada1423d538ad9b171053936 (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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
# $OpenBSD: bsd.xorg.mk,v 1.50 2014/05/18 10:29:01 matthieu Exp $ -*- makefile  -*-
#
# Copyright © 2006,2012 Matthieu Herrb
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#

.if exists(${.CURDIR}/../Makefile.inc)
.include "${.CURDIR}/../Makefile.inc"
.endif

AUTOMAKE_VERSION=	1.12
AUTOCONF_VERSION=	2.69
PYTHON_VERSION=		2.7

# Where source lives
XSRCDIR?=		/usr/xenocara

# Where to build
XOBJDIR?=	/usr/xobj

# Where to install
BINDIR?=		${X11BASE}/bin
LIBDIR=			${X11BASE}/lib
INCSDIR=		${X11BASE}/include
MANDIR=			${X11BASE}/man/man

PKG_CONFIG_LIBDIR=	/usr/lib/pkgconfig:${X11BASE}/lib/pkgconfig

# A few aliases for *-install targets
INSTALL_DATA = \
	${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m ${SHAREMODE}

# Autoconf cache
_cache= --cache-file=${XOBJDIR}/xorg-config.cache.${MACHINE}

CFLAGS+=	$(COPTS)

.if !defined(CONFIG_SITE)
CONFIG_SITE=	${XSRCDIR}/etc/config.site
.endif

_SRCDIR?=	${.CURDIR}

XENOCARA_PATH?=	/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin

CONFIGURE_ENV=	PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)" \
		CONFIG_SITE=$(CONFIG_SITE) \
		CFLAGS="$(CFLAGS:C/ *$//)" \
		MAKE="${MAKE}"

CONFIGURE_ARGS+= --disable-silent-rules

AUTOTOOLS_ENV=  AUTOMAKE_VERSION="$(AUTOMAKE_VERSION)" \
		AUTOCONF_VERSION="$(AUTOCONF_VERSION)" \
		ACLOCAL="aclocal -I ${X11BASE}/share/aclocal" \
		$(CONFIGURE_ENV)

##
## Default rules
##

# pkgconfig
.if defined(PKGCONFIG)

PACKAGE_VERSION ?= `m4 ${DESTDIR}${X11BASE}/share/mk/package_version.m4 ${_SRCDIR}/configure.ac`

all: ${PKGCONFIG}

${PKGCONFIG}: ${PKGCONFIG}.in
	@sed -e 's#@prefix@#${X11BASE}#g' \
	    -e 's#@datarootdir@#$${prefix}/share#g' \
	    -e 's#@datadir@#$${datarootdir}#g' \
	    -e 's#@exec_prefix@#$${prefix}#g' \
	    -e 's#@libdir@#$${exec_prefix}/lib#g' \
	    -e 's#@includedir@#$${prefix}/include#g' \
	    -e 's#@PACKAGE_VERSION@#'${PACKAGE_VERSION}'#g' \
	    ${EXTRA_PKGCONFIG_SUBST} \
	< $? > $@

install-pc: ${PKGCONFIG}
	${INSTALL_DATA} ${PKGCONFIG} ${DESTDIR}${LIBDIR}/pkgconfig

clean-pc:
	rm -rf ${PKGCONFIG}

realinstall: install-pc

clean:	clean-pc


.endif

# headers
.if defined(HEADERS)
install-headers:
	@echo installing ${HEADERS} in ${INCSDIR}/${HEADERS_SUBDIR}
	@cd ${_SRCDIR}; for i in ${HEADERS}; do \
	    cmp -s $$i ${DESTDIR}${INCSDIR}/${HEADERS_SUBDIR}$$i || \
		${INSTALL_DATA} $$i ${DESTDIR}${INCSDIR}/${HEADERS_SUBDIR}$$i;\
	done

realinstall: install-headers
.endif
.if defined(HEADERS_SUBDIRS)
.for d in ${HEADERS_SUBDIRS}
install-headers-subdirs::
	@echo installing ${HEADERS_${d:S/\//_/}} in ${INCSDIR}/${d}
	@cd ${_SRCDIR}; for i in ${HEADERS_${d:S/\//_/}}; do \
	    cmp -s $$i ${DESTDIR}${INCSDIR}/$d/$$i || \
		${INSTALL_DATA} $$i ${DESTDIR}${INCSDIR}/${d}; \
	done

realinstall: install-headers-subdirs
.endfor
.endif

.if !target(.MAIN)
.MAIN: all
.endif

.if !target(includes)
includes: _SUBDIRUSE
.endif

.if defined(SHARED_LIBS)
_lt_libs=
.for _n _v in ${SHARED_LIBS}
_lt_libs+=lib${_n:S/+/_/g:S/-/_/g:S/./_/g}_ltversion=${_v}
.endfor
.endif

.if !target(all)
all:	config.status
	exec ${MAKE} ${_lt_libs}
.endif


REORDER_DEPENDENCIES += ${X11BASE}/share/mk/automake.dep
ECHO_REORDER ?= :

.if !target(config.status)
config.status:
.if defined(XENOCARA_RERUN_AUTOCONF) && ${XENOCARA_RERUN_AUTOCONF:L} == "yes"
	cd ${_SRCDIR}; ${AUTOTOOLS_ENV} exec autoreconf -v --install --force
.else
.if !defined(NO_REORDER)
	@sed -e '/^#/d' ${REORDER_DEPENDENCIES} | \
	  tsort -r|while read f; do \
	    cd ${_SRCDIR}; \
		case $$f in \
		/*) \
			find . -name $${f#/} -print| while read i; \
				do ${ECHO_REORDER} "Touching $$i"; touch $$i; done \
			;; \
		*) \
			if test -e $$f ; then \
				${ECHO_REORDER} "Touching $$f"; touch $$f; \
			fi \
			;; \
		esac; done
.endif
.endif
	${CONFIGURE_ENV} PATH=$(XENOCARA_PATH) \
		exec sh ${_SRCDIR}/configure --prefix=${X11BASE} \
		--sysconfdir=/etc \
		--mandir=${X11BASE}/man \
		${_cache} \
		${CONFIGURE_ARGS}
.endif

.if !target(depend)
depend:
	@echo "no dependencies here yet"
.endif

.if !target(install)
.  if !target(beforeinstall)
beforeinstall:
.  endif
.  if !target(afterinstall)
afterinstall:
.  endif
.  if !target(realinstall)
realinstall:
	exec ${MAKE} ${MAKE_FLAGS} ${_lt_libs} install
.endif
install: maninstall
maninstall: afterinstall
afterinstall: realinstall
realinstall: beforeinstall
.endif

.if !target(build)
.if exists(Makefile.bsd-wrapper)
_wrapper = -f Makefile.bsd-wrapper
.endif
build:
	cd ${.CURDIR} && exec ${MAKE} ${MAKE_FLAGS} ${_wrapper} cleandir
	cd ${.CURDIR} && exec ${MAKE} ${MAKE_FLAGS} ${_wrapper} depend
	cd ${.CURDIR} && exec ${MAKE} ${MAKE_FLAGS} ${_wrapper} all
	cd ${.CURDIR} && exec ${SUDO} ${MAKE} ${MAKE_FLAGS} ${_wrapper} install
.endif

.if !target(clean) && ${MAKEFILE:T} != "Makefile"
clean:
	-@if [ -f Makefile ]; then exec ${MAKE} clean; fi
.endif

.if !target(cleandir)
cleandir: clean
	-@if [ -f Makefile ]; then exec ${MAKE} distclean; fi
	-@if [ -f config.status ]; then \
		echo "rm config.status"; \
		rm -f config.status; \
	fi
.endif

#
# Obj dir rules for xenocara
#
.if !target(_xenocara_obj)
. if defined(NOOBJ)
_xenocara_obj:
. else

. if defined(MAKEOBJDIR)
__objdir=	${MAKEOBJDIR}
. else
__objdir=	obj
. endif

_SUBDIRUSE:

_xenocara_obj! _SUBDIRUSE
	@cd $(.CURDIR); \
	here=`/bin/pwd`; xsrcdir=`cd $(XSRCDIR); /bin/pwd`; \
	subdir=$${here#$${xsrcdir}/}; \
	if test $$here != $$subdir ; then \
	    dest=${XOBJDIR}/$$subdir; \
	    echo "$$here/${__objdir} -> $$dest"; \
	    if test ! -L ${__objdir} -o \
		X`readlink ${__objdir}` != X$$dest; then \
		    if  test -e ${__objdir}; then rm -rf ${__objdir}; fi; \
		    ln -sf $$dest ${__objdir}; \
	    fi; \
	    if test -d ${XOBJDIR}; then \
		    test -d $$dest || mkdir -p $$dest; \
	    else \
		    if test -e ${XOBJDIR}; then \
			    echo "${XOBJDIR} is not a directory"; \
		    else \
			    echo "${XOBJDIR} does not exist"; \
		    fi; \
	    fi; \
	else \
	    dest=$$here/${__objdir}; \
	    if test ! -d ${__objdir}; then \
		echo "making $$dest"; \
		mkdir $$dest; \
	    fi ; \
	fi
. endif
.endif

.if !target(obj)
obj:	_xenocara_obj
.endif

.include <bsd.subdir.mk>