-
Notifications
You must be signed in to change notification settings - Fork 4
/
configure
executable file
·177 lines (160 loc) · 6.3 KB
/
configure
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
#!/usr/bin/env gosh
;; Configuring Gauche-gl
;; Run ./configure (or gosh ./configure) to generate Makefiles.
(use gauche.configure)
;; glut
;; The actual library name depends on the platform, so we set a dummy
;; value here, and later substitute them.
(define *use-glut* #t)
(define *glut-path* #f)
(cf-arg-with 'glut
(cf-help-string
"--with-glut[=yes|no|mingw-static|PATH]"
"Use GLUT library installed under PATH. \
By default, Gauche-gl assumes GLUT is installed in the system standard \
location. If you do not want to use GLUT support, specify --with-glut=no. \
On MinGW you can statically link freeglut included in the source. \
If you want to choose so, say --with-glut=mingw-static.")
(^[val]
(rxmatch-case val
[#/^no$/ (_) (set! *use-glut* #f)]
[#/^yes$/ (_) (set! *use-glut* #t)]
[#/^mingw-static$/ (_) (set! *use-glut* 'mingw-static)]
[else (set! *glut-path* val)])))
;; glfw
;; we'll check availability later, so we just record the option value.
(define *use-glfw* 'check)
(define *glfw-path* #f)
(cf-arg-with 'glfw
(cf-help-string
"--with-glfw[=PATH]"
"Use GLFW library installed under PATH. \
By default, the availability of GLFW in the system default location is \
checked. If you do not want to use GLFW support, specify --with-glfw=no.")
(^[val]
(rxmatch-case val
[#/^no$/ (_) (set! *use-glfw* #f)]
[#/^yes$/ (_) (set! *use-glfw* #t)]
[else (set! *use-glfw* #t)
(set! *glfw-path* val)])))
;; cg
(cf-arg-enable 'cg
(cf-help-string
"--enable-cg"
"Enable NVidia's Cg binding.")
(^_
(cf-define 'HAVE_CG)
(cf-subst 'ENABLE_CG 1)
(cf-subst 'CG_LIBS "-lCgCL -lCg")
(cf-subst 'CG_SCM "cg/gl/cg.scm"))
(^[]
(cf-subst 'ENABLE_CG "")
(cf-subst 'CG_LIBS "")
(cf-subst 'CG_SCM "")))
;; Initialize configure. This creates the global context, parses
;; command-line args and sets up default values.
(cf-init-gauche-extension)
;; Check target-dependent glut library
(case *use-glut*
[(mingw-static)
;; We use internal freeglut
(cf-subst 'GLUT_LIB "-lfreeglut_static -lgdi32 -lwinmm")
(cf-subst 'GLUT_INCDIR "-I../win32/freeglut-3.0.0-1/include -DFREEGLUT_STATIC")
;; MSYS2 config.guess reports x86_64-pc-mingw64 on 64bit system,
;; but MSYS2/mingw-w64 toolchain canonically use x86_64-w64-mingw32.
(rxmatch-case (cf$ 'target)
[#/x86_64-.*mingw.*/ (_)
(cf-subst 'GLUT_LIBDIR "-L../win32/freeglut-3.0.0-1/lib/x64")]
[else
(cf-subst 'GLUT_LIBDIR "-L../win32/freeglut-3.0.0-1/lib")])]
[(#t)
(cf-subst 'GLUT_LIB "-lglut")
(if *glut-path*
(begin (cf-subst 'GLUT_INCDIR #"-I~|*glut-path*|/include")
(cf-subst 'GLUT_LIBDIR #"-L~|*glut-path*|/lib"))
(begin (cf-subst 'GLUT_INCDIR "")
(cf-subst 'GLUT_LIBDIR "")))]
[(#f)
(cf-subst 'GLUT_LIB "")
(cf-subst 'GLUT_INCDIR "")
(cf-subst 'GLUT_LIBDIR "")])
;; Set appropriate libraries
(cf-check-headers '("GL/glx.h")
:if-found
(^_
(cf-subst 'GL_LIBS "-lGLU -lGL -lX11 -lXext")
(cf-subst-append 'GLUT_LIB "-lXmu -lXi")))
(cf-check-headers '("GLUT/glut.h") ; darwin on MacOSX
:if-found
(^_
(cf-subst-append 'CFLAGS "-DMacOSX=1")
(cf-subst 'GL_LIBS "-framework OpenGL -framework GLUT")
(cf-subst 'GLUT_LIB "-framework GLUT")))
;; Link opengl libs
(unless (cf-ref 'GL_LIBS #f)
(rxmatch-case (cf$ 'target)
[#/.*-mingw.*/ (_)
(cf-subst 'GL_LIBS "-lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32")]
[else
(cf-subst 'GL_LIBS "-lGLU -lGL")]))
;; Check GLFW availability
(when *use-glfw*
(when *glfw-path*
(cf-subst-append 'CPPFLAGS #"-I~|*glfw-path*|/include")
(cf-subst-append 'LDFLAGS #"-L~|*glfw-path*|/lib"))
(cf-check-headers '("GLFW/glfw3.h"))
(when (cf-search-libs "glfwInit" '("glfw" "glfw3"))
(cf-define 'HAVE_LIBGLFW)))
(cond [(and (cf-defined? 'HAVE_GLFW_GLFW3_H)
(cf-defined? 'HAVE_LIBGLFW))
(cf-subst 'USE_GLFW_yes "")
(cf-subst 'USE_GLFW_no "#")]
[(eq? *use-glfw* #t)
(cf-msg-error "Can't find glfw library. Aborting...")]
[else
(cf-subst 'USE_GLFW_yes "#")
(cf-subst 'USE_GLFW_no "")])
(cond [*glfw-path*
(cf-subst 'GLFW_INCDIR #"~|*glfw-path*|/include")
(cf-subst 'GLFW_LIBDIR #"~|*glfw-path*|/lib")]
[else
(cf-subst 'GLFW_INCDIR "")
(cf-subst 'GLFW_LIBDIR "")])
;; Check Vulkan availiability
(cf-check-headers '("vulkan/vulkan.h"))
(cf-check-lib "vulkan" "vkCreateInstance")
(cond [(and (cf-defined? 'HAVE_VULKAN_VULKAN_H)
(cf-defined? 'HAVE_LIBVULKAN))
(cf-subst 'USE_VULKAN_yes "")
(cf-subst 'USE_VULKAN_no "#")]
[else
(cf-subst 'USE_VULKAN_yes "#")
(cf-subst 'USE_VULKAN_no "")])
;; On MinGW, we use GLEW so that we can get newer GL features; the GL header
;; comes with MinGW installation is very old.
;; TODO: We might add --with-glew configure option so that we can use glew
;; on other platforms. At this moment, though, Gauche-gl has its own
;; runtime name lookup system, so having glew isn't vital on other platforms.
(cond [(#/.*-mingw.*/ (cf$ 'target))
(cf-define 'HAVE_GL_GLEW_H)
(cf-subst 'GLEW_INCDIR "-I../win32/glew-2.1.0/include -DGLEW_STATIC")
(cf-subst 'GLEW_SOURCE "../win32/glew-2.1.0/src/glew.c")]
[else
(cf-subst 'GLEW_INCDIR "")
(cf-subst 'GLEW_SOURCE "")])
;; Check for other programs.
(cf-check-prog 'MAKEINFO "makeinfo" :default "")
(cf-check-prog 'GZIP_PROGRAM "gzip" :default "")
;; On Windows, we need several extra -l flags.
(cond [(#/.*-mingw.*/ (cf$ 'target))
(cf-subst 'GL_EXTRALIBS "-L. -lgauche-math3d")
(cf-subst 'GLUT_EXTRALIBS "-L. -lgauche-gl -lgauche-math3d")]
[else
(cf-subst 'GL_EXTRALIBS "")
(cf-subst 'GLUT_EXTRALIBS "")])
;; Output
(cf-config-headers "src/gauche/gl-config.h")
(cf-output-default)
;; Local variables:
;; mode: scheme
;; end: