From 249c1310f7c55dd65735735c5c2984d7d0867e85 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mon, 27 Aug 2012 09:35:59 -0400 Subject: [PATCH] Add a configure script to implement GNOME Build API See http://people.gnome.org/~walters/docs/build-api.txt This also required modifying the install rule to honor DESTDIR. Signed-off-by: Adam Jackson --- Makefile | 20 +++++------------- configure | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 15 deletions(-) create mode 100644 configure diff --git a/Makefile b/Makefile index f661cd5..c8b203b 100644 --- a/Makefile +++ b/Makefile @@ -3,17 +3,7 @@ VERSION=$(shell awk '/Version:/ { print $$2 }' hwdata.spec) RELEASE=$(shell rpm -q --define 'dist %{nil}' --specfile --qf "%{release}" hwdata.spec) SOURCEDIR := $(shell pwd) -prefix=$(DESTDIR)/usr -sysconfdir=$(DESTDIR)/etc -bindir=$(prefix)/bin -sbindir=$(prefix)/sbin -datadir=$(prefix)/share -mandir=$(datadir)/man -includedir=$(prefix)/include -libdir=$(prefix)/lib - -CC=gcc -CFLAGS=$(RPM_OPT_FLAGS) -g +include Makefile.inc CVSROOT = $(shell cat CVS/Root 2>/dev/null || :) @@ -26,12 +16,12 @@ FILES = pci.ids usb.ids oui.txt pnp.ids all: install: - mkdir -p -m 755 $(datadir)/$(NAME) + mkdir -p -m 755 $(DESTDIR)$(datadir)/$(NAME) for foo in $(FILES) ; do \ - install -m 644 $$foo $(datadir)/$(NAME) ;\ + install -m 644 $$foo $(DESTDIR)$(datadir)/$(NAME) ;\ done - mkdir -p -m 755 $(sysconfdir)/modprobe.d - install -m 644 blacklist.conf $(sysconfdir)/modprobe.d + mkdir -p -m 755 $(DESTDIR)$(sysconfdir)/modprobe.d + install -m 644 blacklist.conf $(DESTDIR)$(sysconfdir)/modprobe.d commit: git commit -a ||: diff --git a/configure b/configure new file mode 100644 index 0000000..5f87c77 --- /dev/null +++ b/configure @@ -0,0 +1,63 @@ +#!/bin/bash +# -*- mode: sh -*- +# Minimal configure script which writes out a Makefile.inc +# Copyright 2010, 2011 Colin Walters +# Licensed under the new-BSD license (http://www.opensource.org/licenses/bsd-license.php) + +prefix=/usr + +# Little helper function for reading args from the commandline. +# it automatically handles -a b and -a=b variants, and returns 1 if +# we need to shift $3. +read_arg() { + # $1 = arg name + # $2 = arg value + # $3 = arg parameter + local rematch='^[^=]*=(.*)$' + if [[ $2 =~ $rematch ]]; then + read "$1" <<< "${BASH_REMATCH[1]}" + else + read "$1" <<< "$3" + # There is no way to shift our callers args, so + # return 1 to indicate they should do it instead. + return 1 + fi +} + +while (($# > 0)); do + case "${1%%=*}" in + --prefix) read_arg prefix "$@" || shift;; + --bindir) read_arg bindir "$@" || shift;; + --sbindir) read_arg sbindir "$@" || shift;; + --libexecdir) read_arg libexecdir "$@" || shift;; + --datarootdir) read_arg datarootdir "$@" || shift;; + --datadir) read_arg datadir "$@" || shift;; + --sysconfdir) read_arg sysconfdir "$@" || shift;; + --libdir) read_arg libdir "$@" || shift;; + --mandir) read_arg mandir "$@" || shift;; + *) echo "Ignoring unknown option '$1'";; + esac + shift +done + +# Handle srcdir != builddir +srcdir=$(dirname $0) +if ! test -f Makefile; then + ln -s ${srcdir}/Makefile Makefile +fi + +cat > Makefile.inc.tmp <