From 0b190cc8fbca0f970eadd8c0f1d5792c41f71cf6 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 12 Aug 2013 13:18:37 -0700 Subject: [PATCH] Add a configure script The primary motivation is a new install target. And it's just plain rude to provide an install target without also supporting --prefix and DESTDIR, so we need this simple configure script at least. --- .gitignore | 3 + Makefile | 40 +++++++- configure | 261 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 301 insertions(+), 3 deletions(-) create mode 100755 configure diff --git a/.gitignore b/.gitignore index 463ea60..52ed726 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ lib32 lib64 +libglaze.so* +Makefile.config +*~ diff --git a/Makefile b/Makefile index c9db5c8..3ccb7fa 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,18 @@ -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 $@ $< @@ -14,5 +21,32 @@ lib32/libGL.so.1: glaze-gl.c specs/gl.def 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) diff --git a/configure b/configure new file mode 100755 index 0000000..6195562 --- /dev/null +++ b/configure @@ -0,0 +1,261 @@ +#! /bin/sh + +PROJECT=glaze +PROJECT_BLURB="a shiny way to wrap OpenGL" + +srcdir=$(dirname "$0") + +# For a non-srcdir configure invocation (such as ../configure), create +# the directory structure and copy Makefiles. +if [ "$srcdir" != "." ]; then + + for dir in . $(grep "^subdirs *=" "$srcdir"/Makefile | sed -e "s/subdirs *= *//"); do + mkdir -p "$dir" + cp "$srcdir"/"$dir"/Makefile.local "$dir" + cp "$srcdir"/"$dir"/Makefile "$dir" + done +fi + +# Set several defaults (optionally specified by the user in +# environment variables) +CC=${CC:-gcc} +CFLAGS=${CFLAGS:--O2} +LDFLAGS=${LDFLAGS:-} + +# Set the defaults for values the user can specify with command-line +# options. +PREFIX=/usr/local + +usage () +{ + cat <-- Currently ignored + --host=-- Currently ignored + --infodir=DIR Currently ignored + --datadir=DIR Currently ignored + --localstatedir=DIR Currently ignored + --libexecdir=DIR Currently ignored + --disable-maintainer-mode Currently ignored + --disable-dependency-tracking Currently ignored + +EOF +} + +# Parse command-line options +for option; do + if [ "${option}" = '--help' ] ; then + usage + exit 0 + elif [ "${option%%=*}" = '--prefix' ] ; then + PREFIX="${option#*=}" + elif [ "${option%%=*}" = '--bindir' ] ; then + BINDIR="${option#*=}" + elif [ "${option%%=*}" = '--libdir' ] ; then + LIBDIR="${option#*=}" + elif [ "${option%%=*}" = '--mandir' ] ; then + MANDIR="${option#*=}" + elif [ "${option%%=*}" = '--sysconfdir' ] ; then + SYSCONFDIR="${option#*=}" + elif [ "${option%%=*}" = '--build' ] ; then + true + elif [ "${option%%=*}" = '--host' ] ; then + true + elif [ "${option%%=*}" = '--infodir' ] ; then + true + elif [ "${option%%=*}" = '--datadir' ] ; then + true + elif [ "${option%%=*}" = '--localstatedir' ] ; then + true + elif [ "${option%%=*}" = '--libexecdir' ] ; then + true + elif [ "${option}" = '--disable-maintainer-mode' ] ; then + true + elif [ "${option}" = '--disable-dependency-tracking' ] ; then + true + else + echo "Unrecognized option: ${option}" + echo "See:" + echo " $0 --help" + echo "" + exit 1 + fi +done + +printf "Checking for working C compiler (${CC})... " +printf "int main(void){return 42;}\n" > minimal.c +if ${CC} -o minimal minimal.c > /dev/null 2>&1 +then + printf "Yes.\n" +else + printf "No.\n" + cat < /dev/null 2>&1 + then + WARN_CFLAGS="${WARN_CFLAGS}${WARN_CFLAGS:+ }${flag}" + fi +done +printf "\t${WARN_CFLAGS}\n" + +rm -f minimal minimal.c + +printf "#include \nint main(void){return 0;}\n" > arch-minimal.c + +printf "Checking for machine-dependent compiler support:\n" + +printf " Compiler can create 32-bit binaries... " +have_m32=Yes +if ${CC} -m32 -o arch-minimal arch-minimal.c > /dev/null 2>&1 +then + printf "Yes.\n" +else + printf "No.\n" + have_m32=No +fi + +printf " Compiler can create 64-bit binaries... " +have_m64=Yes +if ${CC} -m64 -o arch-minimal arch-minimal.c > /dev/null 2>&1 +then + printf "Yes.\n" +else + printf "No.\n" + have_m64=No +fi + +if [ "$have_m32" = "No" ] || [ "$have_m64" = "No" ]; then + cat < Makefile.config <