Makefile 11.2 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

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

50 51 52 53
ifneq ($(GLEW_NO_GLU), -DGLEW_NO_GLU)
LIBGLU = glu
endif

54
DIST_NAME    ?= glew-$(GLEW_VERSION)
55 56 57
DIST_SRC_ZIP ?= $(shell pwd)/$(DIST_NAME).zip
DIST_SRC_TGZ ?= $(shell pwd)/$(DIST_NAME).tgz
DIST_WIN32   ?= $(shell pwd)/$(DIST_NAME)-win32.zip
mem's avatar
mem committed
58

59
DIST_DIR := $(shell mktemp -d /tmp/glew.XXXXXX)/$(DIST_NAME)
60

61
# To disable stripping of linked binaries either:
62 63
#   - use STRIP= on gmake command-line
#   - edit this makefile to set STRIP to the empty string
64
# (Note: STRIP does not affect the strip in the install step)
65 66 67
#
# To disable symlinks:
#   - use LN= on gmake command-line
68

69 70 71 72 73 74 75 76
AR       ?= ar
ARFLAGS  ?= cr
INSTALL  ?= install
STRIP    ?= strip
RM       ?= rm -f
LN       ?= ln -sf
UNIX2DOS ?= unix2dos -q
DOS2UNIX ?= dos2unix -q
77

78
ifneq (,$(filter debug,$(MAKECMDGOALS)))
ikits's avatar
ikits committed
79 80
OPT = -g
else
ikits's avatar
ikits committed
81
OPT = $(POPT)
ikits's avatar
ikits committed
82
endif
ikits's avatar
ikits committed
83
INCLUDE = -Iinclude
ikits's avatar
ikits committed
84
CFLAGS = $(OPT) $(WARN) $(INCLUDE) $(CFLAGS.EXTRA)
ikits's avatar
ikits committed
85

86
all debug: glew.lib glew.bin
87

88
# GLEW shared and static libraries
89

90 91 92 93 94 95 96 97 98 99 100
LIB.LDFLAGS        := $(LDFLAGS.EXTRA) $(LDFLAGS.GL)
LIB.LIBS           := $(GL_LDFLAGS)

LIB.SRCS           := src/glew.c
LIB.SRCS.NAMES     := $(notdir $(LIB.SRCS))

LIB.OBJS           := $(addprefix tmp/$(SYSTEM)/default/static/,$(LIB.SRCS.NAMES))
LIB.OBJS           := $(LIB.OBJS:.c=.o)
LIB.SOBJS          := $(addprefix tmp/$(SYSTEM)/default/shared/,$(LIB.SRCS.NAMES))
LIB.SOBJS          := $(LIB.SOBJS:.c=.o)

Danilo Margarido's avatar
Danilo Margarido committed
101 102 103 104
glew.lib: glew.lib.shared glew.lib.static

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

106 107
.PHONY: glew.lib glew.lib.shared glew.lib.static

ikits's avatar
ikits committed
108 109
lib:
	mkdir lib
ikits's avatar
ikits committed
110

ikits's avatar
ikits committed
111
lib/$(LIB.STATIC): $(LIB.OBJS)
112
ifneq ($(AR),)
113
	$(AR) $(ARFLAGS) $@ $^
114 115 116
else ifneq ($(LIBTOOL),)
	$(LIBTOOL) $@ $^
endif
117 118 119
ifneq ($(STRIP),)
	$(STRIP) -x $@
endif
ikits's avatar
ikits committed
120

mem's avatar
mem committed
121
lib/$(LIB.SHARED): $(LIB.SOBJS)
ikits's avatar
ikits committed
122
	$(LD) $(LDFLAGS.SO) -o $@ $^ $(LIB.LDFLAGS) $(LIB.LIBS)
123
ifneq ($(LN),)
ikits's avatar
ikits committed
124 125
	$(LN) $(LIB.SHARED) lib/$(LIB.SONAME)
	$(LN) $(LIB.SHARED) lib/$(LIB.DEVLNK)
ikits's avatar
ikits committed
126
endif
127 128 129 130 131 132
ifneq ($(STRIP),)
	$(STRIP) -x $@
endif

tmp/$(SYSTEM)/default/static/glew.o: src/glew.c include/GL/glew.h include/GL/wglew.h include/GL/glxew.h
	@mkdir -p $(dir $@)
133
	$(CC) -DGLEW_NO_GLU -DGLEW_STATIC $(CFLAGS) $(CFLAGS.SO) -o $@ -c $<
134 135 136

