Makefile 10.2 KB
Newer Older
1 2
#!/usr/bin/make -f

3 4 5
NULL =

# helpers for "install" target
6 7 8
INSTALL_DIR=install -d -m 755
INSTALL_FILE=install -m 644
INSTALL_PROGRAM=install -m 755
9
INSTALL_SYMLINK=ln -s -f
10 11 12 13 14

# helpers for "build" target
SYMLINK_FILE=ln -f -s

# helpers for "clean" and "uninstall" targets
15 16
RM_FILE=rm -f
RM_DIR=rmdir -p --ignore-fail-on-non-empty
17
RM_DIR_REC=rm -Rf
18

19 20 21 22 23 24 25 26
ETCDIR_NX       ?= /etc/nxagent
PREFIX          ?= /usr/local
BINDIR          ?= $(PREFIX)/bin
LIBDIR          ?= $(PREFIX)/lib
SHLIBDIR        ?= $(LIBDIR)
NXLIBDIR        ?= $(SHLIBDIR)/nx
USRLIBDIR       ?= $(NXLIBDIR)/X11
INCLUDEDIR      ?= $(PREFIX)/include
27
CONFIGURE       ?= ./configure --prefix="$(PREFIX)"
28

29 30
# check if the xkbcomp devel pkg is available - we need it for the next step
ifneq ($(shell pkg-config --exists xkbcomp && echo yes), yes)
31
    $(warning xkbcomp devel package missing, using imake default values)
32
endif
33 34 35
ifneq ($(shell pkg-config --exists fontutil && echo yes), yes)
    $(warning fontutil devel package missing, using imake default values)
endif
36

37 38 39 40
ifneq "$(strip $(NX_VERSION_CUSTOM))" ""
    CUSTOM_VERSION_DEFINE = NX_VERSION_CUSTOM="$(NX_VERSION_CUSTOM)"
endif

41 42
IMAKE_DEFINES	?=

43
SHELL:=/bin/bash
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
NX_X11_HEADERS =		\
	Xlib.h			\
	Xresource.h		\
	Xutil.h			\
	cursorfont.h		\
	Xlibint.h		\
	Xcms.h			\
	Xlocale.h		\
	XKBlib.h		\
	XlibConf.h		\
	Xregion.h		\
	ImUtil.h		\
	$(NULL)

NX_XTRANS_HEADERS =		\
	transport.c		\
	Xtrans.c		\
	Xtrans.h		\
	Xtransint.h		\
	Xtranslcl.c		\
	Xtranssock.c		\
	Xtransutil.c		\
	$(NULL)

69 70
all: build

71
clean: version imakeconfig
72 73 74 75 76
	test -f nxcomp/Makefile     && ${MAKE} -C nxcomp clean         || true
	test -f nxproxy/Makefile    && ${MAKE} -C nxproxy clean        || true
	test -f nx-X11/lib/Makefile && ${MAKE} -C nx-X11/lib clean     || true
	test -f nxcompshad/Makefile && ${MAKE} -C nxcompshad clean     || true
	test -d nx-X11              && ${MAKE} clean-env               || true
77
	test -f nxdialog/Makefile   && ${MAKE} -C nxdialog clean       || true
78

79
distclean: clean version imakeconfig
80 81 82 83 84
	test -f nxcomp/Makefile     && ${MAKE} -C nxcomp distclean     || true
	test -f nxproxy/Makefile    && ${MAKE} -C nxproxy distclean    || true
	test -f nx-X11/lib/Makefile && ${MAKE} -C nx-X11/lib distclean || true
	test -f nxcompshad/Makefile && ${MAKE} -C nxcompshad distclean || true
	test -d nx-X11              && ${MAKE} -C nx-X11 distclean     || true
85
	test -f nxdialog/Makefile   && ${MAKE} -C nxdialog distclean   || true
86
	test -x ./mesa-quilt        && ./mesa-quilt pop -a
87 88 89
	$(RM_DIR_REC) nx-X11/extras/Mesa/.pc/
	$(RM_FILE) nx-X11/config/cf/nxversion.def
	$(RM_FILE) nx-X11/config/cf/nxconfig.def
90 91 92 93

test:
	echo "No testing for NX (redistributed)"

