diff options
author | Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> | 2016-11-27 17:45:49 +0100 |
---|---|---|
committer | David Hendricks <david.hendricks@gmail.com> | 2017-06-23 06:08:36 +0000 |
commit | 7634708c98a6fa439443e0791dd62563f4baf746 (patch) | |
tree | ab92caf9995bf2819ef31a8b4245a13c386027f9 /Makefile | |
parent | 8624e8cfa88ebd17ecf3bfd55c8dc1a799f47573 (diff) | |
download | flashrom-7634708c98a6fa439443e0791dd62563f4baf746.tar.gz flashrom-7634708c98a6fa439443e0791dd62563f4baf746.tar.bz2 flashrom-7634708c98a6fa439443e0791dd62563f4baf746.zip |
Convert flashrom to git
- Drop support for Subversion in the getrevision script and Makefile.
- Add .gitignore and .gitattributes file (the latter to limit exports).
- Restore modification dates of the exported files from the SCM.
- Stop exporting SCM log dumps to CHANGELOG. This makes no sense.
- Do not export the pre-"compiled" manpage. It can be generated like
anything else from the code dump when we export the respective
variable.
The latter is added with this change.
- Add some initial client-side git hooks
* When committing check for obvious stuff you never want anyway:
- white space errors
* When pushing to the upstream repository check mandatory rules:
- existing signoffs and acks in all new commits
- no deletions or creation of branches
- do not rewrite history of the precious branches, even if forced
NOTE: This patch is adapted from Stefan Tauner's original commit:
https://mail.coreboot.org/pipermail/flashrom/2016-November/014877.html
There are a few major differences:
- This uses coreboot's commit-msg hook which includes support for
generating and appending Change-Id.
- djgpp-dos target removal is moved to a follow-up patch.
- Version string changes are moved to a follow-up patch.
Change-Id: I64eef21982cac0a0a7419bcd2c8a936672ae9cb2
Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Signed-off-by: David Hendricks <dhendricks@fb.com>
Reviewed-on: https://review.coreboot.org/19206
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 88 |
1 files changed, 59 insertions, 29 deletions
@@ -526,23 +526,36 @@ LIB_OBJS = libflashrom.o layout.o flashrom.o udelay.o programmer.o helpers.o ich CLI_OBJS = cli_classic.o cli_output.o cli_common.o print.o -# Set the flashrom version string from the highest revision number of the checked out flashrom files. -# Note to packagers: Any tree exported with "make export" or "make tarball" -# will not require subversion. The downloadable snapshots are already exported. -SVNVERSION := $(shell ./util/getrevision.sh -u 2>/dev/null ) +# Makefile.version is used when packaging flashrom and is generated by the +# export rule. If Makefile.version is not found, version info will be obtained +# using util/getrevision.sh or "unknown" if SCM metadata directory isn't found. +ifeq ($(wildcard Makefile.version),) +ifeq ($(wildcard .git),) +VERSION ?= unknown +MAN_DATE ?= unknown +else +VERSION ?= $(shell ./util/getrevision.sh --local) +MAN_DATE ?= $(shell ./util/getrevision.sh -d $(PROGRAM).8.tmpl 2>/dev/null) +# This is also a convenient time to install hooks. +$(shell ./util/git-hooks/install.sh) +endif +else +include Makefile.version +endif -RELEASE := 0.9.9 -VERSION := $(RELEASE)-$(SVNVERSION) -RELEASENAME ?= $(VERSION) +# VERSION equals "offline" if online access is required but the respective git +# config variable is not set yet. +ifeq ($(VERSION),offline) + $(error Aborting) +endif + +SCMDEF := -D'FLASHROM_VERSION="$(VERSION)"' -SVNDEF := -D'FLASHROM_VERSION="$(VERSION)"' +# No spaces in release names unless set explicitly +RELEASENAME ?= $(shell echo "$(VERSION)" | sed -e 's/ /_/') -# Inform user if there is no meaningful version string. If there is version information from a VCS print -# something anyway because $(info...) will print a line break in any case which would look suspicious. -# The && between the echos is a workaround for old versions of GNU make that issue the error "unterminated -# variable reference" if a semicolon is used instead. -$(info $(shell ./util/getrevision.sh -c 2>/dev/null || echo "Files don't seem to be under version control." && \ - echo "Replacing all version templates with $(VERSION)." )) +# Inform user of the version string +$(info Replacing all version templates with $(VERSION).) ############################################################################### # Default settings of CONFIG_* variables. @@ -1027,7 +1040,7 @@ libflashrom.a: $(LIBFLASHROM_OBJS) TAROPTIONS = $(shell LC_ALL=C tar --version|grep -q GNU && echo "--owner=root --group=root") %.o: %.c .features - $(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) $(FEATURE_CFLAGS) $(SVNDEF) -o $@ -c $< + $(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) $(FEATURE_CFLAGS) $(SCMDEF) -o $@ -c $< # Make sure to add all names of generated binaries here. # This includes all frontends and libflashrom. @@ -1371,7 +1384,7 @@ $(PROGRAM).8.html: $(PROGRAM).8 $(PROGRAM).8: $(PROGRAM).8.tmpl @# Add the man page change date and version to the man page - @sed -e 's#.TH FLASHROM 8 ".*".*#.TH FLASHROM 8 "$(shell ./util/getrevision.sh -d $(PROGRAM).8.tmpl 2>/dev/null)" "$(VERSION)"#' <$< >$@ + @sed -e 's#.TH FLASHROM 8 ".*".*#.TH FLASHROM 8 "$(MAN_DATE)" "$(VERSION)"#' <$< >$@ install: $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8 mkdir -p $(DESTDIR)$(PREFIX)/sbin @@ -1385,25 +1398,42 @@ libinstall: libflashrom.a libflashrom.h mkdir -p $(DESTDIR)$(PREFIX)/include $(INSTALL) -m 0644 libflashrom.h $(DESTDIR)$(PREFIX)/include -export: $(PROGRAM).8 - @rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME) - @svn export -r BASE . $(EXPORTDIR)/flashrom-$(RELEASENAME) - @sed "s/^SVNVERSION.*/SVNVERSION := $(SVNVERSION)/" Makefile >$(EXPORTDIR)/flashrom-$(RELEASENAME)/Makefile - @cp $(PROGRAM).8 "$(EXPORTDIR)/flashrom-$(RELEASENAME)/$(PROGRAM).8" - @svn log >$(EXPORTDIR)/flashrom-$(RELEASENAME)/ChangeLog - @echo Exported $(EXPORTDIR)/flashrom-$(RELEASENAME)/ - -tarball: export - @tar cjf $(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2 -C $(EXPORTDIR)/ $(TAROPTIONS) flashrom-$(RELEASENAME)/ - @rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME) - @echo Created $(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2 +_export: $(PROGRAM).8 + @rm -rf "$(EXPORTDIR)/flashrom-$(RELEASENAME)" + @mkdir -p "$(EXPORTDIR)/flashrom-$(RELEASENAME)" + @git archive HEAD | tar -x -C "$(EXPORTDIR)/flashrom-$(RELEASENAME)" +# Generate Makefile.version since SCM metadata won't be available in +# exported sources. + @echo "VERSION = $(VERSION)" > "$(EXPORTDIR)/flashrom-$(RELEASENAME)/Makefile.version" + @echo "MAN_DATE = $(MAN_DATE)" >> "$(EXPORTDIR)/flashrom-$(RELEASENAME)/Makefile.version" +# Restore modification date of all tracked files not marked +# 'export-ignore' in .gitattributes. sed is required to filter out file +# names having the attribute set. + @git ls-tree -r -z -t --full-name --name-only HEAD | \ + git check-attr -z --stdin export-ignore | \ + sed -zne 'x;n;n;/^set$$/{b};x;p' | \ + xargs -0 sh -c 'for f; do \ + touch -d $$(git log --pretty=format:%cI -1 HEAD -- "$$f") \ + "$(EXPORTDIR)/flashrom-$(RELEASENAME)/$$f"; \ + done' + +export: _export + @echo "Exported $(EXPORTDIR)/flashrom-$(RELEASENAME)/" + +tarball: _export + @tar -cz --format=ustar -f "$(EXPORTDIR)/flashrom-$(RELEASENAME).tar.gz" \ + -C "$(EXPORTDIR)/$(TAROPTIONS)" "flashrom-$(RELEASENAME)/" +# Delete the exported directory again because it is most likely what's expected by the user. + @rm -rf "$(EXPORTDIR)/flashrom-$(RELEASENAME)" + @echo Created "$(EXPORTDIR)/flashrom-$(RELEASENAME).tar.gz" djgpp-dos: clean make CC=i586-pc-msdosdjgpp-gcc STRIP=i586-pc-msdosdjgpp-strip + libpayload: clean make CC="CC=i386-elf-gcc lpgcc" AR=i386-elf-ar RANLIB=i386-elf-ranlib -.PHONY: all install clean distclean compiler hwlibs features export tarball djgpp-dos featuresavailable libpayload +.PHONY: all install clean distclean compiler hwlibs features _export export tarball featuresavailable libpayload # Disable implicit suffixes and built-in rules (for performance and profit) .SUFFIXES: |