Makefile 11.4 KB
Newer Older
ikits's avatar
ikits committed
1
#!gmake
ikits's avatar
ikits committed
2
## The OpenGL Extension Wrangler Library
ikits's avatar
ikits committed
3
4
## Copyright (C) 2002-2008, Milan Ikits <milan ikits[]ieee org>
## Copyright (C) 2002-2008, Marcelo E. Magallon <mmagallo[]debian org>
ikits's avatar
ikits committed
5
## Copyright (C) 2002, Lev Povalahev
ikits's avatar
ikits committed
6
7
8
9
10
11
12
13
14
15
16
17
## All rights reserved.
## 
## Redistribution and use in source and binary forms, with or without 
## modification, are permitted provided that the following conditions are met:
## 
## * Redistributions of source code must retain the above copyright notice, 
##   this list of conditions and the following disclaimer.
## * Redistributions in binary form must reproduce the above copyright notice, 
##   this list of conditions and the following disclaimer in the documentation 
##   and/or other materials provided with the distribution.
## * The name of the author may be used to endorse or promote products 
##   derived from this software without specific prior written permission.
ikits's avatar
ikits committed
18
##
ikits's avatar
ikits committed
19
20
21
22
23
24
25
26
27
28
29
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
## ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
## LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
## CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
## SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
## INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
## THE POSSIBILITY OF SUCH DAMAGE.
ikits's avatar
ikits committed
30

mem's avatar
mem committed
31
include config/version
mem's avatar
mem committed
32
33

SHELL = /bin/sh
34
SYSTEM ?= $(shell config/config.guess | cut -d - -f 3 | sed -e 's/[0-9\.]//g;')
35
SYSTEM.SUPPORTED = $(shell test -f config/Makefile.$(SYSTEM) && echo 1)
mem's avatar
mem committed
36

37
38
ifeq ($(SYSTEM.SUPPORTED), 1)
include config/Makefile.$(SYSTEM)
ikits's avatar
ikits committed
39
40
41
42
else
$(error "Platform '$(SYSTEM)' not supported")
endif

ikits's avatar
ikits committed
43
GLEW_DEST ?= /usr
ikits's avatar
ikits committed
44
BINDIR ?= $(GLEW_DEST)/bin
ikits's avatar
ikits committed
45
LIBDIR ?= $(GLEW_DEST)/lib
ikits's avatar
ikits committed
46
INCDIR ?= $(GLEW_DEST)/include/GL
ikits's avatar
ikits committed
47
SHARED_OBJ_EXT ?= o
48

ikits's avatar
ikits committed
49
TARDIR = ../glew-$(GLEW_VERSION)
50
TARBALL = ../glew-$(GLEW_VERSION).tar.gz
mem's avatar
mem committed
51

52
53
54
55
DIST_DIR     = glew-$(GLEW_VERSION)
DIST_WIN32   = glew-$(GLEW_VERSION)-win32.zip
DIST_SRC_ZIP = glew-$(GLEW_VERSION).zip
DIST_SRC_TGZ = glew-$(GLEW_VERSION).tgz
56

mem's avatar
mem committed
57
58
AR = ar
INSTALL = install
ikits's avatar
ikits committed
59
STRIP = strip
mem's avatar
mem committed
60
61
RM = rm -f
LN = ln -sf
ikits's avatar
ikits committed
62
63
64
ifeq ($(MAKECMDGOALS), debug)
OPT = -g
else
ikits's avatar
ikits committed
65
OPT = $(POPT)
ikits's avatar
ikits committed
66
endif
ikits's avatar
ikits committed
67
INCLUDE = -Iinclude
ikits's avatar
ikits committed
68
CFLAGS = $(OPT) $(WARN) $(INCLUDE) $(CFLAGS.EXTRA)
ikits's avatar
ikits committed
69
70
71

