1#!gmake 2## The OpenGL Extension Wrangler Library 3## Copyright (C) 2002-2008, Milan Ikits <milan ikits[]ieee org> 4## Copyright (C) 2002-2008, Marcelo E. Magallon <mmagallo[]debian org> 5## Copyright (C) 2002, Lev Povalahev 6## All rights reserved. 7## 8## Redistribution and use in source and binary forms, with or without 9## modification, are permitted provided that the following conditions are met: 10## 11## * Redistributions of source code must retain the above copyright notice, 12## this list of conditions and the following disclaimer. 13## * Redistributions in binary form must reproduce the above copyright notice, 14## this list of conditions and the following disclaimer in the documentation 15## and/or other materials provided with the distribution. 16## * The name of the author may be used to endorse or promote products 17## derived from this software without specific prior written permission. 18## 19## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22## ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 23## LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24## CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25## SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26## INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 29## THE POSSIBILITY OF SUCH DAMAGE. 30 31include config/version 32 33SHELL = /bin/sh 34SYSTEM ?= $(shell config/config.guess | cut -d - -f 3 | sed -e 's/[0-9\.]//g;') 35SYSTEM.SUPPORTED = $(shell test -f config/Makefile.$(SYSTEM)-egl-glvnd && echo 1) 36 37ifeq ($(SYSTEM.SUPPORTED), 1) 38include config/Makefile.$(SYSTEM)-egl-glvnd 39else 40$(error "Platform '$(SYSTEM)' not supported") 41endif 42 43GLEW_PREFIX ?= /usr 44GLEW_DEST ?= /usr 45BINDIR ?= $(GLEW_DEST)/bin 46GLEW_LIBDIR ?= $(GLEW_DEST)/lib 47INCDIR ?= $(GLEW_DEST)/include/GL 48PKGDIR ?= $(GLEW_DEST)/lib/pkgconfig 49 50ifneq ($(GLEW_NO_GLU), -DGLEW_NO_GLU) 51LIBGLU = glu 52endif 53 54DIST_NAME ?= glew-$(GLEW_VERSION) 55DIST_SRC_ZIP ?= $(shell pwd)/$(DIST_NAME).zip 56DIST_SRC_TGZ ?= $(shell pwd)/$(DIST_NAME).tgz 57DIST_WIN32 ?= $(shell pwd)/$(DIST_NAME)-win32.zip 58 59DIST_DIR := $(shell mktemp -d /tmp/glew.XXXXXX)/$(DIST_NAME) 60 61# To disable stripping of linked binaries either: 62# - use STRIP= on gmake command-line 63# - edit this makefile to set STRIP to the empty string 64# (Note: STRIP does not affect the strip in the install step) 65# 66# To disable symlinks: 67# - use LN= on gmake command-line 68 69AR ?= ar 70ARFLAGS ?= cr 71INSTALL ?= install 72STRIP ?= strip 73RM ?= rm -f 74LN ?= ln -sf 75UNIX2DOS ?= unix2dos -q 76DOS2UNIX ?= dos2unix -q 77 78ifneq (,$(filter debug,$(MAKECMDGOALS))) 79OPT = -g 80else 81OPT = $(POPT) 82endif 83INCLUDE = -Iinclude 84CFLAGS += $(OPT) $(WARN) $(INCLUDE) $(CFLAGS.EXTRA) 85 86all debug: glew.lib glew.bin 87 88# GLEW shared and static libraries 89 90LIB.LDFLAGS := $(LDFLAGS.EXTRA) $(LDFLAGS.GL) 91LIB.LIBS := $(GL_LDFLAGS) 92LIB.SHARED.DIR ?= lib 93 94LIB.SRCS := src/glew.c 95LIB.SRCS.NAMES := $(notdir $(LIB.SRCS)) 96 97LIB.OBJS := $(addprefix tmp/$(SYSTEM)/default/static/,$(LIB.SRCS.NAMES)) 98LIB.OBJS := $(LIB.OBJS:.c=.o) 99LIB.SOBJS := $(addprefix tmp/$(SYSTEM)/default/shared/,$(LIB.SRCS.NAMES)) 100LIB.SOBJS := $(LIB.SOBJS:.c=.o) 101 102glew.lib: glew.lib.shared glew.lib.static 103 104glew.lib.shared: lib $(LIB.SHARED.DIR) $(LIB.SHARED.DIR)/$(LIB.SHARED) glew.pc 105glew.lib.static: lib lib/$(LIB.STATIC) glew.pc 106 107.PHONY: glew.lib glew.lib.shared glew.lib.static 108 109lib: 110 mkdir lib 111 112lib/$(LIB.STATIC): $(LIB.OBJS) 113ifneq ($(AR),) 114 $(AR) $(ARFLAGS) $@ $^ 115else ifneq ($(LIBTOOL),) 116 $(LIBTOOL) $@ $^ 117endif 118ifneq ($(STRIP),) 119 $(STRIP) $@ 120endif 121 122$(LIB.SHARED.DIR)/$(LIB.SHARED): $(LIB.SOBJS) 123 $(LD) $(LDFLAGS.SO) -o $@ $^ $(LIB.LDFLAGS) $(LIB.LIBS) 124ifneq ($(LN),) 125 $(LN) $(LIB.SHARED) $(LIB.SHARED.DIR)/$(LIB.SONAME) 126 $(LN) $(LIB.SHARED) $(LIB.SHARED.DIR)/$(LIB.DEVLNK) 127endif 128ifneq ($(STRIP),) 129 $(STRIP) $@ 130endif 131 /usr/bin/file $@ 132 133tmp/$(SYSTEM)/default/static/glew.o: src/glew.c include/GL/glew.h include/GL/wglew.h include/GL/glxew.h 134 @mkdir -p $(dir $@) 135 $(CC) -DGLEW_NO_GLU -DGLEW_STATIC $(CFLAGS) $(CFLAGS.SO) -o $@ -c $< 136 137tmp/$(SYSTEM)/default/shared/glew.o: src/glew.c include/GL/glew.h include/GL/wglew.h include/GL/glxew.h 138 @mkdir -p $(dir $@) 139 $(CC) -DGLEW_NO_GLU -DGLEW_BUILD $(CFLAGS) $(CFLAGS.SO) -o $@ -c $< 140 141# Force re-write of glew.pc, GLEW_DEST can vary 142 143.PHONY: glew.pc 144 145glew.pc: glew.pc.in 146 sed \ 147 -e 's|@prefix@|$(GLEW_PREFIX)|g' \ 148 -e 's|@libdir@|$${prefix}/lib|g' \ 149 -e 's|@exec_prefix@|$${prefix}/bin|g' \ 150 -e 's|@includedir@|$${prefix}/include|g' \ 151 -e 's|@version@|$(GLEW_VERSION)|g' \ 152 -e 's|@cflags@||g' \ 153 -e 's|@libname@|$(NAME)|g' \ 154 -e 's|@libgl@|$(LDFLAGS.GL)|g' \ 155 -e 's|@requireslib@|$(LIBGLU)|g' \ 156 < $< > $@ 157 158# GLEW utility programs 159 160BIN.LIBS = -Llib $(LDFLAGS.DYNAMIC) -l$(NAME) $(LDFLAGS.EXTRA) $(LDFLAGS.GL) 161 162GLEWINFO.BIN := glewinfo$(BIN.SUFFIX) 163GLEWINFO.BIN.SRC := src/glewinfo.c 164GLEWINFO.BIN.OBJ := $(addprefix tmp/$(SYSTEM)/default/shared/,$(notdir $(GLEWINFO.BIN.SRC))) 165GLEWINFO.BIN.OBJ := $(GLEWINFO.BIN.OBJ:.c=.o) 166 167VISUALINFO.BIN := visualinfo$(BIN.SUFFIX) 168VISUALINFO.BIN.SRC := src/visualinfo.c 169VISUALINFO.BIN.OBJ := $(addprefix tmp/$(SYSTEM)/default/shared/,$(notdir $(VISUALINFO.BIN.SRC))) 170VISUALINFO.BIN.OBJ := $(VISUALINFO.BIN.OBJ:.c=.o) 171 172# Don't build glewinfo or visualinfo for NaCL, yet. 173 174ifneq ($(filter nacl%,$(SYSTEM)),) 175glew.bin: glew.lib bin 176else 177glew.bin: glew.lib bin bin/$(GLEWINFO.BIN) bin/$(VISUALINFO.BIN) 178endif 179 180bin: 181 mkdir bin 182 183bin/$(GLEWINFO.BIN): $(GLEWINFO.BIN.OBJ) $(LIB.SHARED.DIR)/$(LIB.SHARED) 184 $(CC) $(CFLAGS) -o $@ $(GLEWINFO.BIN.OBJ) $(BIN.LIBS) 185ifneq ($(STRIP),) 186 $(STRIP) $@ 187endif 188 189bin/$(VISUALINFO.BIN): $(VISUALINFO.BIN.OBJ) $(LIB.SHARED.DIR)/$(LIB.SHARED) 190 $(CC) $(CFLAGS) -o $@ $(VISUALINFO.BIN.OBJ) $(BIN.LIBS) 191ifneq ($(STRIP),) 192 $(STRIP) $@ 193endif 194 195$(GLEWINFO.BIN.OBJ): $(GLEWINFO.BIN.SRC) include/GL/glew.h include/GL/wglew.h include/GL/glxew.h 196 @mkdir -p $(dir $@) 197 $(CC) -DGLEW_NO_GLU $(CFLAGS) -o $@ -c $< 198 199$(VISUALINFO.BIN.OBJ): $(VISUALINFO.BIN.SRC) include/GL/glew.h include/GL/wglew.h include/GL/glxew.h 200 @mkdir -p $(dir $@) 201 $(CC) -DGLEW_NO_GLU $(CFLAGS) -o $@ -c $< 202 203# Install targets 204 205install.all: install install.bin 206 207install: install.include install.lib install.pkgconfig 208 209install.lib: glew.lib 210 $(INSTALL) -d -m 0755 "$(DESTDIR)$(GLEW_LIBDIR)" 211# runtime 212ifeq ($(filter-out mingw% cygwin,$(SYSTEM)),) 213 $(INSTALL) -d -m 0755 "$(DESTDIR)$(BINDIR)" 214 $(INSTALL) -m 0755 $(LIB.SHARED.DIR)/$(LIB.SHARED) "$(DESTDIR)$(BINDIR)/" 215else 216 $(INSTALL) -m 0644 $(LIB.SHARED.DIR)/$(LIB.SHARED) "$(DESTDIR)$(GLEW_LIBDIR)/" 217endif 218ifneq ($(LN),) 219 $(LN) $(LIB.SHARED) "$(DESTDIR)$(GLEW_LIBDIR)/$(LIB.SONAME)" 220endif 221 222# development files 223ifeq ($(filter-out mingw% cygwin,$(SYSTEM)),) 224 $(INSTALL) -m 0644 lib/$(LIB.DEVLNK) "$(DESTDIR)$(GLEW_LIBDIR)/" 225endif 226ifneq ($(LN),) 227 $(LN) $(LIB.SHARED) "$(DESTDIR)$(GLEW_LIBDIR)/$(LIB.DEVLNK)" 228endif 229 $(INSTALL) -m 0644 lib/$(LIB.STATIC) "$(DESTDIR)$(GLEW_LIBDIR)/" 230 231install.bin: glew.bin 232 $(INSTALL) -d -m 0755 "$(DESTDIR)$(BINDIR)" 233 $(INSTALL) -s -m 0755 bin/$(GLEWINFO.BIN) bin/$(VISUALINFO.BIN) "$(DESTDIR)$(BINDIR)/" 234 235install.include: 236 $(INSTALL) -d -m 0755 "$(DESTDIR)$(INCDIR)" 237 $(INSTALL) -m 0644 include/GL/wglew.h "$(DESTDIR)$(INCDIR)/" 238 $(INSTALL) -m 0644 include/GL/glew.h "$(DESTDIR)$(INCDIR)/" 239 $(INSTALL) -m 0644 include/GL/glxew.h "$(DESTDIR)$(INCDIR)/" 240 241install.pkgconfig: glew.pc 242 $(INSTALL) -d -m 0755 "$(DESTDIR)$(PKGDIR)" 243 $(INSTALL) -d -m 0755 "$(DESTDIR)$(PKGDIR)" 244 $(INSTALL) -m 0644 glew.pc "$(DESTDIR)$(PKGDIR)/" 245 246uninstall: 247 $(RM) "$(DESTDIR)$(INCDIR)/wglew.h" 248 $(RM) "$(DESTDIR)$(INCDIR)/glew.h" 249 $(RM) "$(DESTDIR)$(INCDIR)/glxew.h" 250 $(RM) "$(DESTDIR)$(GLEW_LIBDIR)/$(LIB.DEVLNK)" 251ifeq ($(filter-out mingw% cygwin,$(SYSTEM)),) 252 $(RM) "$(DESTDIR)$(BINDIR)/$(LIB.SHARED)" 253else 254 $(RM) "$(DESTDIR)$(GLEW_LIBDIR)/$(LIB.SONAME)" 255 $(RM) "$(DESTDIR)$(GLEW_LIBDIR)/$(LIB.SHARED)" 256endif 257 $(RM) "$(DESTDIR)$(GLEW_LIBDIR)/$(LIB.STATIC)" 258 $(RM) "$(DESTDIR)$(BINDIR)/$(GLEWINFO.BIN)" "$(DESTDIR)$(BINDIR)/$(VISUALINFO.BIN)" 259 260clean: 261 $(RM) -r tmp/ 262 $(RM) -r lib/ 263 $(RM) -r bin/ 264 $(RM) glew.pc 265 266distclean: clean 267 find . -name \*~ | xargs $(RM) 268 find . -name .\*.sw\? | xargs $(RM) 269 270# Distributions 271 272dist-win32: 273 $(RM) -r $(DIST_DIR) 274 mkdir -p $(DIST_DIR) 275 cp -a include $(DIST_DIR) 276 cp -a doc $(DIST_DIR) 277 cp -a *.txt $(DIST_DIR) 278 cp -a bin $(DIST_DIR) 279 cp -a lib $(DIST_DIR) 280 $(RM) -f $(DIST_DIR)/bin/*/*/*.pdb $(DIST_DIR)/bin/*/*/*.exp 281 $(RM) -f $(DIST_DIR)/bin/*/*/glewinfo-*.exe $(DIST_DIR)/bin/*/*/visualinfo-*.exe 282 $(RM) -f $(DIST_DIR)/lib/*/*/*.pdb $(DIST_DIR)/lib/*/*/*.exp 283 $(UNIX2DOS) $(DIST_DIR)/include/GL/*.h 284 $(UNIX2DOS) $(DIST_DIR)/doc/*.txt 285 $(UNIX2DOS) $(DIST_DIR)/doc/*.html 286 $(UNIX2DOS) $(DIST_DIR)/*.txt 287 rm -f $(DIST_WIN32) 288 cd $(DIST_DIR)/.. && zip -rq9 $(DIST_WIN32) $(DIST_NAME) 289 $(RM) -r $(DIST_DIR) 290 291dist-src: 292 $(RM) -r $(DIST_DIR) 293 mkdir -p $(DIST_DIR) 294 mkdir -p $(DIST_DIR)/bin 295 mkdir -p $(DIST_DIR)/lib 296 cp -a auto $(DIST_DIR) 297 $(RM) -Rf $(DIST_DIR)/auto/registry 298 $(RM) -Rf $(DIST_DIR)/auto/glfixes 299 $(RM) -Rf $(DIST_DIR)/auto/OpenGL-Registry 300 $(RM) -Rf $(DIST_DIR)/auto/EGL-Registry 301 cp -a build $(DIST_DIR) 302 cp -a config $(DIST_DIR) 303 cp -a src $(DIST_DIR) 304 cp -a doc $(DIST_DIR) 305 cp -a include $(DIST_DIR) 306 cp -a *.md $(DIST_DIR) 307 cp -a *.txt $(DIST_DIR) 308 cp -a Makefile $(DIST_DIR) 309 cp -a glew.pc.in $(DIST_DIR) 310 find $(DIST_DIR) -name '*.o' | xargs $(RM) -r 311 find $(DIST_DIR) -name '*~' | xargs $(RM) -r 312 find $(DIST_DIR) -name CVS -o -name .cvsignore | xargs $(RM) -r 313 find $(DIST_DIR) -name .svn | xargs $(RM) -r 314 find $(DIST_DIR) -name "*.patch" | xargs $(RM) -r 315 $(DOS2UNIX) $(DIST_DIR)/Makefile 316 $(DOS2UNIX) $(DIST_DIR)/auto/Makefile 317 $(DOS2UNIX) $(DIST_DIR)/config/* 318 $(UNIX2DOS) $(DIST_DIR)/auto/core/* 319 $(UNIX2DOS) $(DIST_DIR)/auto/extensions/* 320 find $(DIST_DIR) -name '*.h' | xargs $(UNIX2DOS) 321 find $(DIST_DIR) -name '*.c' | xargs $(UNIX2DOS) 322 find $(DIST_DIR) -name '*.md' | xargs $(UNIX2DOS) 323 find $(DIST_DIR) -name '*.txt' | xargs $(UNIX2DOS) 324 find $(DIST_DIR) -name '*.html' | xargs $(UNIX2DOS) 325 find $(DIST_DIR) -name '*.css' | xargs $(UNIX2DOS) 326 find $(DIST_DIR) -name '*.sh' | xargs $(UNIX2DOS) 327 find $(DIST_DIR) -name '*.pl' | xargs $(UNIX2DOS) 328 find $(DIST_DIR) -name 'Makefile' | xargs $(UNIX2DOS) 329 find $(DIST_DIR) -name '*.in' | xargs $(UNIX2DOS) 330 find $(DIST_DIR) -name '*.pm' | xargs $(UNIX2DOS) 331 find $(DIST_DIR) -name '*.rc' | xargs $(UNIX2DOS) 332 rm -f $(DIST_SRC_ZIP) 333 cd $(DIST_DIR)/.. && zip -rq9 $(DIST_SRC_ZIP) $(DIST_NAME) 334 $(DOS2UNIX) $(DIST_DIR)/Makefile 335 $(DOS2UNIX) $(DIST_DIR)/auto/Makefile 336 $(DOS2UNIX) $(DIST_DIR)/config/* 337 $(DOS2UNIX) $(DIST_DIR)/auto/core/* 338 $(DOS2UNIX) $(DIST_DIR)/auto/extensions/* 339 find $(DIST_DIR) -name '*.h' | xargs $(DOS2UNIX) 340 find $(DIST_DIR) -name '*.c' | xargs $(DOS2UNIX) 341 find $(DIST_DIR) -name '*.md' | xargs $(DOS2UNIX) 342 find $(DIST_DIR) -name '*.txt' | xargs $(DOS2UNIX) 343 find $(DIST_DIR) -name '*.html' | xargs $(DOS2UNIX) 344 find $(DIST_DIR) -name '*.css' | xargs $(DOS2UNIX) 345 find $(DIST_DIR) -name '*.sh' | xargs $(DOS2UNIX) 346 find $(DIST_DIR) -name '*.pl' | xargs $(DOS2UNIX) 347 find $(DIST_DIR) -name 'Makefile' | xargs $(DOS2UNIX) 348 find $(DIST_DIR) -name '*.in' | xargs $(DOS2UNIX) 349 find $(DIST_DIR) -name '*.pm' | xargs $(DOS2UNIX) 350 find $(DIST_DIR) -name '*.rc' | xargs $(DOS2UNIX) 351 rm -f $(DIST_SRC_TGZ) 352 cd $(DIST_DIR)/.. && env GZIP=-9 tar czf $(DIST_SRC_TGZ) $(DIST_NAME) 353 $(RM) -r $(DIST_DIR) 354 355extensions: 356 $(MAKE) -C auto 357 358.PHONY: clean distclean tardist dist-win32 dist-src 359