1#!/usr/bin/make -f
2
3TOP_DIR=$(CURDIR)
4CLIENT_DIR=$(TOP_DIR)/client_build
5CLIENT_BINARY=$(CLIENT_DIR)/x2goclient
6
7SHELL=/bin/bash
8
9INSTALL_DIR=install -d -o root -g root -m 755
10INSTALL_FILE=install -o root -g root -m 644
11INSTALL_SYMLINK=ln -s -f
12INSTALL_PROGRAM=install -o root -g root -m 755
13
14RM_FILE=rm -f
15RM_DIR=rmdir -p --ignore-fail-on-non-empty
16
17DESTDIR=
18PREFIX=/usr/local
19ETCDIR=/etc/x2go
20BINDIR=$(PREFIX)/bin
21SHAREDIR=$(PREFIX)/share
22MANDIR=$(SHAREDIR)/man
23QMAKE_BINARY=qmake-qt4
24LRELEASE_BINARY=lrelease-qt4
25QMAKE_OPTS=
26
27LDFLAGS=
28LIBS=
29
30
31#####################################################################
32# Make sure that variables passed via the command line are not
33# automatically exported.
34#
35# By default, such variables are exported and passed on to child
36# (make) processes, which means that we will run into trouble if we
37# pass CXXFLAGS="some value" as an argument to the top-level
38# make call. Whatever qmake generates will be overridden by this
39# definition, leading to build failures (since the code expects
40# macro values to be set in some cases - which won't be the case
41# for "generic" CXXFLAGS values.)
42#
43# Doing that turns out to be somewhat difficult, though.
44#
45# While preventing make from passing down *options* is possible via
46# giving the new make call an empty MAKEFLAGS value and even though
47# variables defined on the command line are part of MAKEFLAGS, this
48# doesn't affect implicit exporting of variables (for most
49# implementations.)
50#
51# Even worse, the correct way to this stuff differs from make
52# implementation to make implementation.
53
54# GNU make way.
55MAKEOVERRIDES=
56
57# FreeBSD and NetBSD way.
58.MAKEOVERRIDES=
59
60# OpenBSD way.
61.MAKEFLAGS=
62
63
64all: build
65
66build: build_man
67	$(MAKE) build_client
68
69build_client:
70	$(LRELEASE_BINARY) x2goclient.pro
71	mkdir -p $(CLIENT_DIR) && cd $(CLIENT_DIR) && $(QMAKE_BINARY) QMAKE_CFLAGS="${CPPFLAGS} ${CFLAGS}" QMAKE_CXXFLAGS="${CPPFLAGS} ${CXXFLAGS}" QMAKE_LFLAGS="${LDFLAGS}" QMAKE_LIBS="${LIBS}" $(QMAKE_OPTS) ../x2goclient.pro
72	cd $(CLIENT_DIR) && $(MAKE)
73
74build_man:
75	${MAKE} -f Makefile.man2html build
76
77clean: clean_client clean_man
78	find . -maxdepth 3 -name '*.o' -exec rm -vf {} + -type f
79	find . -maxdepth 3 -name 'moc_*.cpp' -exec rm -vf {} + -type f
80	find . -maxdepth 3 -name 'ui_*.h' -exec rm -vf {} + -type f
81	find . -maxdepth 3 -name 'qrc_*.cpp' -exec rm -vf {} + -type f
82	find . -maxdepth 3 -name 'x2goclient_*.qm' -exec rm -vf {} + -type f
83	rm -f x2goclient
84	rm -f x2goclient.tag
85	rm -f res/txt/changelog
86	rm -f res/txt/git-info
87
88clean_client:
89	rm -fr $(CLIENT_DIR)
90
91clean_man:
92	make -f Makefile.man2html clean
93
94install: install_client install_man
95
96install_client:
97	$(INSTALL_DIR) $(DESTDIR)$(BINDIR)/
98	$(INSTALL_DIR) $(DESTDIR)$(SHAREDIR)/applications
99	$(INSTALL_DIR) $(DESTDIR)$(SHAREDIR)/x2goclient/icons
100	$(INSTALL_DIR) $(DESTDIR)$(SHAREDIR)/icons/hicolor/128x128/apps
101	$(INSTALL_DIR) $(DESTDIR)$(SHAREDIR)/icons/hicolor/16x16/apps
102	$(INSTALL_DIR) $(DESTDIR)$(SHAREDIR)/icons/hicolor/64x64/apps
103	$(INSTALL_DIR) $(DESTDIR)$(SHAREDIR)/icons/hicolor/32x32/apps
104	$(INSTALL_PROGRAM) $(CLIENT_DIR)/x2goclient $(DESTDIR)$(BINDIR)/x2goclient
105	$(INSTALL_FILE) desktop/x2goclient.desktop    $(DESTDIR)$(SHAREDIR)/applications/x2goclient.desktop
106	$(INSTALL_FILE) res/img/icons/x2goclient.xpm          $(DESTDIR)$(SHAREDIR)/x2goclient/icons/x2goclient.xpm
107	$(INSTALL_FILE) res/img/icons/128x128/x2goclient.png  $(DESTDIR)$(SHAREDIR)/x2goclient/icons/x2goclient.png
108	$(INSTALL_FILE) res/img/icons/128x128/x2gosession.png $(DESTDIR)$(SHAREDIR)/x2goclient/icons/x2gosession.png
109	$(INSTALL_FILE) res/img/icons/128x128/x2goclient.png  $(DESTDIR)$(SHAREDIR)/icons/hicolor/128x128/apps/x2goclient.png
110	$(INSTALL_FILE) res/img/icons/16x16/x2goclient.png    $(DESTDIR)$(SHAREDIR)/icons/hicolor/16x16/apps/x2goclient.png
111	$(INSTALL_FILE) res/img/icons/64x64/x2goclient.png    $(DESTDIR)$(SHAREDIR)/icons/hicolor/64x64/apps/x2goclient.png
112	$(INSTALL_FILE) res/img/icons/32x32/x2goclient.png    $(DESTDIR)$(SHAREDIR)/icons/hicolor/32x32/apps/x2goclient.png
113
114install_man:
115	$(INSTALL_DIR) $(DESTDIR)$(MANDIR)/
116	$(INSTALL_DIR) $(DESTDIR)$(MANDIR)/man1
117	$(INSTALL_FILE) man/man1/x2goclient.1    $(DESTDIR)$(MANDIR)/man1/x2goclient.1
118	gzip -f $(DESTDIR)$(MANDIR)/man1/x2goclient.1
119
120uninstall: uninstall_client uninstall_man
121
122uninstall_client:
123	$(RM_FILE) $(BINDIR)/x2goclient
124	$(RM_FILE) $(SHAREDIR)/applications/x2goclient.desktop
125	$(RM_FILE) $(SHAREDIR)/x2goclient/icons/x2goclient.png
126	$(RM_FILE) $(SHAREDIR)/x2goclient/icons/x2goclient.xpm
127	$(RM_FILE) $(SHAREDIR)/x2goclient/icons/x2gosession.png
128	$(RM_FILE) $(SHAREDIR)/icons/hicolor/128x128/apps/x2goclient.png
129	$(RM_FILE) $(SHAREDIR)/icons/hicolor/16x16/apps/x2goclient.png
130	$(RM_FILE) $(SHAREDIR)/icons/hicolor/64x64/apps/x2goclient.png
131	$(RM_FILE) $(SHAREDIR)/icons/hicolor/32x32/apps/x2goclient.png
132	$(RM_DIR) $(SHAREDIR)/applications
133	$(RM_DIR) $(SHAREDIR)/x2goclient/icons
134	$(RM_DIR) $(SHAREDIR)/icons/hicolor/128x128/apps
135	$(RM_DIR) $(SHAREDIR)/icons/hicolor/16x16/apps
136	$(RM_DIR) $(SHAREDIR)/icons/hicolor/64x64/apps
137	$(RM_DIR) $(SHAREDIR)/icons/hicolor/32x32/apps
138
139uninstall_man:
140	$(RM_FILE) $(MANDIR)/man1/x2goclient.1.gz
141	$(RM_DIR) $(MANDIR)/man1
142