File: config.pkg

package info (click to toggle)
libt3key 0.2.10-1
  • links: PTS
  • area: main
  • in suites: bullseye, sid
  • size: 580 kB
  • sloc: ansic: 2,543; sh: 948; xml: 172; makefile: 70
file content (201 lines) | stat: -rw-r--r-- 5,487 bytes parent folder | download
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
# Copyright (C) 2011-2012 G.P. Halkes
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3, as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

EXTENSIONS="c libtool pkgconfig verbose_compile pkgconfig_dep gettext x11 lfs"
MAKEFILES="Makefile mk/libt3key mk/t3keyc mk/t3learnkeys"
LTSHARED=1
DEFAULT_LINGUAS=nl
SWITCHES="+t3learnkeys"
USERHELP=print_help
INSTALLDIRS="bindir libdir datadir docdir mandir includedir"


print_help() {
	echo "  --without-t3learnkeys   Do not build the t3learnkeys program"
}

test_select() {
	DESC="$1"
	shift
	clean_c
	for HEADER in "$@"
	do
		echo "#include <${HEADER}>"
	done > .config.c
	cat >> .config.c <<EOF
#include <stdlib.h>

int main(int argc, char *argv[]) {
	fd_set test;
	FD_ZERO(&test);
	FD_SET(0, &test);
	FD_ISSET(0, &test);
	FD_CLR(0, &test);
	select(1, &test, NULL, NULL, NULL);
	return 0;
}
EOF
	test_link "${DESC}"
}


config() {
	clean_c
	cat > .config.c << EOF
#include <unistd.h>

int main(int argc, char *argv[]) {
	symlink("/foo", "/bar");
	return 0;
}
EOF
	test_link "required functions" || error "!! Some required functionality is not available. See config.log for details."

	clean_c
	cat > .config.c <<EOF
#include <t3config/config.h>

int main(int argc, char *argv[]) {
	t3_config_get_version();
	return 0;
}
EOF
	pkgconfig libt3config/0.2.5 LIBT3CONFIG test_link PKGCONFIG_REQUIRES || \
		error "!! Can not find libt3config. libt3config is required to compile libt3key."

	if [ yes = "${with_t3learnkeys}" ] ; then
		clean_c
		cat > .config.c << EOF
#include <termios.h>
#include <unistd.h>
#include <stdio.h>
#include <search.h>

int compar(const void *a, const void *b) {
	return a < b;
}

int main(int argc, char *argv[]) {
	struct termios attr;
	int result;
	char buf[1024];
	size_t size = 0;

	usleep(500);
	isatty(result);
	result = (int) read(argc, buf, sizeof(buf));
	result = lfind(&result, &result, &size, sizeof(result), compar) == NULL;
	tcgetattr(argc, &attr);
	tcsetattr(argc, TCSADRAIN, &attr);
	snprintf(buf, sizeof(buf), "%d", result);
	return 0;
}
EOF
		test_link "required functions for t3learnkeys" || error "!! Some required functionality for t3learnkeys is not available. See config.log for details. Try configuring with --without-t3learnkeys."
		if test_select "select in <sys/select.h>" "sys/select.h" ; then
			CONFIGFLAGS="${CONFIGFLAGS} -DHAS_SELECT_H"
		else
			test_select "select in <unistd.h>" "sys/time.h" "sys/types.h" "unistd.h" || error "!! Can not find required select function. Try configuring with --without-t3learnkeys."
		fi

		clean_c
		cat > .config.c <<EOF
#include <stdlib.h>
#include <xcb/xcb.h>

int main(int argc, char *argv[]) {
	int value;
	xcb_connection_t *c = xcb_connect(NULL, NULL);
	value = XCB_MOD_MASK_CONTROL;
	value = XCB_MOD_MASK_SHIFT;
	value = XCB_MOD_MASK_1;
	value = XCB_TIME_CURRENT_TIME;
	value = XCB_WINDOW_NONE;
}
EOF
		if pkgconfig xcb X11 test_link ; then
			:
		else
			check_message_result "!! Could not find X11 library. t3learnkeys will not provide the --auto-learn option."
			X11_FLAGS="-DNO_AUTOLEARN"
		fi
	else
		MAKEFILES="Makefile mk/libt3key mk/t3keyc"
		cat > mk/t3learnkeys <<EOF
all:
clean:
dist-clean:
EOF
	fi

	unset CURSES_LIBS CURSES_FLAGS
	clean_c
	cat > .config.c <<EOF
#include <stdio.h>
#include <stdlib.h>
#include <curses.h>

int main(int argc, char *argv[]) {
	int args[9], error, fd;

	if (setupterm(NULL, fd, &error) == OK) {
		tigetstr("cup");
		tigetnum("colors");
		tigetflag("km");
		tputs("\033[0m", 1, putchar);
		tparm("\033[0m", args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]);
	}
	return 0;
}
EOF
	if pkgconfig tinfo CURSES test_link PKGCONFIG_REQUIRES_PRIVATE; then
		:
	elif pkgconfig ncurses CURSES test_link PKGCONFIG_REQUIRES_PRIVATE; then
		:
	elif test_compile "curses header file" ; then
		if test_link "terminfo access functions in -ltinfo" "TESTLIBS=-ltinfo" ; then
			CURSES_LIBS="-ltinfo"
		elif test_link "curses library in -lcurses" "TESTLIBS=-lcurses" ; then
			CURSES_LIBS="-lcurses"
		else
			if test_link "ncurses library in -lncurses" "TESTLIBS=-lncurses" ; then
				CURSES_LIBS="-lncurses"
			else
				error "!! Can not find curses/tinfo library. The curses/tinfo library is required to compile libt3key."
			fi
		fi
		PKGCONFIG_LIBS_PRIVATE="${PKGCONFIG_LIBS_PRIVATE} ${CURSES_LIBS}"
	else
		error "!! Can not find curses/tinfo library. The curses/tinfo library is required to compile libt3key."
	fi

	clean_c
	cat > .config.c <<EOF
#include <string.h>
int main(int argc, char *argv[]) {
	strdup("foo");
}
EOF
	test_link "strdup" && CONFIGFLAGS="${CONFIGFLAGS} -DHAS_STRDUP"

	PKGCONFIG_DESC="Terminal key database"
	PKGCONFIG_VERSION="0.2.10"
	PKGCONFIG_URL="http://os.ghalkes.nl/t3/libt3key.html"
	PKGCONFIG_CFLAGS="-I\${includedir}/t3/key"
	PKGCONFIG_LIBS="-lt3key"

	gen_pkgconfig libt3key
	create_makefile "CONFIGFLAGS=${CONFIGFLAGS} ${CURSES_FLAGS} ${LIBT3CONFIG_FLAGS}" \
		"CONFIGLIBS=${CONFIGLIBS} ${CURSES_LIBS} ${LIBT3CONFIG_LIBS}" "X11_FLAGS=${X11_FLAGS}" \
		"X11_LIBS=${X11_LIBS}"
}