LIB.SRCS = src/glew.c
LIB.OBJS = $(LIB.SRCS:.c=.o)
ikits's avatar
ikits committed
72
LIB.SOBJS = $(LIB.SRCS:.c=.$(SHARED_OBJ_EXT))
ikits's avatar
ikits committed
73
LIB.LDFLAGS = $(LDFLAGS.EXTRA) $(LDFLAGS.GL)
mem's avatar
mem committed
74
LIB.LIBS = $(GL_LDFLAGS)
ikits's avatar
ikits committed
75

76
77
78
LIB.OBJS.MX  = $(LIB.SRCS:.c=.mx.o)
LIB.SOBJS.MX = $(LIB.SRCS:.c=.mx.$(SHARED_OBJ_EXT))

ikits's avatar
ikits committed
79
80
GLEWINFO.BIN = glewinfo$(BIN.SUFFIX)
GLEWINFO.BIN.SRCS = src/glewinfo.c
81
GLEWINFO.BIN.OBJS = $(GLEWINFO.BIN.SRCS:.c=.o)
ikits's avatar
ikits committed
82
83
VISUALINFO.BIN = visualinfo$(BIN.SUFFIX)
VISUALINFO.BIN.SRCS = src/visualinfo.c
84
VISUALINFO.BIN.OBJS = $(VISUALINFO.BIN.SRCS:.c=.o)
ikits's avatar
ikits committed
85
BIN.LIBS = -Llib $(LDFLAGS.DYNAMIC) -l$(NAME) $(LDFLAGS.EXTRA) $(LDFLAGS.GL)
ikits's avatar
ikits committed
86

87
88
89
90
91
92
93
94
all debug: glew.lib glew.lib.mx glew.bin

%.o: %.c
	$(CC) -c $(CFLAGS) -o $@ $<

# GLEW libraries

glew.lib: lib lib/$(LIB.SHARED) lib/$(LIB.STATIC) glew.pc
ikits's avatar
ikits committed
95

ikits's avatar
ikits committed
96
97
lib:
	mkdir lib
ikits's avatar
ikits committed
98

ikits's avatar
ikits committed
99
lib/$(LIB.STATIC): $(LIB.OBJS)
ikits's avatar
ikits committed
100
	$(AR) cr $@ $^
ikits's avatar
ikits committed
101

mem's avatar
mem committed
102
lib/$(LIB.SHARED): $(LIB.SOBJS)
ikits's avatar
ikits committed
103
	$(LD) $(LDFLAGS.SO) -o $@ $^ $(LIB.LDFLAGS) $(LIB.LIBS)
104
ifeq ($(filter-out mingw% cygwin,$(SYSTEM)),)
ikits's avatar
ikits committed
105
else
ikits's avatar
ikits committed
106
107
	$(LN) $(LIB.SHARED) lib/$(LIB.SONAME)
	$(LN) $(LIB.SHARED) lib/$(LIB.DEVLNK)
ikits's avatar
ikits committed
108
endif
ikits's avatar
ikits committed
109

110
111
112
113
114
115
116
117
118
119
glew.pc: glew.pc.in
	sed \
		-e "s|@prefix@|$(GLEW_DEST)|g" \
		-e "s|@libdir@|$(LIBDIR)|g" \
		-e "s|@exec_prefix@|$(BINDIR)|g" \
		-e "s|@includedir@|$(INCDIR)|g" \
		-e "s|@version@|$(GLEW_VERSION)|g" \
		-e "s|@cflags@||g" \
		-e "s|@libname@|GLEW|g" \
		< $< > $@
ikits's avatar
ikits committed
120

121
src/glew.o: src/glew.c include/GL/glew.h include/GL/wglew.h include/GL/glxew.h
122
	$(CC) -DGLEW_NO_GLU $(CFLAGS) $(CFLAGS.SO) -o $@ -c $<
123