94
version:
95 96
	# prepare nx-X11/config/cf/nxversion.def
	sed \
97 98 99 100
	    -e 's/###NX_VERSION_MAJOR###/$(shell ./version.sh 1)/' \
	    -e 's/###NX_VERSION_MINOR###/$(shell ./version.sh 2)/' \
	    -e 's/###NX_VERSION_MICRO###/$(shell ./version.sh 3)/' \
	    -e 's/###NX_VERSION_PATCH###/$(shell ./version.sh 4)/' \
101 102
	    nx-X11/config/cf/nxversion.def.in \
	    > nx-X11/config/cf/nxversion.def
103 104 105
ifneq "$(strip $(NX_VERSION_CUSTOM))" ""
	echo '#define NX_VERSION_CUSTOM $(NX_VERSION_CUSTOM)' >>nx-X11/config/cf/nxversion.def
endif
106

107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
imakeconfig:
	# auto-config some setting

	# check if system supports Xfont2
	(echo "#define HasXfont2 `pkg-config --exists xfont2 && echo YES || echo NO`") >nx-X11/config/cf/nxconfig.def

	# check if system has an _old_ release of Xfont1
	(echo "#define HasLegacyXfont1 `pkg-config --exists 'xfont < 1.4.2' && echo YES || echo NO`") >>nx-X11/config/cf/nxconfig.def

	# check if system has an _old_ release of XextProto
	(echo "#define HasLegacyXextProto `pkg-config --exists 'xextproto < 7.1.0' && echo YES || echo NO`") >>nx-X11/config/cf/nxconfig.def

	# the system's directory with the xkb data and binary files (these
	# needs to be independent of Imake's ProjectRoot or the configure
	# prefix.)
	(pkg-config --exists xkbcomp && echo "#define SystemXkbConfigDir `pkg-config xkbcomp --variable=xkbconfigdir`"; :) >>nx-X11/config/cf/nxconfig.def
	(pkg-config --exists xkbcomp && echo "#define SystemXkbBinDir `pkg-config xkbcomp --variable=prefix`/bin"; :) >>nx-X11/config/cf/nxconfig.def

125 126
	(pkg-config --exists fontutil && echo "#define SystemFontRootDir `pkg-config fontutil --variable=fontrootdir`"; :) >>nx-X11/config/cf/nxconfig.def

127 128 129
	# let's create the nx-X11 Makefiles now, once everything has been defined
	$(MAKE) -j1 -C nx-X11 Makefiles IMAKE_DEFINES="$(IMAKE_DEFINES)"

130
build-env: version imakeconfig
131
	# prepare Makefiles and the nx-X11 symlinking magic
132
	${MAKE} -j1 -C nx-X11 BuildIncludes IMAKE_DEFINES="$(IMAKE_DEFINES)"
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153

	# set up environment for libNX_X11 build (X11 header files)
	mkdir -p nx-X11/exports/include/nx-X11/
	for header in $(NX_X11_HEADERS); do \
	    ${SYMLINK_FILE} ../../../lib/include/X11/$${header} nx-X11/exports/include/nx-X11/$${header}; \
	done

	# set up environment for libNX_X11 build (Xtrans header/include files)
	mkdir -p nx-X11/exports/include/nx-X11/Xtrans/
	for header in $(NX_XTRANS_HEADERS); do \
	    ${SYMLINK_FILE} ../../../../lib/include/xtrans/$${header} nx-X11/exports/include/nx-X11/Xtrans/$${header}; \
	done

clean-env: version
	for header in $(NX_X11_HEADERS); do \
	    ${RM_FILE} nx-X11/exports/include/nx-X11/$${header}; \
	done
	for header in $(NX_XTRANS_HEADERS); do \
	    ${RM_FILE} nx-X11/exports/include/nx-X11/Xtrans/$${header}; \
	done

154 155
	[ -d exports/include/nx-X11/Xtrans ] && $(RM_DIR) exports/include/nx-X11/Xtrans/ || :
	[ -d exports/include/nx-X11/ ]       && $(RM_DIR) exports/include/nx-X11/        || :
156

157
	${MAKE} -j1 -C nx-X11 clean IMAKE_DEFINES="$(IMAKE_DEFINES)"