tmp/$(SYSTEM)/default/shared/glew.o: src/glew.c include/GL/glew.h include/GL/wglew.h include/GL/glxew.h
	@mkdir -p $(dir $@)
137
	$(CC) -DGLEW_NO_GLU -DGLEW_BUILD $(CFLAGS) $(CFLAGS.SO) -o $@ -c $<
ikits's avatar
ikits committed
138

139 140 141 142
# Force re-write of glew.pc, GLEW_DEST can vary

.PHONY: glew.pc

143 144
glew.pc: glew.pc.in
	sed \
145
		-e "s|@prefix@|$(GLEW_PREFIX)|g" \
146 147 148 149 150
		-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" \
151 152
		-e "s|@libname@|$(NAME)|g" \
		-e "s|@requireslib@|$(LIBGLU)|g" \
153
		< $< > $@
ikits's avatar
ikits committed
154

155
# GLEW utility programs
156

157
BIN.LIBS = -Llib $(LDFLAGS.DYNAMIC) -l$(NAME) $(LDFLAGS.EXTRA) $(LDFLAGS.GL)
158

159 160 161 162 163 164 165 166 167 168
GLEWINFO.BIN       := glewinfo$(BIN.SUFFIX)
GLEWINFO.BIN.SRC   := src/glewinfo.c
GLEWINFO.BIN.OBJ   := $(addprefix tmp/$(SYSTEM)/default/shared/,$(notdir $(GLEWINFO.BIN.SRC)))
GLEWINFO.BIN.OBJ   := $(GLEWINFO.BIN.OBJ:.c=.o)

VISUALINFO.BIN     := visualinfo$(BIN.SUFFIX)
VISUALINFO.BIN.SRC := src/visualinfo.c
VISUALINFO.BIN.OBJ := $(addprefix tmp/$(SYSTEM)/default/shared/,$(notdir $(VISUALINFO.BIN.SRC)))
VISUALINFO.BIN.OBJ := $(VISUALINFO.BIN.OBJ:.c=.o)

169 170 171 172 173
# Don't build glewinfo or visualinfo for NaCL, yet.

ifneq ($(filter nacl%,$(SYSTEM)),)
glew.bin: glew.lib bin
else
174
glew.bin: glew.lib bin bin/$(GLEWINFO.BIN) bin/$(VISUALINFO.BIN) 
175
endif
176 177 178 179

bin:
	mkdir bin

180 181 182 183 184
bin/$(GLEWINFO.BIN): $(GLEWINFO.BIN.OBJ) lib/$(LIB.SHARED)
	$(CC) $(CFLAGS) -o $@ $(GLEWINFO.BIN.OBJ) $(BIN.LIBS)
ifneq ($(STRIP),)
	$(STRIP) -x $@
endif
185

186 187 188 189 190
bin/$(VISUALINFO.BIN): $(VISUALINFO.BIN.OBJ) lib/$(LIB.SHARED)
	$(CC) $(CFLAGS) -o $@ $(VISUALINFO.BIN.OBJ) $(BIN.LIBS)
ifneq ($(STRIP),)
	$(STRIP) -x $@
endif
191

192 193 194 195 196 197 198
$(GLEWINFO.BIN.OBJ): $(GLEWINFO.BIN.SRC) include/GL/glew.h include/GL/wglew.h include/GL/glxew.h
	@mkdir -p $(dir $@)
	$(CC) -DGLEW_NO_GLU $(CFLAGS) $(CFLAGS.SO) -o $@ -c $<

$(VISUALINFO.BIN.OBJ): $(VISUALINFO.BIN.SRC) include/GL/glew.h include/GL/wglew.h include/GL/glxew.h
	@mkdir -p $(dir $@)
	$(CC) -DGLEW_NO_GLU $(CFLAGS) $(CFLAGS.SO) -o $@ -c $<
199 200 201

# Install targets

202
install.all: install install.bin
203 204 205 206

install:     install.include install.lib install.pkgconfig

install.lib: glew.lib
hasufell's avatar
hasufell committed
207
	$(INSTALL) -d -m 0755 "$(DESTDIR)$(LIBDIR)"
mem's avatar
mem committed
208
# runtime
209
ifeq ($(filter-out mingw% cygwin,$(SYSTEM)),)
hasufell's avatar
hasufell committed
210 211
	$(INSTALL) -d -m 0755 "$(DESTDIR)$(BINDIR)"
	$(INSTALL) -m 0755 lib/$(LIB.SHARED) "$(DESTDIR)$(BINDIR)/"