mem's avatar
mem committed
124
src/glew.pic_o: src/glew.c include/GL/glew.h include/GL/wglew.h include/GL/glxew.h
125
	$(CC) -DGLEW_NO_GLU $(CFLAGS) $(PICFLAG) $(CFLAGS.SO) -o $@ -c $<
mem's avatar
mem committed
126

127
128
129
130
131
132
133
134
# GLEW MX libraries

glew.lib.mx:  lib lib/$(LIB.SHARED.MX) lib/$(LIB.STATIC.MX) glewmx.pc

lib/$(LIB.STATIC.MX): $(LIB.OBJS.MX)
	$(AR) cr $@ $^

lib/$(LIB.SHARED.MX): $(LIB.SOBJS.MX)
135
	$(LD) $(LDFLAGS.SO.MX) -o $@ $^ $(LIB.LDFLAGS) $(LIB.LIBS)
136
137
138
139
140
141
142
ifeq ($(filter-out mingw% cygwin,$(SYSTEM)),)
else
	$(LN) $(LIB.SHARED.MX) lib/$(LIB.SONAME.MX)
	$(LN) $(LIB.SHARED.MX) lib/$(LIB.DEVLNK.MX)
endif

glewmx.pc: glew.pc.in
143
144
145
146
147
148
	sed \
		-e "s|@prefix@|$(GLEW_DEST)|g" \
		-e "s|@libdir@|$(LIBDIR)|g" \
		-e "s|@exec_prefix@|$(BINDIR)|g" \
		-e "s|@includedir@|$(INCDIR)|g" \
		-e "s|@version@|$(GLEW_VERSION)|g" \
149
150
		-e "s|@cflags@|-DGLEW_MX|g" \
		-e "s|@libname@|GLEWmx|g" \
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
src/glew.mx.o: src/glew.c include/GL/glew.h include/GL/wglew.h include/GL/glxew.h
	$(CC) -DGLEW_NO_GLU -DGLEW_MX $(CFLAGS) $(CFLAGS.SO) -o $@ -c $<

src/glew.mx.pic_o: src/glew.c include/GL/glew.h include/GL/wglew.h include/GL/glxew.h
	$(CC) -DGLEW_NO_GLU -DGLEW_MX $(CFLAGS) $(PICFLAG) $(CFLAGS.SO) -o $@ -c $<

# GLEW utilities

bin:
	mkdir bin

glew.bin:     glew.lib bin bin/$(GLEWINFO.BIN) bin/$(VISUALINFO.BIN) 

bin/$(GLEWINFO.BIN): $(GLEWINFO.BIN.OBJS) lib/$(LIB.SHARED)
	$(CC) $(CFLAGS) -o $@ $(GLEWINFO.BIN.OBJS) $(BIN.LIBS)

bin/$(VISUALINFO.BIN): $(VISUALINFO.BIN.OBJS) lib/$(LIB.SHARED)
	$(CC) $(CFLAGS) -o $@ $(VISUALINFO.BIN.OBJS) $(BIN.LIBS)

# Install targets

install.all: install install.mx install.bin

install:     install.include install.lib install.pkgconfig

install.mx:  install.include install.lib.mx install.pkgconfig.mx

install.lib: glew.lib
ikits's avatar
ikits committed
181
	$(INSTALL) -d -m 0755 $(LIBDIR)
mem's avatar
mem committed
182
# runtime
183
ifeq ($(filter-out mingw% cygwin,$(SYSTEM)),)
184
	$(INSTALL) -d -m 0755 $(BINDIR)
ikits's avatar
ikits committed
185
	$(STRIP) -x lib/$(LIB.SHARED)
186
	$(INSTALL) -m 0755 lib/$(LIB.SHARED) $(BINDIR)/
ikits's avatar
ikits committed
187
else
ikits's avatar
ikits committed
188
	$(STRIP) -x lib/$(LIB.SHARED)