158

159
build-lite:
160
	cd nxcomp  && autoreconf -vfsi && (${CONFIGURE}) && ${MAKE}
161 162 163 164
	cd nxproxy && autoreconf -vfsi && (${CONFIGURE}) && ${MAKE}

build-full: build-env
# in the full case, we rely on "magic" in the nx-X11 imake-based makefiles...
165 166

	# build nxcomp first
167
	cd nxcomp && autoreconf -vfsi && (${CONFIGURE} $(CUSTOM_VERSION_DEFINE)) && ${MAKE}
168

169
	# build libNX_X11 second
170
	cd nx-X11/lib && autoreconf -vfsi && (${CONFIGURE} $(CUSTOM_VERSION_DEFINE) --disable-poll) && ${MAKE}
171 172 173 174 175 176
	mkdir -p nx-X11/exports/lib/
	$(SYMLINK_FILE) ../../lib/src/.libs/libNX_X11.so nx-X11/exports/lib/libNX_X11.so
	$(SYMLINK_FILE) ../../lib/src/.libs/libNX_X11.so.6 nx-X11/exports/lib/libNX_X11.so.6
	$(SYMLINK_FILE) ../../lib/src/.libs/libNX_X11.so.6.3.0 nx-X11/exports/lib/libNX_X11.so.6.3.0

	# build nxcompshad third
177
	cd nxcompshad && autoreconf -vfsi && (${CONFIGURE} $(CUSTOM_VERSION_DEFINE)) && ${MAKE}
178

179
	# build nxagent fourth
180
	./mesa-quilt push -a
181 182
	${MAKE} -j1 -C nx-X11 BuildDependsOnly IMAKE_DEFINES="$(IMAKE_DEFINES)"
	${MAKE} -C nx-X11 World USRLIBDIR="$(USRLIBDIR)" SHLIBDIR="$(SHLIBDIR)" IMAKE_DEFINES="$(IMAKE_DEFINES)"
183

184
	# build nxproxy fifth
185
	cd nxproxy && autoreconf -vfsi && (${CONFIGURE} $(CUSTOM_VERSION_DEFINE)) && ${MAKE}
186

187 188 189
	# "build" nxdialog last
	cd nxdialog && autoreconf -vfsi && (${CONFIGURE}) && ${MAKE}

190 191 192 193 194 195 196
build:
	if ! test -d nx-X11; then \
	    ${MAKE} build-lite; \
	else \
	    ${MAKE} build-full; \
	fi

197
install:
198 199 200 201
	$(MAKE) install-lite
	[ ! -d nx-X11 ] || $(MAKE) install-full

install-lite:
202 203 204
	# install nxcomp library
	$(MAKE) -C nxcomp install

205 206
	# install the nxproxy executable and its man page
	$(MAKE) -C nxproxy install
207

208
install-full:
209
	$(MAKE) -C nxcompshad install
210

211
	$(INSTALL_DIR) $(DESTDIR)$(BINDIR)/
212
	$(INSTALL_PROGRAM) nx-X11/programs/Xserver/nxagent-relink $(DESTDIR)$(BINDIR)/nxagent
213

214 215 216
	$(INSTALL_DIR) $(DESTDIR)$(PREFIX)/share/nx
	$(INSTALL_FILE) nx-X11/programs/Xserver/Xext/SecurityPolicy $(DESTDIR)$(PREFIX)/share/nx

217
	# FIXME: Drop this symlink for 3.6.0. Requires that third party frameworks like X2Go have become aware of this...
218
	$(INSTALL_DIR) $(DESTDIR)$(NXLIBDIR)/bin
219
	$(INSTALL_SYMLINK) $(BINDIR)/nxagent $(DESTDIR)$(NXLIBDIR)/bin/nxagent
220