ikits's avatar
ikits committed
212
else
hasufell's avatar
hasufell committed
213
	$(INSTALL) -m 0644 lib/$(LIB.SHARED) "$(DESTDIR)$(LIBDIR)/"
214 215
endif
ifneq ($(LN),)
hasufell's avatar
hasufell committed
216
	$(LN) $(LIB.SHARED) "$(DESTDIR)$(LIBDIR)/$(LIB.SONAME)"
ikits's avatar
ikits committed
217
endif
218

mem's avatar
mem committed
219
# development files
220
ifeq ($(filter-out mingw% cygwin,$(SYSTEM)),)
hasufell's avatar
hasufell committed
221
	$(INSTALL) -m 0644 lib/$(LIB.DEVLNK) "$(DESTDIR)$(LIBDIR)/"
222 223
endif
ifneq ($(LN),)
hasufell's avatar
hasufell committed
224
	$(LN) $(LIB.SHARED) "$(DESTDIR)$(LIBDIR)/$(LIB.DEVLNK)"
ikits's avatar
ikits committed
225
endif
hasufell's avatar
hasufell committed
226
	$(INSTALL) -m 0644 lib/$(LIB.STATIC) "$(DESTDIR)$(LIBDIR)/"
227 228

install.bin: glew.bin
hasufell's avatar
hasufell committed
229 230
	$(INSTALL) -d -m 0755 "$(DESTDIR)$(BINDIR)"
	$(INSTALL) -s -m 0755 bin/$(GLEWINFO.BIN) bin/$(VISUALINFO.BIN) "$(DESTDIR)$(BINDIR)/"
ikits's avatar
ikits committed
231

232
install.include:
hasufell's avatar
hasufell committed
233 234 235 236
	$(INSTALL) -d -m 0755 "$(DESTDIR)$(INCDIR)"
	$(INSTALL) -m 0644 include/GL/wglew.h "$(DESTDIR)$(INCDIR)/"
	$(INSTALL) -m 0644 include/GL/glew.h "$(DESTDIR)$(INCDIR)/"
	$(INSTALL) -m 0644 include/GL/glxew.h "$(DESTDIR)$(INCDIR)/"
237 238

install.pkgconfig: glew.pc
239 240 241
	$(INSTALL) -d -m 0755 "$(DESTDIR)$(PKGDIR)"
	$(INSTALL) -d -m 0755 "$(DESTDIR)$(PKGDIR)"
	$(INSTALL) -m 0644 glew.pc "$(DESTDIR)$(PKGDIR)/"
242

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

clean:
258 259 260
	$(RM) -r tmp/
	$(RM) -r lib/
	$(RM) -r bin/
261
	$(RM) glew.pc
mem's avatar
mem committed
262 263

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

267
# Distributions
mem's avatar
mem committed
268

269
dist-win32:
270 271 272 273 274 275 276 277 278 279
	$(RM) -r $(DIST_DIR)
	mkdir -p $(DIST_DIR)
	cp -a include $(DIST_DIR)
	cp -a doc $(DIST_DIR)
	cp -a *.txt $(DIST_DIR)
	cp -a bin $(DIST_DIR)
	cp -a lib $(DIST_DIR)
	$(RM) -f $(DIST_DIR)/bin/*/*/*.pdb $(DIST_DIR)/bin/*/*/*.exp
	$(RM) -f $(DIST_DIR)/bin/*/*/glewinfo-*.exe $(DIST_DIR)/bin/*/*/visualinfo-*.exe 
	$(RM) -f $(DIST_DIR)/lib/*/*/*.pdb $(DIST_DIR)/lib/*/*/*.exp
