Makefile refinements: Move strip step from install to build, make it optional. Don't use exotic .o suffixes. Put temporary files in tmp/ for easy seperation and deltion

This commit is contained in:
Nigel Stewart 2012-02-12 14:12:36 -06:00
parent 64e751c741
commit aa7da9242a
6 changed files with 89 additions and 69 deletions

145
Makefile
View File

@ -44,7 +44,6 @@ GLEW_DEST ?= /usr
BINDIR ?= $(GLEW_DEST)/bin BINDIR ?= $(GLEW_DEST)/bin
LIBDIR ?= $(GLEW_DEST)/lib LIBDIR ?= $(GLEW_DEST)/lib
INCDIR ?= $(GLEW_DEST)/include/GL INCDIR ?= $(GLEW_DEST)/include/GL
SHARED_OBJ_EXT ?= o
TARDIR = ../glew-$(GLEW_VERSION) TARDIR = ../glew-$(GLEW_VERSION)
TARBALL = ../glew-$(GLEW_VERSION).tar.gz TARBALL = ../glew-$(GLEW_VERSION).tar.gz
@ -54,11 +53,16 @@ DIST_WIN32 = glew-$(GLEW_VERSION)-win32.zip
DIST_SRC_ZIP = glew-$(GLEW_VERSION).zip DIST_SRC_ZIP = glew-$(GLEW_VERSION).zip
DIST_SRC_TGZ = glew-$(GLEW_VERSION).tgz DIST_SRC_TGZ = glew-$(GLEW_VERSION).tgz
AR = ar # To disable stripping of binaries either:
INSTALL = install # - use STRIP= on gmake command-line
STRIP = strip # - edit this makefile to set STRIP to the empty string
RM = rm -f
LN = ln -sf AR ?= ar
INSTALL ?= install
STRIP ?= strip
RM ?= rm -f
LN ?= ln -sf
ifeq ($(MAKECMDGOALS), debug) ifeq ($(MAKECMDGOALS), debug)
OPT = -g OPT = -g
else else
@ -67,29 +71,25 @@ endif
INCLUDE = -Iinclude INCLUDE = -Iinclude
CFLAGS = $(OPT) $(WARN) $(INCLUDE) $(CFLAGS.EXTRA) CFLAGS = $(OPT) $(WARN) $(INCLUDE) $(CFLAGS.EXTRA)
LIB.SRCS = src/glew.c
LIB.OBJS = $(LIB.SRCS:.c=.o)
LIB.SOBJS = $(LIB.SRCS:.c=.$(SHARED_OBJ_EXT))
LIB.LDFLAGS = $(LDFLAGS.EXTRA) $(LDFLAGS.GL)
LIB.LIBS = $(GL_LDFLAGS)
LIB.OBJS.MX = $(LIB.SRCS:.c=.mx.o)
LIB.SOBJS.MX = $(LIB.SRCS:.c=.mx.$(SHARED_OBJ_EXT))
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)
BIN.LIBS = -Llib $(LDFLAGS.DYNAMIC) -l$(NAME) $(LDFLAGS.EXTRA) $(LDFLAGS.GL)
all debug: glew.lib glew.lib.mx glew.bin all debug: glew.lib glew.lib.mx glew.bin
%.o: %.c # GLEW shared and static libraries
$(CC) -c $(CFLAGS) -o $@ $<
# GLEW libraries 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)
LIB.OBJS.MX := $(addprefix tmp/$(SYSTEM)/mx/static/,$(LIB.SRCS.NAMES))
LIB.OBJS.MX := $(LIB.OBJS.MX:.c=.o)
LIB.SOBJS.MX := $(addprefix tmp/$(SYSTEM)/mx/shared/,$(LIB.SRCS.NAMES))
LIB.SOBJS.MX := $(LIB.SOBJS.MX:.c=.o)
glew.lib: lib lib/$(LIB.SHARED) lib/$(LIB.STATIC) glew.pc glew.lib: lib lib/$(LIB.SHARED) lib/$(LIB.STATIC) glew.pc
@ -98,6 +98,9 @@ lib:
lib/$(LIB.STATIC): $(LIB.OBJS) lib/$(LIB.STATIC): $(LIB.OBJS)
$(AR) cr $@ $^ $(AR) cr $@ $^
ifneq ($(STRIP),)
$(STRIP) -x $@
endif
lib/$(LIB.SHARED): $(LIB.SOBJS) lib/$(LIB.SHARED): $(LIB.SOBJS)
$(LD) $(LDFLAGS.SO) -o $@ $^ $(LIB.LDFLAGS) $(LIB.LIBS) $(LD) $(LDFLAGS.SO) -o $@ $^ $(LIB.LDFLAGS) $(LIB.LIBS)
@ -106,6 +109,17 @@ else
$(LN) $(LIB.SHARED) lib/$(LIB.SONAME) $(LN) $(LIB.SHARED) lib/$(LIB.SONAME)
$(LN) $(LIB.SHARED) lib/$(LIB.DEVLNK) $(LN) $(LIB.SHARED) lib/$(LIB.DEVLNK)
endif endif
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 $@)
$(CC) -DGLEW_NO_GLU -DGLEW_STATIC $(CFLAGS) $(CFLAGS.SO) -o $@ -c $<
tmp/$(SYSTEM)/default/shared/glew.o: src/glew.c include/GL/glew.h include/GL/wglew.h include/GL/glxew.h
@mkdir -p $(dir $@)
$(CC) -DGLEW_NO_GLU $(CFLAGS) $(PICFLAG) $(CFLAGS.SO) -o $@ -c $<
glew.pc: glew.pc.in glew.pc: glew.pc.in
sed \ sed \
@ -118,13 +132,7 @@ glew.pc: glew.pc.in
-e "s|@libname@|GLEW|g" \ -e "s|@libname@|GLEW|g" \
< $< > $@ < $< > $@
src/glew.o: src/glew.c include/GL/glew.h include/GL/wglew.h include/GL/glxew.h # GLEW MX static and shared libraries
$(CC) -DGLEW_NO_GLU $(CFLAGS) $(CFLAGS.SO) -o $@ -c $<
src/glew.pic_o: src/glew.c include/GL/glew.h include/GL/wglew.h include/GL/glxew.h
$(CC) -DGLEW_NO_GLU $(CFLAGS) $(PICFLAG) $(CFLAGS.SO) -o $@ -c $<
# GLEW MX libraries
glew.lib.mx: lib lib/$(LIB.SHARED.MX) lib/$(LIB.STATIC.MX) glewmx.pc glew.lib.mx: lib lib/$(LIB.SHARED.MX) lib/$(LIB.STATIC.MX) glewmx.pc
@ -138,6 +146,17 @@ else
$(LN) $(LIB.SHARED.MX) lib/$(LIB.SONAME.MX) $(LN) $(LIB.SHARED.MX) lib/$(LIB.SONAME.MX)
$(LN) $(LIB.SHARED.MX) lib/$(LIB.DEVLNK.MX) $(LN) $(LIB.SHARED.MX) lib/$(LIB.DEVLNK.MX)
endif endif
ifneq ($(STRIP),)
$(STRIP) -x $@
endif
tmp/$(SYSTEM)/mx/static/glew.o: src/glew.c include/GL/glew.h include/GL/wglew.h include/GL/glxew.h
@mkdir -p $(dir $@)
$(CC) -DGLEW_NO_GLU -DGLEW_MX -DGLEW_STATIC $(CFLAGS) $(CFLAGS.SO) -o $@ -c $<
tmp/$(SYSTEM)/mx/shared/glew.o: src/glew.c include/GL/glew.h include/GL/wglew.h include/GL/glxew.h
@mkdir -p $(dir $@)
$(CC) -DGLEW_NO_GLU -DGLEW_MX $(CFLAGS) $(PICFLAG) $(CFLAGS.SO) -o $@ -c $<
glewmx.pc: glew.pc.in glewmx.pc: glew.pc.in
sed \ sed \
@ -150,24 +169,44 @@ glewmx.pc: glew.pc.in
-e "s|@libname@|GLEWmx|g" \ -e "s|@libname@|GLEWmx|g" \
< $< > $@ < $< > $@
src/glew.mx.o: src/glew.c include/GL/glew.h include/GL/wglew.h include/GL/glxew.h # GLEW utility programs
$(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 BIN.LIBS = -Llib $(LDFLAGS.DYNAMIC) -l$(NAME) $(LDFLAGS.EXTRA) $(LDFLAGS.GL)
$(CC) -DGLEW_NO_GLU -DGLEW_MX $(CFLAGS) $(PICFLAG) $(CFLAGS.SO) -o $@ -c $<
# GLEW utilities 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)
glew.bin: glew.lib bin bin/$(GLEWINFO.BIN) bin/$(VISUALINFO.BIN)
bin: bin:
mkdir bin mkdir bin
glew.bin: glew.lib bin bin/$(GLEWINFO.BIN) bin/$(VISUALINFO.BIN) bin/$(GLEWINFO.BIN): $(GLEWINFO.BIN.OBJ) lib/$(LIB.SHARED)
$(CC) $(CFLAGS) -o $@ $(GLEWINFO.BIN.OBJ) $(BIN.LIBS)
ifneq ($(STRIP),)
$(STRIP) -x $@
endif
bin/$(GLEWINFO.BIN): $(GLEWINFO.BIN.OBJS) lib/$(LIB.SHARED) bin/$(VISUALINFO.BIN): $(VISUALINFO.BIN.OBJ) lib/$(LIB.SHARED)
$(CC) $(CFLAGS) -o $@ $(GLEWINFO.BIN.OBJS) $(BIN.LIBS) $(CC) $(CFLAGS) -o $@ $(VISUALINFO.BIN.OBJ) $(BIN.LIBS)
ifneq ($(STRIP),)
$(STRIP) -x $@
endif
bin/$(VISUALINFO.BIN): $(VISUALINFO.BIN.OBJS) lib/$(LIB.SHARED) $(GLEWINFO.BIN.OBJ): $(GLEWINFO.BIN.SRC) include/GL/glew.h include/GL/wglew.h include/GL/glxew.h
$(CC) $(CFLAGS) -o $@ $(VISUALINFO.BIN.OBJS) $(BIN.LIBS) @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 $<
# Install targets # Install targets
@ -182,10 +221,8 @@ install.lib: glew.lib
# runtime # runtime
ifeq ($(filter-out mingw% cygwin,$(SYSTEM)),) ifeq ($(filter-out mingw% cygwin,$(SYSTEM)),)
$(INSTALL) -d -m 0755 $(BINDIR) $(INSTALL) -d -m 0755 $(BINDIR)
$(STRIP) -x lib/$(LIB.SHARED)
$(INSTALL) -m 0755 lib/$(LIB.SHARED) $(BINDIR)/ $(INSTALL) -m 0755 lib/$(LIB.SHARED) $(BINDIR)/
else else
$(STRIP) -x lib/$(LIB.SHARED)
$(INSTALL) -m 0644 lib/$(LIB.SHARED) $(LIBDIR)/ $(INSTALL) -m 0644 lib/$(LIB.SHARED) $(LIBDIR)/
$(LN) $(LIB.SHARED) $(LIBDIR)/$(LIB.SONAME) $(LN) $(LIB.SHARED) $(LIBDIR)/$(LIB.SONAME)
endif endif
@ -195,7 +232,6 @@ ifeq ($(filter-out mingw% cygwin,$(SYSTEM)),)
else else
$(LN) $(LIB.SHARED) $(LIBDIR)/$(LIB.DEVLNK) $(LN) $(LIB.SHARED) $(LIBDIR)/$(LIB.DEVLNK)
endif endif
$(STRIP) -x lib/$(LIB.STATIC)
$(INSTALL) -m 0644 lib/$(LIB.STATIC) $(LIBDIR)/ $(INSTALL) -m 0644 lib/$(LIB.STATIC) $(LIBDIR)/
install.lib.mx: glew.lib.mx install.lib.mx: glew.lib.mx
@ -203,10 +239,8 @@ install.lib.mx: glew.lib.mx
# runtime # runtime
ifeq ($(filter-out mingw% cygwin,$(SYSTEM)),) ifeq ($(filter-out mingw% cygwin,$(SYSTEM)),)
$(INSTALL) -d -m 0755 $(BINDIR) $(INSTALL) -d -m 0755 $(BINDIR)
$(STRIP) -x lib/$(LIB.SHARED.MX)
$(INSTALL) -m 0755 lib/$(LIB.SHARED.MX) $(BINDIR)/ $(INSTALL) -m 0755 lib/$(LIB.SHARED.MX) $(BINDIR)/
else else
$(STRIP) -x lib/$(LIB.SHARED.MX)
$(INSTALL) -m 0644 lib/$(LIB.SHARED.MX) $(LIBDIR)/ $(INSTALL) -m 0644 lib/$(LIB.SHARED.MX) $(LIBDIR)/
$(LN) $(LIB.SHARED.MX) $(LIBDIR)/$(LIB.SONAME.MX) $(LN) $(LIB.SHARED.MX) $(LIBDIR)/$(LIB.SONAME.MX)
endif endif
@ -216,7 +250,6 @@ ifeq ($(filter-out mingw% cygwin,$(SYSTEM)),)
else else
$(LN) $(LIB.SHARED.MX) $(LIBDIR)/$(LIB.DEVLNK.MX) $(LN) $(LIB.SHARED.MX) $(LIBDIR)/$(LIB.DEVLNK.MX)
endif endif
$(STRIP) -x lib/$(LIB.STATIC.MX)
$(INSTALL) -m 0644 lib/$(LIB.STATIC.MX) $(LIBDIR)/ $(INSTALL) -m 0644 lib/$(LIB.STATIC.MX) $(LIBDIR)/
install.bin: glew.bin install.bin: glew.bin
@ -254,15 +287,10 @@ endif
$(RM) $(BINDIR)/$(GLEWINFO.BIN) $(BINDIR)/$(VISUALINFO.BIN) $(RM) $(BINDIR)/$(GLEWINFO.BIN) $(BINDIR)/$(VISUALINFO.BIN)
clean: clean:
$(RM) $(LIB.OBJS) $(LIB.OBJS.MX) $(RM) -r tmp/
$(RM) $(LIB.SOBJS) $(LIB.SOBJS.MX) $(RM) -r lib/
$(RM) lib/$(LIB.STATIC) lib/$(LIB.SHARED) lib/$(LIB.DEVLNK) lib/$(LIB.SONAME) $(LIB.STATIC) $(RM) -r bin/
$(RM) lib/$(LIB.STATIC.MX) lib/$(LIB.SHARED.MX) lib/$(LIB.DEVLNK.MX) lib/$(LIB.SONAME.MX) $(LIB.STATIC.MX)
$(RM) $(GLEWINFO.BIN.OBJS) bin/$(GLEWINFO.BIN) $(VISUALINFO.BIN.OBJS) bin/$(VISUALINFO.BIN)
$(RM) glew.pc glewmx.pc $(RM) glew.pc glewmx.pc
# Compiler droppings
$(RM) so_locations
$(RM) -r lib/ bin/
distclean: clean distclean: clean
find . -name \*~ | xargs $(RM) find . -name \*~ | xargs $(RM)
@ -312,9 +340,6 @@ dist-src:
cp -a Makefile $(TARDIR) cp -a Makefile $(TARDIR)
cp -a glew.pc.in $(TARDIR) cp -a glew.pc.in $(TARDIR)
find $(TARDIR) -name '*.o' | xargs $(RM) -r find $(TARDIR) -name '*.o' | xargs $(RM) -r
find $(TARDIR) -name '*.mx.o' | xargs $(RM) -r
find $(TARDIR) -name '*.pic_o' | xargs $(RM) -r
find $(TARDIR) -name '*.mx.pic_o' | xargs $(RM) -r
find $(TARDIR) -name '*~' | xargs $(RM) -r find $(TARDIR) -name '*~' | xargs $(RM) -r
find $(TARDIR) -name CVS -o -name .cvsignore | xargs $(RM) -r find $(TARDIR) -name CVS -o -name .cvsignore | xargs $(RM) -r
find $(TARDIR) -name .svn | xargs $(RM) -r find $(TARDIR) -name .svn | xargs $(RM) -r

View File

@ -25,4 +25,3 @@ LIB.DEVLNK.MX = lib$(NAME)mx.dylib
LIB.SHARED.MX = lib$(NAME)mx.$(SO_VERSION).dylib LIB.SHARED.MX = lib$(NAME)mx.$(SO_VERSION).dylib
LIB.STATIC.MX = lib$(NAME)mx.a LIB.STATIC.MX = lib$(NAME)mx.a
LDFLAGS.SO.MX = -dynamiclib -install_name $(GLEW_DEST)/lib/$(LIB.SHARED.MX) -current_version $(SO_VERSION) -compatibility_version $(SO_MAJOR) LDFLAGS.SO.MX = -dynamiclib -install_name $(GLEW_DEST)/lib/$(LIB.SHARED.MX) -current_version $(SO_VERSION) -compatibility_version $(SO_MAJOR)
SHARED_OBJ_EXT = pic_o

View File

@ -25,4 +25,3 @@ LIB.DEVLNK.MX = lib$(NAME)mx.dylib
LIB.SHARED.MX = lib$(NAME)mx.$(SO_VERSION).dylib LIB.SHARED.MX = lib$(NAME)mx.$(SO_VERSION).dylib
LIB.STATIC.MX = lib$(NAME)mx.a LIB.STATIC.MX = lib$(NAME)mx.a
LDFLAGS.SO.MX = -dynamiclib -install_name $(GLEW_DEST)/lib/$(LIB.SHARED.MX) -current_version $(SO_VERSION) -compatibility_version $(SO_MAJOR) LDFLAGS.SO.MX = -dynamiclib -install_name $(GLEW_DEST)/lib/$(LIB.SHARED.MX) -current_version $(SO_VERSION) -compatibility_version $(SO_MAJOR)
SHARED_OBJ_EXT = pic_o

View File

@ -20,4 +20,3 @@ LIB.DEVLNK.MX = lib$(NAME)mx.so
LIB.SHARED.MX = lib$(NAME)mx.so.$(SO_VERSION) LIB.SHARED.MX = lib$(NAME)mx.so.$(SO_VERSION)
LIB.STATIC.MX = lib$(NAME)mx.a LIB.STATIC.MX = lib$(NAME)mx.a
LDFLAGS.SO.MX = -shared -Wl,-soname=$(LIB.SONAME.MX) LDFLAGS.SO.MX = -shared -Wl,-soname=$(LIB.SONAME.MX)
SHARED_OBJ_EXT = pic_o

View File

@ -20,4 +20,3 @@ LIB.DEVLNK.MX = lib$(NAME)mx.so
LIB.SHARED.MX = lib$(NAME)mx.so.$(SO_VERSION) LIB.SHARED.MX = lib$(NAME)mx.so.$(SO_VERSION)
LIB.STATIC.MX = lib$(NAME)mx.a LIB.STATIC.MX = lib$(NAME)mx.a
LDFLAGS.SO.MX = -shared -Wl,-soname $(LIB.SONAME.MX) LDFLAGS.SO.MX = -shared -Wl,-soname $(LIB.SONAME.MX)
SHARED_OBJ_EXT = pic_o

View File

@ -27,4 +27,3 @@ LIB.DEVLNK.MX = lib$(NAME)mx.so
LIB.SHARED.MX = lib$(NAME)mx.so.$(SO_VERSION) LIB.SHARED.MX = lib$(NAME)mx.so.$(SO_VERSION)
LIB.STATIC.MX = lib$(NAME)mx.a LIB.STATIC.MX = lib$(NAME)mx.a
LDFLAGS.SO.MX = -shared -Wl,-soname=$(LIB.SONAME.MX) LDFLAGS.SO.MX = -shared -Wl,-soname=$(LIB.SONAME.MX)
SHARED_OBJ_EXT = pic_o