221 222 223 224
	$(INSTALL_DIR) $(DESTDIR)$(PREFIX)/share/man/man1/
	$(INSTALL_FILE) nx-X11/programs/Xserver/hw/nxagent/man/nxagent.1 $(DESTDIR)$(PREFIX)/share/man/man1/
	gzip $(DESTDIR)$(PREFIX)/share/man/man1/*.1

225
	# create a clean nx-X11/.build-exports space
226
	$(RM_DIR_REC) nx-X11/.build-exports
227 228 229 230 231 232
	mkdir -p nx-X11/.build-exports/include
	mkdir -p nx-X11/.build-exports/lib

	# copy headers (for libnx-x11-dev)
	cp -aL nx-X11/exports/include/* nx-X11/.build-exports/include

233
	# copy libs (for libnx-x11), we want the targets of the links
234
	. replace.sh; set -x; find nx-X11/exports/lib/ -name "libNX*.so" | while read libpath; do \
235 236
	    libfile=$$(basename $$libpath); \
	    libdir=$$(dirname $$libpath); \
237
	    link=$$(readlink $$libpath); \
238
	\
239 240
	    mkdir -p "$$(string_rep "$$libdir" exports .build-exports)"; \
	    cp -a "$$(string_rep "$$libpath" "$$libfile" "$$link")" "$$(string_rep "$$libdir" exports .build-exports)"; \
241 242
	done;

243
	$(INSTALL_DIR) $(DESTDIR)$(SHLIBDIR)
244
	$(INSTALL_DIR) $(DESTDIR)$(USRLIBDIR)
245
	$(INSTALL_SYMLINK) ../../libNX_X11.so.6 $(DESTDIR)$(USRLIBDIR)/libX11.so.6
246
	$(INSTALL_SYMLINK) ../../libNX_X11.so.6.3.0 $(DESTDIR)$(USRLIBDIR)/libX11.so.6.3.0
247

248
	. replace.sh; set -x; find nx-X11/.build-exports/include/{nx*,GL} -type d | \
249
	    while read dirname; do \
250
	        $(INSTALL_DIR) "$$(string_rep "$$dirname" nx-X11/.build-exports/include "$(DESTDIR)$(INCLUDEDIR)/")"; \
251
	        $(INSTALL_FILE) $${dirname}/*.h \
252
	                        "$$(string_rep "$$dirname" nx-X11/.build-exports/include "$(DESTDIR)$(INCLUDEDIR)/")"/ || true; \
253 254
	    done; \

255 256
	$(INSTALL_DIR) $(DESTDIR)/$(ETCDIR_NX)
	$(INSTALL_FILE) etc/keystrokes.cfg $(DESTDIR)/$(ETCDIR_NX)/
257 258

	$(INSTALL_DIR) $(DESTDIR)$(PREFIX)/share/nx
259 260
	$(INSTALL_FILE) VERSION $(DESTDIR)$(PREFIX)/share/nx/VERSION.nxagent
	$(INSTALL_FILE) VERSION $(DESTDIR)$(PREFIX)/share/nx/VERSION.nxproxy
261

262 263
	$(MAKE) -C nx-X11/lib install

264 265 266
	# install the nxdialog executable and its man page
	$(MAKE) -C nxdialog install

267
uninstall:
268 269 270 271
	$(MAKE) uninstall-lite
	[ ! -d nx-X11 ] || $(MAKE) uninstall-full

uninstall-lite:
272 273
	test -f nxcomp/Makefile  && ${MAKE} -C nxcomp "$@"
	test -f nxproxy/Makefile && ${MAKE} -C nxproxy "$@"
274

275
	$(RM_FILE) $(DESTDIR)$(PREFIX)/share/nx/VERSION.nxproxy
276
	$(RM_DIR) $(DESTDIR)$(PREFIX)/share/nx/
277 278

uninstall-full:
279 280
	test -f nxcompshad/Makefile && ${MAKE} -C nxcompshad "$@"
	test -f nx-X11/lib/Makefile && ${MAKE} -C nx-X11/lib "$@"
281 282

	$(RM_FILE) $(DESTDIR)$(BINDIR)/nxagent
283

284
	$(RM_FILE) $(DESTDIR)$(PREFIX)/share/nx/VERSION.nxagent
285
	$(RM_DIR) $(DESTDIR)$(PREFIX)/share/nx/
286

287 288
	$(RM_DIR_REC) $(DESTDIR)$(NXLIBDIR)
	$(RM_DIR_REC) $(DESTDIR)$(INCLUDEDIR)/nx
289 290

	test -f nxdialog/Makefile && ${MAKE} -C nxdialog "$@"