280 281 282 283
	$(UNIX2DOS) $(DIST_DIR)/include/GL/*.h
	$(UNIX2DOS) $(DIST_DIR)/doc/*.txt
	$(UNIX2DOS) $(DIST_DIR)/doc/*.html
	$(UNIX2DOS) $(DIST_DIR)/*.txt
284
	rm -f $(DIST_WIN32)
285
	cd $(DIST_DIR)/.. && zip -rq9 $(DIST_WIN32) $(DIST_NAME)
286
	$(RM) -r $(DIST_DIR)
287

288
dist-src:
289 290 291 292 293 294 295 296 297 298 299
	$(RM) -r $(DIST_DIR)
	mkdir -p $(DIST_DIR)
	mkdir -p $(DIST_DIR)/bin
	mkdir -p $(DIST_DIR)/lib
	cp -a auto $(DIST_DIR)
	$(RM) -Rf $(DIST_DIR)/auto/registry
	cp -a build $(DIST_DIR)
	cp -a config $(DIST_DIR)
	cp -a src $(DIST_DIR)
	cp -a doc $(DIST_DIR)
	cp -a include $(DIST_DIR)
300
	cp -a *.md $(DIST_DIR)
301 302 303 304 305 306 307 308
	cp -a *.txt $(DIST_DIR)
	cp -a Makefile $(DIST_DIR)
	cp -a glew.pc.in $(DIST_DIR)
	find $(DIST_DIR) -name '*.o' | xargs $(RM) -r
	find $(DIST_DIR) -name '*~' | xargs $(RM) -r
	find $(DIST_DIR) -name CVS -o -name .cvsignore | xargs $(RM) -r
	find $(DIST_DIR) -name .svn | xargs $(RM) -r
	find $(DIST_DIR) -name "*.patch" | xargs $(RM) -r
309 310 311 312 313 314 315
	$(DOS2UNIX) $(DIST_DIR)/Makefile
	$(DOS2UNIX) $(DIST_DIR)/auto/Makefile
	$(DOS2UNIX) $(DIST_DIR)/config/*
	$(UNIX2DOS) $(DIST_DIR)/auto/core/*
	$(UNIX2DOS) $(DIST_DIR)/auto/extensions/*
	find $(DIST_DIR) -name '*.h' | xargs $(UNIX2DOS)
	find $(DIST_DIR) -name '*.c' | xargs $(UNIX2DOS)
316
	find $(DIST_DIR) -name '*.md' | xargs $(UNIX2DOS)
317 318 319 320 321 322 323 324 325
	find $(DIST_DIR) -name '*.txt' | xargs $(UNIX2DOS)
	find $(DIST_DIR) -name '*.html' | xargs $(UNIX2DOS)
	find $(DIST_DIR) -name '*.css' | xargs $(UNIX2DOS)
	find $(DIST_DIR) -name '*.sh' | xargs $(UNIX2DOS)
	find $(DIST_DIR) -name '*.pl' | xargs $(UNIX2DOS)
	find $(DIST_DIR) -name 'Makefile' | xargs $(UNIX2DOS)
	find $(DIST_DIR) -name '*.in' | xargs $(UNIX2DOS)
	find $(DIST_DIR) -name '*.pm' | xargs $(UNIX2DOS)
	find $(DIST_DIR) -name '*.rc' | xargs $(UNIX2DOS)
326
	rm -f $(DIST_SRC_ZIP)
327 328 329 330 331 332 333 334
	cd $(DIST_DIR)/.. && zip -rq9 $(DIST_SRC_ZIP) $(DIST_NAME)
	$(DOS2UNIX) $(DIST_DIR)/Makefile
	$(DOS2UNIX) $(DIST_DIR)/auto/Makefile
	$(DOS2UNIX) $(DIST_DIR)/config/*
	$(DOS2UNIX) $(DIST_DIR)/auto/core/*
	$(DOS2UNIX) $(DIST_DIR)/auto/extensions/*
	find $(DIST_DIR) -name '*.h' | xargs $(DOS2UNIX)
	find $(DIST_DIR) -name '*.c' | xargs $(DOS2UNIX)
335
	find $(DIST_DIR) -name '*.md' | xargs $(DOS2UNIX)
336 337 338 339 340 341 342 343 344
	find $(DIST_DIR) -name '*.txt' | xargs $(DOS2UNIX)
	find $(DIST_DIR) -name '*.html' | xargs $(DOS2UNIX)
	find $(DIST_DIR) -name '*.css' | xargs $(DOS2UNIX)
	find $(DIST_DIR) -name '*.sh' | xargs $(DOS2UNIX)
	find $(DIST_DIR) -name '*.pl' | xargs $(DOS2UNIX)
	find $(DIST_DIR) -name 'Makefile' | xargs $(DOS2UNIX)
	find $(DIST_DIR) -name '*.in' | xargs $(DOS2UNIX)
	find $(DIST_DIR) -name '*.pm' | xargs $(DOS2UNIX)
	find $(DIST_DIR) -name '*.rc' | xargs $(DOS2UNIX)
345
	rm -f $(DIST_SRC_TGZ)
346
	cd $(DIST_DIR)/.. && env GZIP=-9 tar czf $(DIST_SRC_TGZ) $(DIST_NAME)
347
	$(RM) -r $(DIST_DIR)
348

349 350 351
extensions:
	$(MAKE) -C auto

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