Makefile 6.23 KB
Newer Older
ikits's avatar
ikits committed
1
#!gmake
ikits's avatar
ikits committed
2
## The OpenGL Extension Wrangler Library
3
4
## Copyright (C) 2002-2005, Milan Ikits <milan ikits[]ieee org>
## Copyright (C) 2002-2005, 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

ikits's avatar
ikits committed
31
GLEW_DEST ?= /usr
mem's avatar
mem committed
32
33

GLEW_MAJOR = 1
34
35
GLEW_MINOR = 3
GLEW_MICRO = 0
mem's avatar
mem committed
36
37
38
39
40
41
GLEW_VERSION = $(GLEW_MAJOR).$(GLEW_MINOR).$(GLEW_MICRO)

TARDIR = ../glew-$(GLEW_VERSION)
TARBALL = ../glew_$(GLEW_VERSION).tar.gz

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

45
46
ifeq ($(SYSTEM.SUPPORTED), 1)
include config/Makefile.$(SYSTEM)
ikits's avatar
ikits committed
47
48
49
50
else
$(error "Platform '$(SYSTEM)' not supported")
endif

mem's avatar
mem committed
51
52
53
54
ifeq (undefined, $(origin SHARED_OBJ_EXT))
SHARED_OBJ_EXT = o
endif

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

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

ikits's avatar
ikits committed
75
76
77
78
79
80
GLEWINFO.BIN = glewinfo$(BIN.SUFFIX)
GLEWINFO.BIN.SRCS = src/glewinfo.c
GLEWINFO.BIN.OBJS = $(GLEWINFO_BIN.SRCS:.c=.o)
VISUALINFO.BIN = visualinfo$(BIN.SUFFIX)
VISUALINFO.BIN.SRCS = src/visualinfo.c
VISUALINFO.BIN.OBJS = $(VISUALINFO_BIN.SRCS:.c=.o)
ikits's avatar
ikits committed
81
BIN.LIBS = -Llib $(LDFLAGS.STATIC) -l$(NAME) $(LDFLAGS.EXTRA) $(LDFLAGS.DYNAMIC) $(LDFLAGS.GL)
ikits's avatar
ikits committed
82

ikits's avatar
ikits committed
83
all debug: lib/$(LIB.SHARED) lib/$(LIB.STATIC) bin/$(GLEWINFO.BIN) bin/$(VISUALINFO.BIN)
ikits's avatar
ikits committed
84

ikits's avatar
ikits committed
85
86
lib:
	mkdir lib
ikits's avatar
ikits committed
87

ikits's avatar
ikits committed
88
lib/$(LIB.STATIC): $(LIB.OBJS)
ikits's avatar
ikits committed
89
	$(AR) cr $@ $^
ikits's avatar
ikits committed
90

mem's avatar
mem committed
91
lib/$(LIB.SHARED): $(LIB.SOBJS)
ikits's avatar
ikits committed
92
	$(LD) $(LDFLAGS.SO) -o $@ $^ $(LIB.LDFLAGS) $(LIB.LIBS)
ikits's avatar
ikits committed
93
ifeq ($(patsubst mingw%,mingw,$(SYSTEM)), mingw)
ikits's avatar
ikits committed
94
else
ikits's avatar
ikits committed
95
96
	$(LN) $(LIB.SHARED) lib/$(LIB.SONAME)
	$(LN) $(LIB.SHARED) lib/$(LIB.DEVLNK)
ikits's avatar
ikits committed
97
endif
ikits's avatar
ikits committed
98

ikits's avatar
ikits committed
99
100
101
102
bin/$(GLEWINFO.BIN): $(GLEWINFO.BIN.SRCS)
	$(CC) $(CFLAGS) -o $@ $^ $(BIN.LIBS)

bin/$(VISUALINFO.BIN): $(VISUALINFO.BIN.SRCS)
mem's avatar
mem committed
103
	$(CC) $(CFLAGS) -o $@ $^ $(BIN.LIBS)
ikits's avatar
ikits committed
104
105
106
107

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

108
src/glew.o: src/glew.c include/GL/glew.h include/GL/wglew.h include/GL/glxew.h
ikits's avatar
ikits committed
109
	$(CC) $(CFLAGS) $(CFLAGS.SO) -o $@ -c $<
110

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

ikits's avatar
ikits committed
114
install: all
mem's avatar
mem committed
115
116
117
118
119
# directories
	$(INSTALL) -d -m 0755 $(GLEW_DEST)/bin
	$(INSTALL) -d -m 0755 $(GLEW_DEST)/include/GL
	$(INSTALL) -d -m 0755 $(GLEW_DEST)/lib
# runtime
ikits's avatar
ikits committed
120
ifeq ($(patsubst mingw%,mingw,$(SYSTEM)), mingw)
ikits's avatar
ikits committed
121
122
	$(INSTALL) $(STRIP) -m 0644 lib/$(LIB.SHARED) $(GLEW_DEST)/bin/
else
ikits's avatar
ikits committed
123
  ifeq ($(patsubst darwin%,darwin,$(SYSTEM)), darwin)
ikits's avatar
ikits committed
124
125
	strip -x lib/$(LIB.SHARED)
	$(INSTALL) -m 0644 lib/$(LIB.SHARED) $(GLEW_DEST)/lib/