ikits's avatar
ikits committed
189
190
	$(INSTALL) -m 0644 lib/$(LIB.SHARED) $(LIBDIR)/
	$(LN) $(LIB.SHARED) $(LIBDIR)/$(LIB.SONAME)
ikits's avatar
ikits committed
191
endif
mem's avatar
mem committed
192
# development files
193
ifeq ($(filter-out mingw% cygwin,$(SYSTEM)),)
ikits's avatar
ikits committed
194
	$(INSTALL) -m 0644 lib/$(LIB.DEVLNK) $(LIBDIR)/
ikits's avatar
ikits committed
195
else
ikits's avatar
ikits committed
196
	$(LN) $(LIB.SHARED) $(LIBDIR)/$(LIB.DEVLNK)
ikits's avatar
ikits committed
197
endif
198
199
	$(STRIP) -x lib/$(LIB.STATIC)
	$(INSTALL) -m 0644 lib/$(LIB.STATIC) $(LIBDIR)/
200
201
202
203
204

install.lib.mx: glew.lib.mx
	$(INSTALL) -d -m 0755 $(LIBDIR)
# runtime
ifeq ($(filter-out mingw% cygwin,$(SYSTEM)),)
205
	$(INSTALL) -d -m 0755 $(BINDIR)
206
	$(STRIP) -x lib/$(LIB.SHARED.MX)
207
	$(INSTALL) -m 0755 lib/$(LIB.SHARED.MX) $(BINDIR)/
208
209
210
211
212
213
214
215
216
217
218
else
	$(STRIP) -x lib/$(LIB.SHARED.MX)
	$(INSTALL) -m 0644 lib/$(LIB.SHARED.MX) $(LIBDIR)/
	$(LN) $(LIB.SHARED.MX) $(LIBDIR)/$(LIB.SONAME.MX)
endif
# development files
ifeq ($(filter-out mingw% cygwin,$(SYSTEM)),)
	$(INSTALL) -m 0644 lib/$(LIB.DEVLNK.MX) $(LIBDIR)/
else
	$(LN) $(LIB.SHARED.MX) $(LIBDIR)/$(LIB.DEVLNK.MX)
endif
219
220
	$(STRIP) -x lib/$(LIB.STATIC.MX)
	$(INSTALL) -m 0644 lib/$(LIB.STATIC.MX) $(LIBDIR)/
221
222
223

install.bin: glew.bin
	$(INSTALL) -d -m 0755 $(BINDIR)
ikits's avatar
ikits committed
224
	$(INSTALL) -s -m 0755 bin/$(GLEWINFO.BIN) bin/$(VISUALINFO.BIN) $(BINDIR)/
ikits's avatar
ikits committed
225

226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
install.include:
	$(INSTALL) -d -m 0755 $(INCDIR)
	$(INSTALL) -m 0644 include/GL/wglew.h $(INCDIR)/
	$(INSTALL) -m 0644 include/GL/glew.h $(INCDIR)/
	$(INSTALL) -m 0644 include/GL/glxew.h $(INCDIR)/

install.pkgconfig: glew.pc
	$(INSTALL) -d -m 0755 $(LIBDIR)
	$(INSTALL) -d -m 0755 $(LIBDIR)/pkgconfig
	$(INSTALL) -m 0644 glew.pc $(LIBDIR)/pkgconfig/

install.pkgconfig.mx: glewmx.pc
	$(INSTALL) -d -m 0755 $(LIBDIR)
	$(INSTALL) -d -m 0755 $(LIBDIR)/pkgconfig
	$(INSTALL) -m 0644 glewmx.pc $(LIBDIR)/pkgconfig/

ikits's avatar
ikits committed
242
uninstall:
ikits's avatar
ikits committed
243
244
245
	$(RM) $(INCDIR)/wglew.h
	$(RM) $(INCDIR)/glew.h
	$(RM) $(INCDIR)/glxew.h
246
	$(RM) $(LIBDIR)/$(LIB.DEVLNK) $(LIBDIR)/$(LIB.DEVLNK.MX)
