aboutsummaryrefslogtreecommitdiffstats
path: root/configure
blob: cfd22a1e656b0967017567713db80b682bca65b3 (plain) (blame)
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
#!/bin/sh

# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved.  This file is offered as-is,
# without any warranty.


have_debug='No, enable with --debug'
have_dummy='No, enable with --enable-dummy'
have_randr='No, enable with --enable-randr'
have_vidmode='No, enable with --enable-vidmode'
have_wayland='No, enable with --enable-wayland'
have_drm='No, enable with --enable-drm'
have_w32gdi='No, enable with --enable-w32gdi[=fake]'
have_quartz='No, enable with --enable-quartz[=fake]'

enable_debug=0
enable_dummy=0
enable_randr=0
enable_vidmode=0
enable_wayland=0
enable_drm=0
enable_w32gdi=0
enable_quartz=0
fake_w32gdi=0
fake_quartz=0

os=common


for arg in "$@"; do
    case "${arg}" in
	(--linux=developer|--developer)  enable_debug=1
					 enable_dummy=1
					 enable_randr=1
					 enable_vidmode=1
					 enable_wayland=1
					 enable_drm=1
					 fake_w32gdi=1
					 fake_quartz=1
					 os=gnu
					 ;;
	(--linux)                        enable_randr=1
					 enable_vidmode=1
					 enable_wayland=1
					 enable_drm=1
					 os=gnu
					 ;;
	(--*bsd=developer)               enable_debug=1
					 enable_dummy=1
					 enable_vidmode=1
					 enable_randr=1
					 fake_w32gdi=1
					 fake_quartz=1
					 ;;
	(--*bsd)                         enable_vidmode=1
					 enable_randr=1
					 ;;
	(--windows=developer)            enable_debug=1
					 enable_dummy=1
					 enable_w32gdi=1
					 os=w32
					 ;;
	(--windows)                      enable_w32gdi=1
					 os=w32
					 ;;
	(--mac-os-x=developer)           enable_debug=1
					 enable_dummy=1
					 enable_quartz=1
					 os=osx
					 ;;
	(--mac-os-x)                     enable_quartz=1
					 os=osx
					 ;;
	(--debug)                        enable_debug=1    ;;
	(--enable-dummy)                 enable_dummy=1    ;;
	(--enable-randr)                 enable_randr=1    ;;
	(--enable-vidmode)               enable_vidmode=1  ;;
	(--enable-wayland)               enable_wayland=1  ;;
	(--enable-drm)                   enable_drm=1      ;;
	(--enable-w32gdi)                enable_w32gdi=1   ;;
	(--enable-quartz)                enable_quartz=1   ;;
	(--enable-w32gdi=fake)           fake_w32gdi=1     ;;
	(--enable-quartz=fake)           fake_quartz=1     ;;
	(*)
	    echo "$0: unrecognised option: ${arg}" >&2
	    exit 1
	    ;;
    esac
done


exec 3> "$(dirname "$0")/.config.mk"
exec 4> "$(dirname "$0")/src/lib/libgamma-config.h"
echo 'DEFINITIONS =' >&3

echo '/**' >&4
cat "$(dirname "$0")/COPYING" | sed -e 's:^: \* :' >&4
echo ' */' >&4
echo '#ifndef LIBGAMMA_CONFIG_H' >&4
echo '#define LIBGAMMA_CONFIG_H' >&4
echo >&4
echo >&4

if [ ${fake_w32gdi} = 1 ]; then
    enable_w32gdi=1
fi
if [ ${fake_quartz} = 1 ]; then
    enable_quartz=1
fi
if [ ${enable_debug} = 1 ]; then
    echo "DEBUG = y" >&3
    echo 'DEBUG_FLAGS += -DDEBUG' >&3
    have_debug='Yes'
fi
if [ ${enable_dummy} = 1 ]; then
    echo 'LIBOBJ += gamma-dummy' >&3
    echo 'DEFINITIONS += -DHAVE_LIBGAMMA_METHOD_DUMMY' >&3
    echo '#define HAVE_LIBGAMMA_METHOD_DUMMY' >&4
    have_dummy='Yes'
fi
if [ ${enable_randr} = 1 ]; then
    echo 'LIBOBJ += gamma-x-randr' >&3
    echo 'DEFINITIONS += -DHAVE_LIBGAMMA_METHOD_X_RANDR' >&3
    echo 'LIBS_LD += $$(pkg-config --libs xcb xcb-randr)' >&3
    echo 'LIBS_C += $$(pkg-config --cflags xcb xcb-randr)' >&3
    echo '#define HAVE_LIBGAMMA_METHOD_X_RANDR' >&4
    have_randr='Yes'
fi
if [ ${enable_vidmode} = 1 ]; then
    echo 'LIBOBJ += gamma-x-vidmode' >&3
    echo 'DEFINITIONS += -DHAVE_LIBGAMMA_METHOD_X_VIDMODE' >&3
    echo 'LIBS_LD += $$(pkg-config --libs x11 xxf86vm)' >&3
    echo 'LIBS_C += $$(pkg-config --cflags x11 xxf86vm)' >&3
    echo '#define HAVE_LIBGAMMA_METHOD_X_VIDMODE' >&4
    have_vidmode='Yes'
