-CC ?= gcc
-CFLAGS ?= -g
-CFLAGS += -Wall -Wextra -Wmissing-declarations -Werror=attributes
+LIBGLAZE_VERSION_MAJOR = 0
+LIBGLAZE_VERSION_MINOR = 0
+LIBGLAZE_VERSION_RELEASE = 0
+
+LIBGLAZE_LINKER_NAME = libglaze.so
+LIBGLAZE_SONAME = $(LIBGLAZE_LINKER_NAME).$(LIBGLAZE_VERSION_MAJOR)
+LIBGLAZE_LIBNAME = $(LIBGLAZE_SONAME).$(LIBGLAZE_VERSION_MINOR).$(LIBGLAZE_VERSION_RELEASE)
TARGETS = lib64/libGL.so.1 lib32/libGL.so.1
all: $(TARGETS)
+$(LIBGLAZE_LIBNAME): glaze.c
+ $(CC) $(CFLAGS) -fPIC -shared -Wl,-Bsymbolic,-soname=$(LIBGLAZE_SONAME) -o $@ $<
+
lib64/libGL.so.1: glaze-gl.c glapi.def
mkdir -p lib64
$(CC) $(CFLAGS) -m64 -fPIC -shared -Wl,-Bsymbolic -o $@ $<
mkdir -p lib32
$(CC) $(CFLAGS) -m32 -fPIC -shared -Wl,-Bsymbolic -o $@ $<
+.PHONY: install
+install: all
+ mkdir -p $(DESTDIR)$(LIBDIR)/glaze/lib64
+ install -m0644 lib64/libGL.so.1 $(DESTDIR)$(LIBDIR)/glaze/lib64
+ mkdir -p $(DESTDIR)$(LIBDIR)/glaze/lib32
+ install -m0644 lib32/libGL.so.1 $(DESTDIR)$(LIBDIR)/glaze/lib32
+
clean:
rm -f $(TARGETS)
+
+# Get settings from the output of configure by running it to generate
+# Makefile.config if it doesn't exist yet.
+
+# If Makefile.config doesn't exist, then srcdir won't be
+# set. Conditionally set it (assuming a plain srcdir build) so that
+# the rule to generate Makefile.config can actually work.
+srcdir ?= .
+
+include Makefile.config
+Makefile.config: $(srcdir)/configure
+ifeq ($(configure_options),)
+ @echo ""
+ @echo "Note: Calling ./configure with no command-line arguments. This is often fine,"
+ @echo " but if you want to specify any arguments (such as an alternate prefix"
+ @echo " into which to install), call ./configure explicitly and then make again."
+ @echo " See \"./configure --help\" for more details."
+ @echo ""
+endif
+ $(srcdir)/configure $(configure_options)