247
ifeq ($(filter-out mingw% cygwin,$(SYSTEM)),)
248
	$(RM) $(BINDIR)/$(LIB.SHARED) $(BINDIR)/$(LIB.SHARED.MX)
ikits's avatar
ikits committed
249
else
250
251
	$(RM) $(LIBDIR)/$(LIB.SONAME) $(LIBDIR)/$(LIB.SONAME.MX)
	$(RM) $(LIBDIR)/$(LIB.SHARED) $(LIBDIR)/$(LIB.SHARED.MX)
ikits's avatar
ikits committed
252
endif
253
	$(RM) $(LIBDIR)/$(LIB.STATIC) $(LIBDIR)/$(LIB.STATIC.MX)
ikits's avatar
ikits committed
254
	$(RM) $(BINDIR)/$(GLEWINFO.BIN) $(BINDIR)/$(VISUALINFO.BIN)
ikits's avatar
ikits committed
255
256

clean:
257
258
	$(RM) $(LIB.OBJS) $(LIB.OBJS.MX)
	$(RM) $(LIB.SOBJS) $(LIB.SOBJS.MX)
ikits's avatar
ikits committed
259
	$(RM) lib/$(LIB.STATIC) lib/$(LIB.SHARED) lib/$(LIB.DEVLNK) lib/$(LIB.SONAME) $(LIB.STATIC)
260
	$(RM) lib/$(LIB.STATIC.MX) lib/$(LIB.SHARED.MX) lib/$(LIB.DEVLNK.MX) lib/$(LIB.SONAME.MX) $(LIB.STATIC.MX)
ikits's avatar
ikits committed
261
	$(RM) $(GLEWINFO.BIN.OBJS) bin/$(GLEWINFO.BIN) $(VISUALINFO.BIN.OBJS) bin/$(VISUALINFO.BIN)
262
	$(RM) glew.pc glewmx.pc
263
264
# Compiler droppings
	$(RM) so_locations
265
	$(RM) -r lib/ bin/
mem's avatar
mem committed
266
267

distclean: clean
ikits's avatar
ikits committed
268
269
	find . -name \*~ | xargs $(RM)
	find . -name .\*.sw\? | xargs $(RM)
mem's avatar
mem committed
270

271
# Distributions
mem's avatar
mem committed
272

273
274
275
276
277
278
279
280
281
282
dist-win32:
	$(RM) -r $(TARDIR)
	mkdir -p $(TARDIR)
	mkdir -p $(TARDIR)/bin
	mkdir -p $(TARDIR)/lib
	cp -a include $(TARDIR)
	cp -a doc $(TARDIR)
	cp -a *.txt $(TARDIR)
	cp -a lib/glew32.lib     $(TARDIR)/lib
	cp -a lib/glew32s.lib    $(TARDIR)/lib
283
284
	cp -a lib/glew32mx.lib   $(TARDIR)/lib
	cp -a lib/glew32mxs.lib  $(TARDIR)/lib
285
	cp -a bin/glew32.dll     $(TARDIR)/bin
286
	cp -a bin/glew32mx.dll   $(TARDIR)/bin
287
288
289
290
	cp -a bin/glewinfo.exe   $(TARDIR)/bin
	cp -a bin/visualinfo.exe $(TARDIR)/bin
	find $(TARDIR) -name CVS -o -name .cvsignore | xargs $(RM) -r
	find $(TARDIR) -name .svn | xargs $(RM) -r
291
	find $(TARDIR) -name "*.patch" | xargs $(RM) -r
