| 1 |
#!/usr/bin/make -f |
| 2 |
|
| 3 |
NULL = |
| 4 |
|
| 5 |
# suppress most make output unless "make VERBOSE=1" has been called |
| 6 |
ifndef VERBOSE |
| 7 |
.SILENT: |
| 8 |
endif |
| 9 |
|
| 10 |
# helpers for "install" target |
| 11 |
INSTALL_DIR=install -d -m 755 |
| 12 |
INSTALL_FILE=install -m 644 |
| 13 |
INSTALL_PROGRAM=install -m 755 |
| 14 |
INSTALL_SYMLINK=ln -s -f |
| 15 |
|
| 16 |
# helpers for "build" target |
| 17 |
SYMLINK_FILE=ln -f -s |
| 18 |
|
| 19 |
# helpers for "clean" and "uninstall" targets |
| 20 |
RM_FILE=rm -f |
| 21 |
RM_DIR=rmdir -p --ignore-fail-on-non-empty |
| 22 |
RM_DIR_REC=rm -Rf |
| 23 |
|
| 24 |
ETCDIR_NX ?= /etc/nxagent |
| 25 |
PREFIX ?= /usr/local |
| 26 |
BINDIR ?= $(PREFIX)/bin |
| 27 |
LIBDIR ?= $(PREFIX)/lib |
| 28 |
SHLIBDIR ?= $(LIBDIR) |
| 29 |
NXLIBDIR ?= $(SHLIBDIR)/nx |
| 30 |
USRLIBDIR ?= $(NXLIBDIR)/X11 |
| 31 |
INCLUDEDIR ?= $(PREFIX)/include |
| 32 |
CONFIGURE ?= ./configure --prefix="$(PREFIX)" |
| 33 |
|
| 34 |
# check if the xkbcomp devel pkg is available - we need it for the next step |
| 35 |
ifneq ($(shell pkg-config --exists xkbcomp && echo yes), yes) |
| 36 |
$(warning xkbcomp devel package missing, using imake default values) |
| 37 |
endif |
| 38 |
ifneq ($(shell pkg-config --exists fontutil && echo yes), yes) |
| 39 |
$(warning fontutil devel package missing, using imake default values) |
| 40 |
endif |
| 41 |
|
| 42 |
ifneq "$(strip $(NX_VERSION_CUSTOM))" "" |
| 43 |
CUSTOM_VERSION_DEFINE = NX_VERSION_CUSTOM="$(NX_VERSION_CUSTOM)" |
| 44 |
endif |
| 45 |
|
| 46 |
IMAKE_DEFINES ?= |
| 47 |
|
| 48 |
SHELL:=/bin/bash |
| 49 |
|
| 50 |
NX_X11_HEADERS = \ |
| 51 |
Xlib.h \ |
| 52 |
Xresource.h \ |
| 53 |
Xutil.h \ |
| 54 |
cursorfont.h \ |
| 55 |
Xlibint.h \ |
| 56 |
Xcms.h \ |
| 57 |
Xlocale.h \ |
| 58 |
XKBlib.h \ |
| 59 |
XlibConf.h \ |
| 60 |
Xregion.h \ |
| 61 |
ImUtil.h \ |
| 62 |
$(NULL) |
| 63 |
|
| 64 |
NX_XTRANS_HEADERS = \ |
| 65 |
transport.c \ |
| 66 |
Xtrans.c \ |
| 67 |
Xtrans.h \ |
| 68 |
Xtransint.h \ |
| 69 |
Xtranslcl.c \ |
| 70 |
Xtranssock.c \ |
| 71 |
Xtransutil.c \ |
| 72 |
$(NULL) |
| 73 |
|
| 74 |
all: build |
| 75 |
|
| 76 |
clean: version imakeconfig |
| 77 |
@echo |
| 78 |
@echo "===> $@" |
| 79 |
test -f nxcomp/Makefile && ${MAKE} -C nxcomp clean || true |
| 80 |
test -f nxproxy/Makefile && ${MAKE} -C nxproxy clean || true |
| 81 |
test -f nx-X11/lib/Makefile && ${MAKE} -C nx-X11/lib clean || true |
| 82 |
test -f nxcompshad/Makefile && ${MAKE} -C nxcompshad clean || true |
| 83 |
test -d nx-X11 && ${MAKE} clean-env || true |
| 84 |
test -f nxdialog/Makefile && ${MAKE} -C nxdialog clean || true |
| 85 |
@echo "<=== $@" |
| 86 |
|
| 87 |
distclean: clean version imakeconfig |
| 88 |
@echo |
| 89 |
@echo "===> $@" |
| 90 |
test -f nxcomp/Makefile && ${MAKE} -C nxcomp distclean || true |
| 91 |
test -f nxproxy/Makefile && ${MAKE} -C nxproxy distclean || true |
| 92 |
test -f nx-X11/lib/Makefile && ${MAKE} -C nx-X11/lib distclean || true |
| 93 |
test -f nxcompshad/Makefile && ${MAKE} -C nxcompshad distclean || true |
| 94 |
test -d nx-X11 && ${MAKE} -C nx-X11 distclean || true |
| 95 |
test -f nxdialog/Makefile && ${MAKE} -C nxdialog distclean || true |
| 96 |
test -x ./mesa-quilt && ./mesa-quilt pop -a |
| 97 |
$(RM_DIR_REC) nx-X11/extras/Mesa/.pc/ |
| 98 |
$(RM_FILE) nx-X11/config/cf/nxversion.def |
| 99 |
$(RM_FILE) nx-X11/config/cf/nxconfig.def |
| 100 |
@echo "<=== $@" |
| 101 |
|
| 102 |
test: |
| 103 |
@echo "No testing for NX (redistributed)" |
| 104 |
|
| 105 |
version: |
| 106 |
# prepare nx-X11/config/cf/nxversion.def |
| 107 |
sed \ |
| 108 |
-e 's/###NX_VERSION_MAJOR###/$(shell ./version.sh 1)/' \ |
| 109 |
-e 's/###NX_VERSION_MINOR###/$(shell ./version.sh 2)/' \ |
| 110 |
-e 's/###NX_VERSION_MICRO###/$(shell ./version.sh 3)/' \ |
| 111 |
-e 's/###NX_VERSION_PATCH###/$(shell ./version.sh 4)/' \ |
| 112 |
nx-X11/config/cf/nxversion.def.in \ |
| 113 |
> nx-X11/config/cf/nxversion.def |
| 114 |
ifneq "$(strip $(NX_VERSION_CUSTOM))" "" |
| 115 |
echo '#define NX_VERSION_CUSTOM $(NX_VERSION_CUSTOM)' >>nx-X11/config/cf/nxversion.def |
| 116 |
endif |
| 117 |
|
| 118 |
imakeconfig: |
| 119 |
@echo; |
| 120 |
@echo "===> $@" |
| 121 |
# auto-config some setting |
| 122 |
|
| 123 |
# check if system supports Xfont2 |
| 124 |
(echo "#define HasXfont2 `pkg-config --exists xfont2 && echo YES || echo NO`") >nx-X11/config/cf/nxconfig.def |
| 125 |
|
| 126 |
# check if system has an _old_ release of Xfont1 |
| 127 |
(echo "#define HasLegacyXfont1 `pkg-config --exists 'xfont < 1.4.2' && echo YES || echo NO`") >>nx-X11/config/cf/nxconfig.def |
| 128 |
|
| 129 |
# check if system has an _old_ release of XextProto |
| 130 |
(echo "#define HasLegacyXextProto `pkg-config --exists 'xextproto < 7.1.0' && echo YES || echo NO`") >>nx-X11/config/cf/nxconfig.def |
| 131 |
|
| 132 |
# the system's directory with the xkb data and binary files (these |
| 133 |
# needs to be independent of Imake's ProjectRoot or the configure |
| 134 |
# prefix.) |
| 135 |
(pkg-config --exists xkbcomp && echo "#define SystemXkbConfigDir `pkg-config xkbcomp --variable=xkbconfigdir`"; :) >>nx-X11/config/cf/nxconfig.def |
| 136 |
(pkg-config --exists xkbcomp && echo "#define SystemXkbBinDir `pkg-config xkbcomp --variable=prefix`/bin"; :) >>nx-X11/config/cf/nxconfig.def |
| 137 |
|
| 138 |
(pkg-config --exists fontutil && echo "#define SystemFontRootDir `pkg-config fontutil --variable=fontrootdir`"; :) >>nx-X11/config/cf/nxconfig.def |
| 139 |
|
| 140 |
# let's create the nx-X11 Makefiles now, once everything has been defined |
| 141 |
$(MAKE) -j1 -C nx-X11 Makefiles IMAKE_DEFINES="$(IMAKE_DEFINES)" |
| 142 |
@echo "<=== $@" |
| 143 |
|
| 144 |
build-env: version imakeconfig |
| 145 |
@echo |
| 146 |
@echo "===> $@" |
| 147 |
# prepare Makefiles and the nx-X11 symlinking magic |
| 148 |
${MAKE} -j1 -C nx-X11 BuildIncludes IMAKE_DEFINES="$(IMAKE_DEFINES)" |
| 149 |
|
| 150 |
# set up environment for libNX_X11 build (X11 header files) |
| 151 |
mkdir -p nx-X11/exports/include/nx-X11/ |
| 152 |
for header in $(NX_X11_HEADERS); do \ |
| 153 |
${SYMLINK_FILE} ../../../lib/include/X11/$${header} nx-X11/exports/include/nx-X11/$${header}; \ |
| 154 |
done |
| 155 |
|
| 156 |
# set up environment for libNX_X11 build (Xtrans header/include files) |
| 157 |
mkdir -p nx-X11/exports/include/nx-X11/Xtrans/ |
| 158 |
for header in $(NX_XTRANS_HEADERS); do \ |
| 159 |
${SYMLINK_FILE} ../../../../lib/include/xtrans/$${header} nx-X11/exports/include/nx-X11/Xtrans/$${header}; \ |
| 160 |
done |
| 161 |
@echo "<=== $@" |
| 162 |
|
| 163 |
clean-env: version |
| 164 |
@echo |
| 165 |
@echo "===> $@" |
| 166 |
for header in $(NX_X11_HEADERS); do \ |
| 167 |
${RM_FILE} nx-X11/exports/include/nx-X11/$${header}; \ |
| 168 |
done |
| 169 |
for header in $(NX_XTRANS_HEADERS); do \ |
| 170 |
${RM_FILE} nx-X11/exports/include/nx-X11/Xtrans/$${header}; \ |
| 171 |
done |
| 172 |
|
| 173 |
[ -d exports/include/nx-X11/Xtrans ] && $(RM_DIR) exports/include/nx-X11/Xtrans/ || : |
| 174 |
[ -d exports/include/nx-X11/ ] && $(RM_DIR) exports/include/nx-X11/ || : |
| 175 |
|
| 176 |
${MAKE} -j1 -C nx-X11 clean IMAKE_DEFINES="$(IMAKE_DEFINES)" |
| 177 |
@echo "<=== $@" |
| 178 |
|
| 179 |
build-lite: |
| 180 |
@echo |
| 181 |
@echo "===> $@" |
| 182 |
cd nxcomp && autoreconf -vfsi && (${CONFIGURE}) && ${MAKE} |
| 183 |
cd nxproxy && autoreconf -vfsi && (${CONFIGURE}) && ${MAKE} |
| 184 |
@echo "<=== $@" |
| 185 |
|
| 186 |
build-full: build-env |
| 187 |
# in the full case, we rely on "magic" in the nx-X11 imake-based makefiles... |
| 188 |
|
| 189 |
@echo |
| 190 |
@echo "===> $@" |
| 191 |
|
| 192 |
# build nxcomp first |
| 193 |
cd nxcomp && autoreconf -vfsi && (${CONFIGURE} $(CUSTOM_VERSION_DEFINE)) && ${MAKE} |
| 194 |
|
| 195 |
# build libNX_X11 second |
| 196 |
cd nx-X11/lib && autoreconf -vfsi && (${CONFIGURE} $(CUSTOM_VERSION_DEFINE) --disable-poll) && ${MAKE} |
| 197 |
mkdir -p nx-X11/exports/lib/ |
| 198 |
$(SYMLINK_FILE) ../../lib/src/.libs/libNX_X11.so nx-X11/exports/lib/libNX_X11.so |
| 199 |
$(SYMLINK_FILE) ../../lib/src/.libs/libNX_X11.so.6 nx-X11/exports/lib/libNX_X11.so.6 |
| 200 |
$(SYMLINK_FILE) ../../lib/src/.libs/libNX_X11.so.6.3.0 nx-X11/exports/lib/libNX_X11.so.6.3.0 |
| 201 |
|
| 202 |
# build nxcompshad third |
| 203 |
cd nxcompshad && autoreconf -vfsi && (${CONFIGURE} $(CUSTOM_VERSION_DEFINE)) && ${MAKE} |
| 204 |
|
| 205 |
# build nxagent fourth |
| 206 |
./mesa-quilt push -a |
| 207 |
${MAKE} -j1 -C nx-X11 BuildDependsOnly IMAKE_DEFINES="$(IMAKE_DEFINES)" |
| 208 |
${MAKE} -C nx-X11 World USRLIBDIR="$(USRLIBDIR)" SHLIBDIR="$(SHLIBDIR)" IMAKE_DEFINES="$(IMAKE_DEFINES)" |
| 209 |
|
| 210 |
# build nxproxy fifth |
| 211 |
cd nxproxy && autoreconf -vfsi && (${CONFIGURE} $(CUSTOM_VERSION_DEFINE)) && ${MAKE} |
| 212 |
|
| 213 |
# "build" nxdialog last |
| 214 |
cd nxdialog && autoreconf -vfsi && (${CONFIGURE}) && ${MAKE} |
| 215 |
@echo "<=== $@" |
| 216 |
|
| 217 |
build: |
| 218 |
@echo |
| 219 |
@echo "===> $@" |
| 220 |
if ! test -d nx-X11; then \ |
| 221 |
${MAKE} build-lite; \ |
| 222 |
else \ |
| 223 |
${MAKE} build-full; \ |
| 224 |
fi |
| 225 |
@echo "<=== $@" |
| 226 |
|
| 227 |
install: |
| 228 |
$(MAKE) install-lite |
| 229 |
[ ! -d nx-X11 ] || $(MAKE) install-full |
| 230 |
|
| 231 |
install-lite: |
| 232 |
# install nxcomp library |
| 233 |
$(MAKE) -C nxcomp install |
| 234 |
|
| 235 |
# install the nxproxy executable and its man page |
| 236 |
$(MAKE) -C nxproxy install |
| 237 |
|
| 238 |
install-full: |
| 239 |
$(MAKE) -C nxcompshad install |
| 240 |
|
| 241 |
$(INSTALL_DIR) $(DESTDIR)$(BINDIR)/ |
| 242 |
$(INSTALL_PROGRAM) nx-X11/programs/Xserver/nxagent-relink $(DESTDIR)$(BINDIR)/nxagent |
| 243 |
|
| 244 |
$(INSTALL_DIR) $(DESTDIR)$(PREFIX)/share/nx |
| 245 |
$(INSTALL_FILE) nx-X11/programs/Xserver/Xext/SecurityPolicy $(DESTDIR)$(PREFIX)/share/nx |
| 246 |
|
| 247 |
# FIXME: Drop this symlink for 3.6.0. Requires that third party frameworks like X2Go have become aware of this... |
| 248 |
$(INSTALL_DIR) $(DESTDIR)$(NXLIBDIR)/bin |
| 249 |
$(INSTALL_SYMLINK) $(BINDIR)/nxagent $(DESTDIR)$(NXLIBDIR)/bin/nxagent |
| 250 |
|
| 251 |
$(INSTALL_DIR) $(DESTDIR)$(PREFIX)/share/man/man1/ |
| 252 |
$(INSTALL_FILE) nx-X11/programs/Xserver/hw/nxagent/man/nxagent.1 $(DESTDIR)$(PREFIX)/share/man/man1/ |
| 253 |
gzip $(DESTDIR)$(PREFIX)/share/man/man1/*.1 |
| 254 |
|
| 255 |
# create a clean nx-X11/.build-exports space |
| 256 |
$(RM_DIR_REC) nx-X11/.build-exports |
| 257 |
mkdir -p nx-X11/.build-exports/include |
| 258 |
mkdir -p nx-X11/.build-exports/lib |
| 259 |
|
| 260 |
# copy headers (for libnx-x11-dev) |
| 261 |
cp -aL nx-X11/exports/include/* nx-X11/.build-exports/include |
| 262 |
|
| 263 |
# copy libs (for libnx-x11), we want the targets of the links |
| 264 |
. replace.sh; set -x; find nx-X11/exports/lib/ -name "libNX*.so" | while read libpath; do \ |
| 265 |
libfile=$$(basename $$libpath); \ |
| 266 |
libdir=$$(dirname $$libpath); \ |
| 267 |
link=$$(readlink $$libpath); \ |
| 268 |
\ |
| 269 |
mkdir -p "$$(string_rep "$$libdir" exports .build-exports)"; \ |
| 270 |
cp -a "$$(string_rep "$$libpath" "$$libfile" "$$link")" "$$(string_rep "$$libdir" exports .build-exports)"; \ |
| 271 |
done; |
| 272 |
|
| 273 |
$(INSTALL_DIR) $(DESTDIR)$(SHLIBDIR) |
| 274 |
$(INSTALL_DIR) $(DESTDIR)$(USRLIBDIR) |
| 275 |
$(INSTALL_SYMLINK) ../../libNX_X11.so.6 $(DESTDIR)$(USRLIBDIR)/libX11.so.6 |
| 276 |
$(INSTALL_SYMLINK) ../../libNX_X11.so.6.3.0 $(DESTDIR)$(USRLIBDIR)/libX11.so.6.3.0 |
| 277 |
|
| 278 |
. replace.sh; set -x; find nx-X11/.build-exports/include/{nx*,GL} -type d | \ |
| 279 |
while read dirname; do \ |
| 280 |
$(INSTALL_DIR) "$$(string_rep "$$dirname" nx-X11/.build-exports/include "$(DESTDIR)$(INCLUDEDIR)/")"; \ |
| 281 |
$(INSTALL_FILE) $${dirname}/*.h \ |
| 282 |
"$$(string_rep "$$dirname" nx-X11/.build-exports/include "$(DESTDIR)$(INCLUDEDIR)/")"/ || true; \ |
| 283 |
done; \ |
| 284 |
|
| 285 |
$(INSTALL_DIR) $(DESTDIR)/$(ETCDIR_NX) |
| 286 |
$(INSTALL_FILE) etc/keystrokes.cfg $(DESTDIR)/$(ETCDIR_NX)/ |
| 287 |
|
| 288 |
$(INSTALL_DIR) $(DESTDIR)$(PREFIX)/share/nx |
| 289 |
$(INSTALL_FILE) VERSION $(DESTDIR)$(PREFIX)/share/nx/VERSION.nxagent |
| 290 |
$(INSTALL_FILE) VERSION $(DESTDIR)$(PREFIX)/share/nx/VERSION.nxproxy |
| 291 |
|
| 292 |
$(MAKE) -C nx-X11/lib install |
| 293 |
|
| 294 |
# install the nxdialog executable and its man page |
| 295 |
$(MAKE) -C nxdialog install |
| 296 |
|
| 297 |
uninstall: |
| 298 |
$(MAKE) uninstall-lite |
| 299 |
[ ! -d nx-X11 ] || $(MAKE) uninstall-full |
| 300 |
|
| 301 |
uninstall-lite: |
| 302 |
test -f nxcomp/Makefile && ${MAKE} -C nxcomp "$@" |
| 303 |
test -f nxproxy/Makefile && ${MAKE} -C nxproxy "$@" |
| 304 |
|
| 305 |
$(RM_FILE) $(DESTDIR)$(PREFIX)/share/nx/VERSION.nxproxy |
| 306 |
$(RM_DIR) $(DESTDIR)$(PREFIX)/share/nx/ |
| 307 |
|
| 308 |
uninstall-full: |
| 309 |
test -f nxcompshad/Makefile && ${MAKE} -C nxcompshad "$@" |
| 310 |
test -f nx-X11/lib/Makefile && ${MAKE} -C nx-X11/lib "$@" |
| 311 |
|
| 312 |
$(RM_FILE) $(DESTDIR)$(BINDIR)/nxagent |
| 313 |
|
| 314 |
$(RM_FILE) $(DESTDIR)$(PREFIX)/share/nx/VERSION.nxagent |
| 315 |
$(RM_DIR) $(DESTDIR)$(PREFIX)/share/nx/ |
| 316 |
|
| 317 |
$(RM_DIR_REC) $(DESTDIR)$(NXLIBDIR) |
| 318 |
$(RM_DIR_REC) $(DESTDIR)$(INCLUDEDIR)/nx |
| 319 |
|
| 320 |
test -f nxdialog/Makefile && ${MAKE} -C nxdialog "$@" |