Browse Source

makefile improvements

Using $(libdir) variable instead of $(prefix)/lib. This helps maintain
consistency between paths used in Makefile and those provided by the
build system used in spec (e.g. %_libdir).

Make sure that Makefile.inc is created before its inclusion in Makefile.
Since Makefile is already build, it's not quite obvious that configure
script needs to be run for Makefile.inc to be generated.

Fixed configure script to correctly generate datadir variable.
Łukasz Stelmach 10 years ago
parent
commit
6771fd4406
3 changed files with 14 additions and 8 deletions
  1. 11 6
      Makefile
  2. 2 1
      configure
  3. 1 1
      hwdata.spec

+ 11 - 6
Makefile

@@ -3,8 +3,6 @@ VERSION=$(shell awk '/Version:/ { print $$2 }' hwdata.spec)
 RELEASE=$(shell rpm -q --define 'dist %{nil}' --specfile --qf "%{release}" hwdata.spec)
 SOURCEDIR := $(shell pwd)
 
-include Makefile.inc
-
 CVSROOT = $(shell cat CVS/Root 2>/dev/null || :)
 
 CVSTAG = $(NAME)-r$(subst .,-,$(VERSION))
@@ -14,15 +12,22 @@ FILES = pci.ids usb.ids oui.txt pnp.ids
 .PHONY: all install tag force-tag check commit create-archive archive srpm-x \
     clean clog new-pci-ids new-usb-ids new-pnp-ids
 
-all: 
+include Makefile.inc
+
+all:
+
+Makefile.inc: configure
+	./configure
+	@echo "$@ generated. Run the make again."
+	@exit 1
 
-install:
+install: Makefile.inc
 	mkdir -p -m 755 $(DESTDIR)$(datadir)/$(NAME)
 	for foo in $(FILES) ; do \
 		install -m 644 $$foo $(DESTDIR)$(datadir)/$(NAME) ;\
 	done
-	mkdir -p -m 755 $(DESTDIR)$(prefix)/lib/modprobe.d
-	install -m 644 -T blacklist.conf $(DESTDIR)$(prefix)/lib/modprobe.d/dist-blacklist.conf
+	mkdir -p -m 755 $(DESTDIR)$(libdir)/modprobe.d
+	install -m 644 -T blacklist.conf $(DESTDIR)$(libdir)/modprobe.d/dist-blacklist.conf
 
 commit:
 	git commit -a ||:

+ 2 - 1
configure

@@ -5,6 +5,7 @@
 # Licensed under the new-BSD license (http://www.opensource.org/licenses/bsd-license.php)
 
 prefix=/usr
+datarootdir=${datarootdir:-${prefix}/share}
 
 # Little helper function for reading args from the commandline.
 # it automatically handles -a b and -a=b variants, and returns 1 if
@@ -53,7 +54,7 @@ prefix ?= ${prefix}
 bindir ?= ${bindir:-${prefix}/bin}
 sbindir ?= ${sbindir:-${prefix}/sbin}
 libexecdir ?= ${libexecdir:-${prefix}/libexec}
-datarootdir ?= ${datarootdir:-${prefix}/share}
+datarootdir ?= ${datarootdir}
 datadir ?= ${datadir:-${datarootdir}}
 sysconfdir ?= ${sysconfdir:-${prefix}/etc}
 libdir ?= ${libdir:-${prefix}/lib}

+ 1 - 1
hwdata.spec

@@ -21,7 +21,7 @@ such as the pci.ids and usb.ids databases.
 
 %install
 rm -rf $RPM_BUILD_ROOT
-make install DESTDIR=$RPM_BUILD_ROOT
+make install DESTDIR=$RPM_BUILD_ROOT libdir=%{_prefix}/lib
 
 %clean
 rm -rf $RPM_BUILD_ROOT