292
293
294
295
	unix2dos $(TARDIR)/include/GL/*.h
	unix2dos $(TARDIR)/doc/*.txt
	unix2dos $(TARDIR)/doc/*.html
	unix2dos $(TARDIR)/*.txt
296
	rm -f ../$(DIST_WIN32)
297
298
	cd .. && zip -rv9 $(DIST_WIN32) $(DIST_DIR)

299
300
301
dist-src:
	$(RM) -r $(TARDIR)
	mkdir -p $(TARDIR)
302
303
	mkdir -p $(TARDIR)/bin
	mkdir -p $(TARDIR)/lib
304
305
306
307
308
309
310
311
312
	cp -a auto $(TARDIR)
	$(RM) -Rf $(TARDIR)/auto/registry
	cp -a build $(TARDIR)
	cp -a config $(TARDIR)
	cp -a src $(TARDIR)
	cp -a doc $(TARDIR)
	cp -a include $(TARDIR)
	cp -a *.txt $(TARDIR)
	cp -a Makefile $(TARDIR)
313
	cp -a glew.pc.in $(TARDIR)
314
	find $(TARDIR) -name '*.o' | xargs $(RM) -r
315
	find $(TARDIR) -name '*.mx.o' | xargs $(RM) -r
316
	find $(TARDIR) -name '*.pic_o' | xargs $(RM) -r
317
	find $(TARDIR) -name '*.mx.pic_o' | xargs $(RM) -r
318
319
320
	find $(TARDIR) -name '*~' | xargs $(RM) -r
	find $(TARDIR) -name CVS -o -name .cvsignore | xargs $(RM) -r
	find $(TARDIR) -name .svn | xargs $(RM) -r
321
	find $(TARDIR) -name "*.patch" | xargs $(RM) -r
322
323
324
325
326
327
328
	unix2dos $(TARDIR)/config/*
	unix2dos $(TARDIR)/auto/core/*
	unix2dos $(TARDIR)/auto/extensions/*
	find $(TARDIR) -name '*.h' | xargs unix2dos
	find $(TARDIR) -name '*.c' | xargs unix2dos
	find $(TARDIR) -name '*.txt' | xargs unix2dos
	find $(TARDIR) -name '*.html' | xargs unix2dos
329
	find $(TARDIR) -name '*.css' | xargs unix2dos
330
331
332
	find $(TARDIR) -name '*.sh' | xargs unix2dos
	find $(TARDIR) -name '*.pl' | xargs unix2dos
	find $(TARDIR) -name 'Makefile' | xargs unix2dos
333
	find $(TARDIR) -name '*.in' | xargs unix2dos
334
335
	find $(TARDIR) -name '*.pm' | xargs unix2dos
	find $(TARDIR) -name '*.rc' | xargs unix2dos
336
337
338
339
340
341
342
343
344
	rm -f ../$(DIST_SRC_ZIP)
	cd .. && zip -rv9 $(DIST_SRC_ZIP) $(DIST_DIR)
	dos2unix $(TARDIR)/config/*
	dos2unix $(TARDIR)/auto/core/*
	dos2unix $(TARDIR)/auto/extensions/*
	find $(TARDIR) -name '*.h' | xargs dos2unix
	find $(TARDIR) -name '*.c' | xargs dos2unix
	find $(TARDIR) -name '*.txt' | xargs dos2unix
	find $(TARDIR) -name '*.html' | xargs dos2unix
345
	find $(TARDIR) -name '*.css' | xargs dos2unix
346
347
348
	find $(TARDIR) -name '*.sh' | xargs dos2unix
	find $(TARDIR) -name '*.pl' | xargs dos2unix
	find $(TARDIR) -name 'Makefile' | xargs dos2unix
349
	find $(TARDIR) -name '*.in' | xargs dos2unix
350
351
	find $(TARDIR) -name '*.pm' | xargs dos2unix
	find $(TARDIR) -name '*.rc' | xargs dos2unix
352
353
	cd .. && env GZIP=-9 tar cvzf $(DIST_SRC_TGZ) $(DIST_DIR)

354
355
356
extensions:
	$(MAKE) -C auto

357
.PHONY: clean distclean tardist dist-win32 dist-src