fi
if [ ${enable_wayland} = 1 ]; then
    echo 'LIBOBJ += gamma-wayland wayland-gamma-control-protocol' >&3
    echo 'DEFINITIONS += -DHAVE_LIBGAMMA_METHOD_WAYLAND' >&3
    echo 'LIBS_LD += $$(pkg-config --libs wayland-client)' >&3
    echo 'LIBS_C += $$(pkg-config --cflags wayland-client)' >&3
    echo 'WAYLAND_SCANNER = $(shell pkg-config --variable=wayland_scanner wayland-scanner)' >&3
    echo '#define HAVE_LIBGAMMA_METHOD_WAYLAND' >&4
    have_wayland='Yes'
fi
if [ ${enable_drm} = 1 ]; then
    echo 'LIBOBJ += gamma-linux-drm' >&3
    echo 'DEFINITIONS += -DHAVE_LIBGAMMA_METHOD_LINUX_DRM' >&3
    echo 'LIBS_LD += $$(pkg-config --libs libdrm)' >&3
    echo 'LIBS_C += $$(pkg-config --cflags libdrm)' >&3
    echo '#define HAVE_LIBGAMMA_METHOD_LINUX_DRM' >&4
    have_drm='Yes'
fi
if [ ${enable_w32gdi} = 1 ]; then
    echo 'LIBOBJ += gamma-w32-gdi' >&3
    echo 'DEFINITIONS += -DHAVE_LIBGAMMA_METHOD_W32_GDI' >&3
    echo '#define HAVE_LIBGAMMA_METHOD_W32_GDI' >&4
    have_w32gdi='Yes'
fi
if [ ${enable_quartz} = 1 ]; then
    echo 'LIBOBJ += gamma-quartz-cg' >&3
    echo 'DEFINITIONS += -DHAVE_LIBGAMMA_METHOD_QUARTZ_CORE_GRAPHICS' >&3
    if [ ${fake_w32gdi} = 0 ]; then
	F_ApplicationServices="/System/Library/Frameworks/ApplicationServices.framework"
	I_ApplicationServices="${F_ApplicationServices}/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Headers"
	echo "LIBS_LD += -I${I_ApplicationServices} -F${F_ApplicationServices} -framework ApplicationServices" >&3
    fi
    echo '#define HAVE_LIBGAMMA_METHOD_QUARTZ_CORE_GRAPHICS' >&4
    have_quartz='Yes'
fi
if [ ${fake_w32gdi} = 1 ]; then
    echo 'LIBOBJ += fake-w32-gdi' >&3
    echo 'DEFINITIONS += -DFAKE_LIBGAMMA_METHOD_W32_GDI' >&3
    echo '#define FAKE_LIBGAMMA_METHOD_W32_GDI' >&4
    if [ ${enable_randr} = 1 ]; then
	have_w32gdi='Yes, fake via the RandR protocol for X'
    else
	have_w32gdi='Yes, fake via dummy method, `/dev/null`-style'
    fi
fi
if [ ${fake_quartz} = 1 ]; then
    echo 'LIBOBJ += fake-quartz-cg' >&3
    echo 'DEFINITIONS += -DFAKE_LIBGAMMA_METHOD_QUARTZ_CORE_GRAPHICS' >&3
    echo '#define FAKE_LIBGAMMA_METHOD_QUARTZ_CORE_GRAPHICS' >&4
    if [ ${enable_randr} = 1 ]; then
	have_quartz='Yes, fake via the RandR protocol for X'
    else
	have_quartz='Yes, fake via dummy method, `/dev/null`-style'
    fi
fi
if [ ${os} = w32 ]; then
    echo 'SO = dll' >&3
    echo 'PIC = ' >&3
    echo 'SHARED = -mdll' >&3
elif [ ${os} = osx ]; then
    echo 'SO = dylib' >&3
    echo 'SHARED = -dynamiclib' >&3
    echo 'LDSO = ' >&3
elif [ ${os} = gnu ]; then
    echo 'HAVE_INT128 = y' >&3
fi

echo >&4
echo >&4
echo '#endif' >&4
echo >&4

exec 4<&-
exec 3<&-


echo 'libgamma has now been configured.'
echo
echo "  Debug mode:               ${have_debug}"
echo "  Dummy method:             ${have_dummy}"
echo "  X.org via RandR:          ${have_randr}"
echo "  X.org via VidMode:        ${have_vidmode}"
echo "  Wayland/Orbital:          ${have_wayland}"
echo "  Linux DRM:                ${have_drm}"
echo "  Windows GDI:              ${have_w32gdi}"
echo "  Quartz via CoreGraphics:  ${have_quartz}"
echo
echo 'Compile with `make`.'