Commits

Alex Hixon committed f490f8f

Patch by Willem van Engen making rules obey the PREFIX and added some Makefile comments.

Small enhancements for the rule building

* make rules file obey PREFIX
* add comments to rules generation in Makefile
* remove reference to debian rules in rules file

the indirect sed command using REPL_LOADER could use some improvement, but you'll know to break something when including strange characters like \ and $ into filenames.

Comments (0)

Files changed (2)

 	rm -rfv $(INSTALL_PATH)$(libdir)/r5u87x
 
 $(RULESFILE):
-	cat $(RULESFILE).in | awk 'BEGIN{P=1;}/^###BEGINTEMPLATE###/{P=0;} {if (P) print;}' | grep -v '^###' >$@
+	# extract preamble from template
+	cat $(RULESFILE).in | \
+		awk 'BEGIN{P=1;}/^###BEGINTEMPLATE###/{P=0;} {if (P) print;}' \
+		| grep -v '^###' >$@
+	# process template for each firmware file
+	# loader is part of regexp REPL_LOADER has escaped slashes (to work for simple paths)
 	for sedline in `ls ucode | sed 's/^r5u87x-\([0-9a-zA-Z]\+\)-\([0-9a-zA-Z]\+\)\.fw$$/s\/#VENDORID#\/\1\/g;s\/#PRODUCTID#\/\2\/g/p;d'`; do \
-		cat $(RULESFILE).in | awk 'BEGIN{P=0;}/^###BEGINTEMPLATE###/{P=1;}/^###ENDTEMPLATE###/{P=0;} {if (P) print;}' | grep -v '^###' | sed "$$sedline" >>$@; \
+		REPL_LOADER=$$(echo "$(PREFIX)$(sbindir)/$(LOADER_INSTALL)" | sed 's/\//\\\//g'); \
+		cat $(RULESFILE).in | \
+			awk 'BEGIN{P=0;}/^###BEGINTEMPLATE###/{P=1;}/^###ENDTEMPLATE###/{P=0;} {if (P) print;}' | \
+			grep -v '^###' | \
+			sed -e "$$sedline" \
+			    -e "s/#LOADER#/$$REPL_LOADER/g" >>$@; \
 		done >>$@
-	cat $(RULESFILE).in | awk 'BEGIN{P=0;}/^###ENDTEMPLATE###/{P=1;} {if (P) print;}' | grep -v '^###' >>$@
+	# extract postscript from template
+	cat $(RULESFILE).in | \
+		awk 'BEGIN{P=0;}/^###ENDTEMPLATE###/{P=1;} {if (P) print;}' \
+		| grep -v '^###' >>$@
 
 rules: $(RULESFILE)

contrib/90-r5u87x-loader.rules.in

-# r5u87x-loader.rules - udev rules for loading firmware into Ricoh R5U87x USB video devices
+# 90-r5u87x-loader.rules - udev rules for loading firmware into Ricoh R5U87x USB video devices
 ###
-### This file is processed by the debian rules to create the final file. Each
+### This file is processed by the Makefile to create the final file. Each
 ### USB id gets its own line as defined by the section between BEGINTEMPLATE
-### and ENDTEMPLATE. In the template, the strings #VENDORID# and #PRODUCTID#
-### are replaced by their values. This template line is repeated for each
-### USB for which there is a file in the directory ucode/.
+### and ENDTEMPLATE. In the template, the strings #VENDORID#, #PRODUCTID# and
+### #LOADER# are replaced by their values. This template line is repeated for
+### each file in the directory ucode/ with a USB id.
 ###
 ### Lines starting with three hashes are removed from this file.
 ###
 SUBSYSTEM!="usb", GOTO="r5u87x_rules_end"
 
 ###BEGINTEMPLATE###
-SYSFS{idVendor}=="#VENDORID#", SYSFS{idProduct}=="#PRODUCTID#", RUN+="/usr/sbin/r5u87x-loader --reload"
+SYSFS{idVendor}=="#VENDORID#", SYSFS{idProduct}=="#PRODUCTID#", RUN+="#LOADER# --reload"
 ###ENDTEMPLATE###
 
 LABEL="r5u87x_rules_end"