ikits's avatar
ikits committed
126
127
	$(LN) $(LIB.SHARED) $(GLEW_DEST)/lib/$(LIB.SONAME)
  else
ikits's avatar
ikits committed
128
129
	$(INSTALL) $(STRIP) -m 0644 lib/$(LIB.SHARED) $(GLEW_DEST)/lib/
	$(LN) $(LIB.SHARED) $(GLEW_DEST)/lib/$(LIB.SONAME)
ikits's avatar
ikits committed
130
131
  endif
endif
mem's avatar
mem committed
132
# development files
133
134
135
	$(INSTALL) -m 0644 include/GL/wglew.h $(GLEW_DEST)/include/GL
	$(INSTALL) -m 0644 include/GL/glew.h $(GLEW_DEST)/include/GL
	$(INSTALL) -m 0644 include/GL/glxew.h $(GLEW_DEST)/include/GL
ikits's avatar
ikits committed
136
ifeq ($(patsubst mingw%,mingw,$(SYSTEM)), mingw)
ikits's avatar
ikits committed
137
138
	$(INSTALL) -m 0644 lib/$(LIB.DEVLNK) $(GLEW_DEST)/lib/
else
ikits's avatar
ikits committed
139
  ifeq ($(patsubst darwin%,darwin,$(SYSTEM)), darwin)
ikits's avatar
ikits committed
140
141
	strip -x lib/$(LIB.STATIC)
	$(INSTALL) -m 0644 lib/$(LIB.STATIC) $(GLEW_DEST)/lib/
ikits's avatar
ikits committed
142
143
	$(LN) $(LIB.SHARED) $(GLEW_DEST)/lib/$(LIB.DEVLNK)
  else
ikits's avatar
ikits committed
144
145
	$(INSTALL) $(STRIP) -m 0644 lib/$(LIB.STATIC) $(GLEW_DEST)/lib/
	$(LN) $(LIB.SHARED) $(GLEW_DEST)/lib/$(LIB.DEVLNK)
ikits's avatar
ikits committed
146
147
  endif
endif
mem's avatar
mem committed
148
# utilities
ikits's avatar
ikits committed
149
	$(INSTALL) -s -m 0755 bin/$(GLEWINFO.BIN) bin/$(VISUALINFO.BIN) $(GLEW_DEST)/bin/
ikits's avatar
ikits committed
150
151

uninstall:
152
153
154
	$(RM) $(GLEW_DEST)/include/GL/wglew.h
	$(RM) $(GLEW_DEST)/include/GL/glew.h
	$(RM) $(GLEW_DEST)/include/GL/glxew.h
ikits's avatar
ikits committed
155
	$(RM) $(GLEW_DEST)/lib/$(LIB.DEVLNK)
ikits's avatar
ikits committed
156
ifeq ($(patsubst mingw%,mingw,$(SYSTEM)), mingw)
ikits's avatar
ikits committed
157
158
	$(RM) $(GLEW_DEST)/bin/$(LIB.SHARED)
else
ikits's avatar
ikits committed
159
160
161
	$(RM) $(GLEW_DEST)/lib/$(LIB.SONAME)
	$(RM) $(GLEW_DEST)/lib/$(LIB.SHARED)
	$(RM) $(GLEW_DEST)/lib/$(LIB.STATIC)
ikits's avatar
ikits committed
162
endif
ikits's avatar
ikits committed
163
	$(RM) $(GLEW_DEST)/bin/$(GLEWINFO.BIN) $(GLEW_DEST)/bin/$(VISUALINFO.BIN)
ikits's avatar
ikits committed
164
165

clean:
mem's avatar
mem committed
166
	$(RM) $(LIB.OBJS)
mem's avatar
mem committed
167
	$(RM) $(LIB.SOBJS)
ikits's avatar
ikits committed
168
	$(RM) lib/$(LIB.STATIC) lib/$(LIB.SHARED) lib/$(LIB.DEVLNK) lib/$(LIB.SONAME) $(LIB.STATIC)
ikits's avatar
ikits committed
169
	$(RM) $(GLEWINFO.BIN.OBJS) bin/$(GLEWINFO.BIN) $(VISUALINFO.BIN.OBJS) bin/$(VISUALINFO.BIN)
170
171
# Compiler droppings
	$(RM) so_locations
mem's avatar
mem committed
172
173

distclean: clean
ikits's avatar
ikits committed
174
175
	find . -name \*~ | xargs $(RM)
	find . -name .\*.sw\? | xargs $(RM)
mem's avatar
mem committed
176
177
178
179
180

tardist:
	$(RM) -r $(TARDIR)
	mkdir $(TARDIR)
	cp -a . $(TARDIR)
181
	find $(TARDIR) -name CVS -o -name .cvsignore | xargs $(RM) -r
mem's avatar
mem committed
182
183
184
	$(MAKE) -C $(TARDIR) distclean
	$(MAKE) -C $(TARDIR)
	$(MAKE) -C $(TARDIR) distclean
185
	$(RM) -r $(TARDIR)/auto/registry
mem's avatar
mem committed
186
187
	env GZIP=-9 tar -C `dirname $(TARDIR)` -cvzf $(TARBALL) `basename $(TARDIR)`

188
189
190
extensions:
	$(MAKE) -C auto

191
.PHONY: clean distclean tardist