1 ;;; org-fixup.el --- make life easier for folks without GNU make
5 ;; Homepage: http://orgmode.org
7 ;; This file is not part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 3, or (at your option)
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 ;; Boston, MA 02110-1301, USA.
23 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
28 (require 'org-compat
"org-compat.el")
30 (defun org-make-org-version (org-release org-git-version
)
31 "Make the file org-version.el in the current directory.
32 This function is internally used by the build system and should
33 be used by foreign build systems or installers to produce this
34 file in the installation directory of org-mode. Org will not
35 work correctly if this file is not present (except directly from
39 ;;; org-version.el --- autogenerated file, do not edit
43 \(defun org-release ()
44 \"The release version of org-mode.
45 Inserted by installing org-mode or when a release is made.\"
46 (let ((org-release \"" org-release
"\"))
49 \(defun org-git-version ()
50 \"The Git version of org-mode.
51 Inserted by installing org-mode or when a release is made.\"
52 (let ((org-git-version \"" org-git-version
"\"))
54 \f\n\(provide 'org-version\)
55 \f\n;; Local Variables:\n;; version-control: never
57 ;; coding: utf-8\n;; End:\n;;; org-version.el ends here\n")
59 (write-file "org-version.el")))
61 (defun org-make-org-loaddefs ()
62 "Make the file org-loaddefs.el in the current directory.
63 This function is internally used by the build system and should
64 be used by foreign build systems or installers to produce this
65 file in the installation directory of org-mode. Org will not
66 work correctly if this file is not up-to-date."
68 (set-visited-file-name "org-loaddefs.el")
69 (insert ";;; org-loaddefs.el --- autogenerated file, do not edit\n;;\n;;; Code:\n")
70 (let ((files (directory-files default-directory nil
"^\\(org\\|ob\\)\\(-.*\\)?\\.el$")))
71 (mapc (lambda (f) (generate-file-autoloads f
)) files
))
72 (insert "\f\n(provide 'org-loaddefs)\n")
73 (insert "\f\n;; Local Variables:\n;; version-control: never\n")
74 (insert ";; no-byte-compile: t\n;; no-update-autoloads: t\n")
75 (insert ";; coding: utf-8\n;; End:\n;;; org-loaddefs.el ends here\n")
79 (defun org-make-autoloads (&optional compile force
)
80 "Make the files org-loaddefs.el and org-version.el in the install directory.
81 Finds the install directory by looking for library \"org\".
82 Optionally byte-compile lisp files in the install directory or
83 force re-compilation. This function is provided for easier
84 manual install when the build system can't be used."
85 (let* ((origin default-directory
)
86 (dirlisp (org-find-library-dir "org"))
87 (dirorg (concat dirlisp
"../" )))
92 (org-make-org-version (org-release) (org-git-version))
93 (org-make-org-loaddefs)
94 (when compile
(byte-recompile-directory dirlisp
0 force
)))
97 (defun org-make-autoloads-compile ()
98 "Call org-make-autoloads with compile argument.
99 Convenience function for easier invocation from command line."
100 (org-make-autoloads 'compile nil
))
102 (defun org-make-autoloads-compile-force ()
103 "Call org-make-autoloads with compile force arguments.
104 Convenience function for easier invocation from command line."
105 (org-make-autoloads 'compile
'force
))
107 ;; Internal functions
109 (defun org-make-local-mk ()
110 "Internal function for the build system."
111 (let ((default "mk/default.mk")
115 (insert-file-contents default
)
116 (goto-char (point-min))
117 (when (search-forward "-8<-" nil t
)
119 (delete-region (point-min) (point)))
120 (when (search-forward "->8-" nil t
)
122 (delete-region (point) (point-max)))
123 (goto-char (point-min))
125 # Remove \"oldorg:\" to switch to \"all\" as the default target.
126 # Change \"oldorg:\" to an existing target to make that target the default,
127 # or define your own target here to become the default target.
128 oldorg: # do what the old Makefile did by default.
130 ##----------------------------------------------------------------------
132 (goto-char (point-max))
134 # See default.mk for further configuration options.
140 (defun org-make-letterformat (a4name lettername
)
141 "Internal function for the build system."
144 (insert-file-contents a4name
)
145 (goto-char (point-min))
146 (while (search-forward "\\pdflayout=(0l)" nil t
)
147 (replace-match "\\pdflayout=(1l)" nil t
))
149 (write-file lettername
))
152 ;; redefine version functions
154 (defmacro org-fixup
()
155 (let* ((origin default-directory
)
156 (dirlisp (org-find-library-dir "org"))
157 (dirorg (concat dirlisp
"../" ))
158 (dirgit (concat dirorg
".git/" ))
159 (org-version "N/A-fixup")
160 (org-git-version "N/A-fixup !!check installation!!"))
161 (if (and (boundp 'org-fake-release
) (stringp org-fake-release
)
162 (boundp 'org-fake-git-version
) (stringp org-fake-git-version
))
163 (setq org-version org-fake-release
164 org-git-version org-fake-git-version
)
165 (if (load (concat dirlisp
"org-version.el") 'noerror
'nomessage
'nosuffix
)
166 (setq org-version
(org-release)
167 org-git-version
(org-git-version))
168 (when (and (file-exists-p dirgit
)
169 (executable-find "git"))
173 (let ((git6 (substring (shell-command-to-string "git describe --abbrev=6 HEAD") 0 -
1))
174 (git0 (substring (shell-command-to-string "git describe --abbrev=0 HEAD") 0 -
1))
175 (gitd (string-match "\\S-"
176 (shell-command-to-string "git status -uno --porcelain"))))
177 (setq org-git-version
(concat git6
(when gitd
".dirty") "-git"))
178 (if (string-match "^release_" git0
)
179 (setq org-version
(substring git0
8))
180 (setq org-version git0
))))
182 (message "org-fixup.el: redefined Org version")
184 (defun org-release () ,org-version
)
185 (defun org-git-version () ,org-git-version
))))
190 ;; no-byte-compile: t
193 ;;; org-fixup.el ends here