Makefile 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. # Makefile
  2. # Copyright (C) 2016 Alex Kost <alezost@gmail.com>
  3. # This program is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation, either version 3 of the License, or
  6. # (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. # Commentary:
  16. # This file is used to byte-compile various *.el files of my Emacs
  17. # config so that I can see and fix compilation warnings.
  18. # Code:
  19. EMACS = emacs
  20. MY_INIT_DIR = $(CURDIR)/init
  21. MY_UTILS_DIR = $(CURDIR)/utils
  22. MY_ELPA_DIR = $(CURDIR)/packages
  23. EMACS_ELPA_DIR = $(CURDIR)/data/elpa
  24. GUIX_DIR = $(HOME)/.guix-profiles/emacs/emacs/share/emacs/site-lisp
  25. GUIX_ELPA_DIR = $(GUIX_DIR)/guix.d
  26. L_dirs = $(shell test -d $(1) && \
  27. find -L $(1) -mindepth 1 -maxdepth 1 -type d \
  28. -exec echo -L {} \;)
  29. LOAD_PATH = \
  30. -L $(MY_UTILS_DIR) \
  31. -L $(GUIX_DIR) \
  32. $(call L_dirs,$(MY_ELPA_DIR)) \
  33. $(call L_dirs,$(GUIX_ELPA_DIR)) \
  34. $(call L_dirs,$(EMACS_ELPA_DIR))
  35. EMACS_BATCH = $(EMACS) -batch -Q $(LOAD_PATH)
  36. UTILS_ELS = $(shell find -L $(MY_UTILS_DIR) -maxdepth 1 -name 'al-*el')
  37. UTILS_ELCS = $(UTILS_ELS:.el=.elc)
  38. # "init.el" and "keys.el" should be compiled first.
  39. INIT_ELS = \
  40. $(MY_INIT_DIR)/init.el \
  41. $(MY_INIT_DIR)/keys.el \
  42. $(shell find -L $(MY_INIT_DIR) -maxdepth 1 -name '*el' \
  43. ! -name 'init.el' ! -name 'keys.el')
  44. INIT_ELCS = $(INIT_ELS:.el=.elc)
  45. all: $(UTILS_ELCS)
  46. %.elc: %.el
  47. @printf "Compiling $<\n"
  48. -@$(EMACS_BATCH) --eval "(setq load-prefer-newer t)" \
  49. -f batch-byte-compile $< ;
  50. # This target is not very useful actually: compiling init files brings
  51. # tons of garbage warnings because 'with-eval-after-load' wraps lambda
  52. # in 'eval-after-load', so almost everything inside it is unknown (as it
  53. # is used to set up a foreign package) and produces a warning.
  54. init: $(INIT_ELS)
  55. @printf "Compiling init files\n"
  56. @$(EMACS_BATCH) -f batch-byte-compile $^ ;
  57. clean-utils:
  58. @printf "Removing utils/*.elc...\n"
  59. $(RM) $(UTILS_ELCS)
  60. clean-init:
  61. @printf "Removing init/*.elc...\n"
  62. $(RM) $(INIT_ELCS)
  63. clean: clean-utils clean-init
  64. .PHONY: all init clean clean-utils clean-init
  65. # Makefile ends here