Skip to content

Commit 896c422

Browse files
committed
Embed auto-detected version into haskell-mode.el and dist-target
The current version as inferred by `git describe` is embedded into `haskell-mode.elc` for in-place compiles and is statically embedded into the generated `.tar.gz` (which then does not depend on `git describe` anymore) by rewriting the distributed `Makefile` and `haskell-mode.el` files. This Makefile hack has been stolen from magit's [Makefile](https://github.com/magit/magit/blob/master/Makefile)
1 parent 8d3edf5 commit 896c422

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Makefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,27 @@ info: # No Texinfo file, sorry.
5353

5454
dist: $(TGZ)
5555

56-
$(AUTOLOADS): $(ELFILES)
56+
$(AUTOLOADS): $(ELFILES) haskell-mode.elc
5757
[ -f $@ ] || echo ' ' >$@
5858
$(BATCH) --eval '(setq generated-autoload-file "'`pwd`'/$@")' -f batch-update-autoloads "."
5959

60+
# embed version number into .elc file
61+
haskell-mode.elc: haskell-mode.el
62+
sed -e 's/\$$Name: \$$/$(VERSION)/g' < haskell-mode.el > haskell-mode.tmp.el #NO_DIST
63+
@$(BATCH) -f batch-byte-compile haskell-mode.tmp.el #NO_DIST
64+
mv haskell-mode.tmp.elc haskell-mode.elc #NO_DIST
65+
$(RM) haskell-mode.tmp.el #NO_DIST
66+
6067
$(TGZ): $(DIST_FILES)
6168
rm -rf haskell-mode-$(VERSION)
6269
mkdir haskell-mode-$(VERSION)
6370
cp -p $(DIST_FILES) haskell-mode-$(VERSION)
6471
mkdir haskell-mode-$(VERSION)/examples
6572
cp -p $(DIST_FILES_EX) haskell-mode-$(VERSION)/examples
73+
74+
printf "1s/=.*/= $(VERSION)/\nw\n" | ed -s haskell-mode-$(VERSION)/Makefile #NO_DIST
75+
printf "g/NO_DIST/d\nw\n" | ed -s haskell-mode-$(VERSION)/Makefile #NO_DIST
76+
printf ',s/\$$Name: \$$/$(VERSION)/\nw\n' | ed -s haskell-mode-$(VERSION)/haskell-mode.el #NO_DIST
77+
6678
tar cvzf $(TGZ) haskell-mode-$(VERSION)
6779
rm -rf haskell-mode-$(VERSION)

0 commit comments

Comments
 (0)