You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

353 lines
11KB

  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. include config/version
  31. SHELL = /bin/sh
  32. SYSTEM ?= $(shell config/config.guess | cut -d - -f 3 | sed -e 's/[0-9\.]//g;')
  33. SYSTEM.SUPPORTED = $(shell test -f config/Makefile.$(SYSTEM) && echo 1)
  34. ifeq ($(SYSTEM.SUPPORTED), 1)
  35. include config/Makefile.$(SYSTEM)
  36. else
  37. $(error "Platform '$(SYSTEM)' not supported")
  38. endif
  39. GLEW_PREFIX ?= /usr
  40. GLEW_DEST ?= /usr
  41. BINDIR ?= $(GLEW_DEST)/bin
  42. LIBDIR ?= $(GLEW_DEST)/lib
  43. INCDIR ?= $(GLEW_DEST)/include/GL
  44. PKGDIR ?= $(GLEW_DEST)/lib/pkgconfig
  45. ifneq ($(GLEW_NO_GLU), -DGLEW_NO_GLU)
  46. LIBGLU = glu
  47. endif
  48. DIST_NAME ?= glew-$(GLEW_VERSION)
  49. DIST_SRC_ZIP ?= $(shell pwd)/$(DIST_NAME).zip
  50. DIST_SRC_TGZ ?= $(shell pwd)/$(DIST_NAME).tgz
  51. DIST_WIN32 ?= $(shell pwd)/$(DIST_NAME)-win32.zip
  52. DIST_DIR := $(shell mktemp -d /tmp/glew.XXXXXX)/$(DIST_NAME)
  53. # To disable stripping of linked binaries either:
  54. # - use STRIP= on gmake command-line
  55. # - edit this makefile to set STRIP to the empty string
  56. # (Note: STRIP does not affect the strip in the install step)
  57. #
  58. # To disable symlinks:
  59. # - use LN= on gmake command-line
  60. AR ?= ar
  61. ARFLAGS ?= cr
  62. INSTALL ?= install
  63. STRIP ?= strip
  64. RM ?= rm -f
  65. LN ?= ln -sf
  66. UNIX2DOS ?= unix2dos -q
  67. DOS2UNIX ?= dos2unix -q
  68. ifneq (,$(filter debug,$(MAKECMDGOALS)))
  69. OPT = -g
  70. else
  71. OPT = $(POPT)
  72. endif
  73. INCLUDE = -Iinclude
  74. CFLAGS = $(OPT) $(WARN) $(INCLUDE) $(CFLAGS.EXTRA)
  75. all debug: glew.lib glew.bin
  76. # GLEW shared and static libraries
  77. LIB.LDFLAGS := $(LDFLAGS.EXTRA) $(LDFLAGS.GL)
  78. LIB.LIBS := $(GL_LDFLAGS)
  79. LIB.SRCS := src/glew.c
  80. LIB.SRCS.NAMES := $(notdir $(LIB.SRCS))
  81. LIB.OBJS := $(addprefix tmp/$(SYSTEM)/default/static/,$(LIB.SRCS.NAMES))
  82. LIB.OBJS := $(LIB.OBJS:.c=.o)
  83. LIB.SOBJS := $(addprefix tmp/$(SYSTEM)/default/shared/,$(LIB.SRCS.NAMES))
  84. LIB.SOBJS := $(LIB.SOBJS:.c=.o)
  85. glew.lib: glew.lib.shared glew.lib.static
  86. glew.lib.shared: lib lib/$(LIB.SHARED) glew.pc
  87. glew.lib.static: lib lib/$(LIB.STATIC) glew.pc
  88. .PHONY: glew.lib glew.lib.shared glew.lib.static
  89. lib:
  90. mkdir lib
  91. lib/$(LIB.STATIC): $(LIB.OBJS)
  92. ifneq ($(AR),)
  93. $(AR) $(ARFLAGS) $@ $^
  94. else ifneq ($(LIBTOOL),)
  95. $(LIBTOOL) $@ $^
  96. endif
  97. ifneq ($(STRIP),)
  98. $(STRIP) -x $@
  99. endif
  100. lib/$(LIB.SHARED): $(LIB.SOBJS)
  101. $(LD) $(LDFLAGS.SO) -o $@ $^ $(LIB.LDFLAGS) $(LIB.LIBS)
  102. ifneq ($(LN),)
  103. $(LN) $(LIB.SHARED) lib/$(LIB.SONAME)
  104. $(LN) $(LIB.SHARED) lib/$(LIB.DEVLNK)
  105. endif
  106. ifneq ($(STRIP),)
  107. $(STRIP) -x $@
  108. endif
  109. tmp/$(SYSTEM)/default/static/glew.o: src/glew.c include/GL/glew.h include/GL/wglew.h include/GL/glxew.h
  110. @mkdir -p $(dir $@)
  111. $(CC) -DGLEW_NO_GLU -DGLEW_STATIC $(CFLAGS) $(CFLAGS.SO) -o $@ -c $<
  112. tmp/$(SYSTEM)/default/shared/glew.o: src/glew.c include/GL/glew.h include/GL/wglew.h include/GL/glxew.h
  113. @mkdir -p $(dir $@)
  114. $(CC) -DGLEW_NO_GLU -DGLEW_BUILD $(CFLAGS) $(CFLAGS.SO) -o $@ -c $<
  115. # Force re-write of glew.pc, GLEW_DEST can vary
  116. .PHONY: glew.pc
  117. glew.pc: glew.pc.in
  118. sed \
  119. -e "s|@prefix@|$(GLEW_PREFIX)|g" \
  120. -e "s|@libdir@|$(LIBDIR)|g" \
  121. -e "s|@exec_prefix@|$(BINDIR)|g" \
  122. -e "s|@includedir@|$(INCDIR)|g" \
  123. -e "s|@version@|$(GLEW_VERSION)|g" \
  124. -e "s|@cflags@||g" \
  125. -e "s|@libname@|$(NAME)|g" \
  126. -e "s|@requireslib@|$(LIBGLU)|g" \
  127. < $< > $@
  128. # GLEW utility programs
  129. BIN.LIBS = -Llib $(LDFLAGS.DYNAMIC) -l$(NAME) $(LDFLAGS.EXTRA) $(LDFLAGS.GL)
  130. GLEWINFO.BIN := glewinfo$(BIN.SUFFIX)
  131. GLEWINFO.BIN.SRC := src/glewinfo.c
  132. GLEWINFO.BIN.OBJ := $(addprefix tmp/$(SYSTEM)/default/shared/,$(notdir $(GLEWINFO.BIN.SRC)))
  133. GLEWINFO.BIN.OBJ := $(GLEWINFO.BIN.OBJ:.c=.o)
  134. VISUALINFO.BIN := visualinfo$(BIN.SUFFIX)
  135. VISUALINFO.BIN.SRC := src/visualinfo.c
  136. VISUALINFO.BIN.OBJ := $(addprefix tmp/$(SYSTEM)/default/shared/,$(notdir $(VISUALINFO.BIN.SRC)))
  137. VISUALINFO.BIN.OBJ := $(VISUALINFO.BIN.OBJ:.c=.o)
  138. # Don't build glewinfo or visualinfo for NaCL, yet.
  139. ifneq ($(filter nacl%,$(SYSTEM)),)
  140. glew.bin: glew.lib bin
  141. else
  142. glew.bin: glew.lib bin bin/$(GLEWINFO.BIN) bin/$(VISUALINFO.BIN)
  143. endif
  144. bin:
  145. mkdir bin
  146. bin/$(GLEWINFO.BIN): $(GLEWINFO.BIN.OBJ) lib/$(LIB.SHARED)
  147. $(CC) $(CFLAGS) -o $@ $(GLEWINFO.BIN.OBJ) $(BIN.LIBS)
  148. ifneq ($(STRIP),)
  149. $(STRIP) -x $@
  150. endif
  151. bin/$(VISUALINFO.BIN): $(VISUALINFO.BIN.OBJ) lib/$(LIB.SHARED)
  152. $(CC) $(CFLAGS) -o $@ $(VISUALINFO.BIN.OBJ) $(BIN.LIBS)
  153. ifneq ($(STRIP),)
  154. $(STRIP) -x $@
  155. endif
  156. $(GLEWINFO.BIN.OBJ): $(GLEWINFO.BIN.SRC) include/GL/glew.h include/GL/wglew.h include/GL/glxew.h
  157. @mkdir -p $(dir $@)
  158. $(CC) -DGLEW_NO_GLU $(CFLAGS) $(CFLAGS.SO) -o $@ -c $<
  159. $(VISUALINFO.BIN.OBJ): $(VISUALINFO.BIN.SRC) include/GL/glew.h include/GL/wglew.h include/GL/glxew.h
  160. @mkdir -p $(dir $@)
  161. $(CC) -DGLEW_NO_GLU $(CFLAGS) $(CFLAGS.SO) -o $@ -c $<
  162. # Install targets
  163. install.all: install install.bin
  164. install: install.include install.lib install.pkgconfig
  165. install.lib: glew.lib
  166. $(INSTALL) -d -m 0755 "$(DESTDIR)$(LIBDIR)"
  167. # runtime
  168. ifeq ($(filter-out mingw% cygwin,$(SYSTEM)),)
  169. $(INSTALL) -d -m 0755 "$(DESTDIR)$(BINDIR)"
  170. $(INSTALL) -m 0755 lib/$(LIB.SHARED) "$(DESTDIR)$(BINDIR)/"
  171. else
  172. $(INSTALL) -m 0644 lib/$(LIB.SHARED) "$(DESTDIR)$(LIBDIR)/"
  173. endif
  174. ifneq ($(LN),)
  175. $(LN) $(LIB.SHARED) "$(DESTDIR)$(LIBDIR)/$(LIB.SONAME)"
  176. endif
  177. # development files
  178. ifeq ($(filter-out mingw% cygwin,$(SYSTEM)),)
  179. $(INSTALL) -m 0644 lib/$(LIB.DEVLNK) "$(DESTDIR)$(LIBDIR)/"
  180. endif
  181. ifneq ($(LN),)
  182. $(LN) $(LIB.SHARED) "$(DESTDIR)$(LIBDIR)/$(LIB.DEVLNK)"
  183. endif
  184. $(INSTALL) -m 0644 lib/$(LIB.STATIC) "$(DESTDIR)$(LIBDIR)/"
  185. install.bin: glew.bin
  186. $(INSTALL) -d -m 0755 "$(DESTDIR)$(BINDIR)"
  187. $(INSTALL) -s -m 0755 bin/$(GLEWINFO.BIN) bin/$(VISUALINFO.BIN) "$(DESTDIR)$(BINDIR)/"
  188. install.include:
  189. $(INSTALL) -d -m 0755 "$(DESTDIR)$(INCDIR)"
  190. $(INSTALL) -m 0644 include/GL/wglew.h "$(DESTDIR)$(INCDIR)/"
  191. $(INSTALL) -m 0644 include/GL/glew.h "$(DESTDIR)$(INCDIR)/"
  192. $(INSTALL) -m 0644 include/GL/glxew.h "$(DESTDIR)$(INCDIR)/"
  193. install.pkgconfig: glew.pc
  194. $(INSTALL) -d -m 0755 "$(DESTDIR)$(PKGDIR)"
  195. $(INSTALL) -d -m 0755 "$(DESTDIR)$(PKGDIR)"
  196. $(INSTALL) -m 0644 glew.pc "$(DESTDIR)$(PKGDIR)/"
  197. uninstall:
  198. $(RM) "$(DESTDIR)$(INCDIR)/wglew.h"
  199. $(RM) "$(DESTDIR)$(INCDIR)/glew.h"
  200. $(RM) "$(DESTDIR)$(INCDIR)/glxew.h"
  201. $(RM) "$(DESTDIR)$(LIBDIR)/$(LIB.DEVLNK)"
  202. ifeq ($(filter-out mingw% cygwin,$(SYSTEM)),)
  203. $(RM) "$(DESTDIR)$(BINDIR)/$(LIB.SHARED)"
  204. else
  205. $(RM) "$(DESTDIR)$(LIBDIR)/$(LIB.SONAME)"
  206. $(RM) "$(DESTDIR)$(LIBDIR)/$(LIB.SHARED)"
  207. endif
  208. $(RM) "$(DESTDIR)$(LIBDIR)/$(LIB.STATIC)"
  209. $(RM) "$(DESTDIR)$(BINDIR)/$(GLEWINFO.BIN)" "$(DESTDIR)$(BINDIR)/$(VISUALINFO.BIN)"
  210. clean:
  211. $(RM) -r tmp/
  212. $(RM) -r lib/
  213. $(RM) -r bin/
  214. $(RM) glew.pc
  215. distclean: clean
  216. find . -name \*~ | xargs $(RM)
  217. find . -name .\*.sw\? | xargs $(RM)
  218. # Distributions
  219. dist-win32:
  220. $(RM) -r $(DIST_DIR)
  221. mkdir -p $(DIST_DIR)
  222. cp -a include $(DIST_DIR)
  223. cp -a doc $(DIST_DIR)
  224. cp -a *.txt $(DIST_DIR)
  225. cp -a bin $(DIST_DIR)
  226. cp -a lib $(DIST_DIR)
  227. $(RM) -f $(DIST_DIR)/bin/*/*/*.pdb $(DIST_DIR)/bin/*/*/*.exp
  228. $(RM) -f $(DIST_DIR)/bin/*/*/glewinfo-*.exe $(DIST_DIR)/bin/*/*/visualinfo-*.exe
  229. $(RM) -f $(DIST_DIR)/lib/*/*/*.pdb $(DIST_DIR)/lib/*/*/*.exp
  230. $(UNIX2DOS) $(DIST_DIR)/include/GL/*.h
  231. $(UNIX2DOS) $(DIST_DIR)/doc/*.txt
  232. $(UNIX2DOS) $(DIST_DIR)/doc/*.html
  233. $(UNIX2DOS) $(DIST_DIR)/*.txt
  234. rm -f $(DIST_WIN32)
  235. cd $(DIST_DIR)/.. && zip -rq9 $(DIST_WIN32) $(DIST_NAME)
  236. $(RM) -r $(DIST_DIR)
  237. dist-src:
  238. $(RM) -r $(DIST_DIR)
  239. mkdir -p $(DIST_DIR)
  240. mkdir -p $(DIST_DIR)/bin
  241. mkdir -p $(DIST_DIR)/lib
  242. cp -a auto $(DIST_DIR)
  243. $(RM) -Rf $(DIST_DIR)/auto/registry
  244. cp -a build $(DIST_DIR)
  245. cp -a config $(DIST_DIR)
  246. cp -a src $(DIST_DIR)
  247. cp -a doc $(DIST_DIR)
  248. cp -a include $(DIST_DIR)
  249. cp -a *.md $(DIST_DIR)
  250. cp -a *.txt $(DIST_DIR)
  251. cp -a Makefile $(DIST_DIR)
  252. cp -a glew.pc.in $(DIST_DIR)
  253. find $(DIST_DIR) -name '*.o' | xargs $(RM) -r
  254. find $(DIST_DIR) -name '*~' | xargs $(RM) -r
  255. find $(DIST_DIR) -name CVS -o -name .cvsignore | xargs $(RM) -r
  256. find $(DIST_DIR) -name .svn | xargs $(RM) -r
  257. find $(DIST_DIR) -name "*.patch" | xargs $(RM) -r
  258. $(DOS2UNIX) $(DIST_DIR)/Makefile
  259. $(DOS2UNIX) $(DIST_DIR)/auto/Makefile
  260. $(DOS2UNIX) $(DIST_DIR)/config/*
  261. $(UNIX2DOS) $(DIST_DIR)/auto/core/*
  262. $(UNIX2DOS) $(DIST_DIR)/auto/extensions/*
  263. find $(DIST_DIR) -name '*.h' | xargs $(UNIX2DOS)
  264. find $(DIST_DIR) -name '*.c' | xargs $(UNIX2DOS)
  265. find $(DIST_DIR) -name '*.md' | xargs $(UNIX2DOS)
  266. find $(DIST_DIR) -name '*.txt' | xargs $(UNIX2DOS)
  267. find $(DIST_DIR) -name '*.html' | xargs $(UNIX2DOS)
  268. find $(DIST_DIR) -name '*.css' | xargs $(UNIX2DOS)
  269. find $(DIST_DIR) -name '*.sh' | xargs $(UNIX2DOS)
  270. find $(DIST_DIR) -name '*.pl' | xargs $(UNIX2DOS)
  271. find $(DIST_DIR) -name 'Makefile' | xargs $(UNIX2DOS)
  272. find $(DIST_DIR) -name '*.in' | xargs $(UNIX2DOS)
  273. find $(DIST_DIR) -name '*.pm' | xargs $(UNIX2DOS)
  274. find $(DIST_DIR) -name '*.rc' | xargs $(UNIX2DOS)
  275. rm -f $(DIST_SRC_ZIP)
  276. cd $(DIST_DIR)/.. && zip -rq9 $(DIST_SRC_ZIP) $(DIST_NAME)
  277. $(DOS2UNIX) $(DIST_DIR)/Makefile
  278. $(DOS2UNIX) $(DIST_DIR)/auto/Makefile
  279. $(DOS2UNIX) $(DIST_DIR)/config/*
  280. $(DOS2UNIX) $(DIST_DIR)/auto/core/*
  281. $(DOS2UNIX) $(DIST_DIR)/auto/extensions/*
  282. find $(DIST_DIR) -name '*.h' | xargs $(DOS2UNIX)
  283. find $(DIST_DIR) -name '*.c' | xargs $(DOS2UNIX)
  284. find $(DIST_DIR) -name '*.md' | xargs $(DOS2UNIX)
  285. find $(DIST_DIR) -name '*.txt' | xargs $(DOS2UNIX)
  286. find $(DIST_DIR) -name '*.html' | xargs $(DOS2UNIX)
  287. find $(DIST_DIR) -name '*.css' | xargs $(DOS2UNIX)
  288. find $(DIST_DIR) -name '*.sh' | xargs $(DOS2UNIX)
  289. find $(DIST_DIR) -name '*.pl' | xargs $(DOS2UNIX)
  290. find $(DIST_DIR) -name 'Makefile' | xargs $(DOS2UNIX)
  291. find $(DIST_DIR) -name '*.in' | xargs $(DOS2UNIX)
  292. find $(DIST_DIR) -name '*.pm' | xargs $(DOS2UNIX)
  293. find $(DIST_DIR) -name '*.rc' | xargs $(DOS2UNIX)
  294. rm -f $(DIST_SRC_TGZ)
  295. cd $(DIST_DIR)/.. && env GZIP=-9 tar czf $(DIST_SRC_TGZ) $(DIST_NAME)
  296. $(RM) -r $(DIST_DIR)
  297. extensions:
  298. $(MAKE) -C auto
  299. .PHONY: clean distclean tardist dist-win32 dist-src