; Convert a makefile, assumed to be in the current buffer, to a DOS bat file. ; The current buffer will be saved when done, which assumes that the file name ; is something appropriate, e.g., make.bat instead of Makefile. ; (setq case-fold-search nil) ; Change mention of "Makefile" in the comment, if any. (replace-string "# Makefile for" "# DOS batch file for") (beginning-of-buffer) ; Add the line "@echo off" to the top of the file. (insert "@echo off\n\n") (beginning-of-buffer) ; Change all "#" comment characters on the start of a line to "REM". (replace-string "#" "REM") ; For each variable assignment command (lines containing "="): ; ; -- Remove all space and tab characters around the "=" operators. ; -- Add the command "set" at the beginning of the line. (beginning-of-buffer) (while (search-forward-regexp "[ ]*=[ ]*" nil t) (delete-whitespace) (backward-char 1) (delete-whitespace) (beginning-of-line) (insert "set ") (next-line 1) (beginning-of-line) ) (beginning-of-buffer) ; Change all "/" characters in file paths to "\\". (replace-string "/" "\\") ; Change any absolute UNIX paths of the form /users/gfisher/... to an ; appropriate path on the computer where the batch file will be run. (replace-string "\\users\\" "d:\\") (beginning-of-buffer) ; Change all make commands of the form: ; commandname: ; command1; \\ ; command2; \\ ; \&... ; to a DOS command sequence of the form ; command1 ; command2 ; \&... (replace-regexp "^[a-z0-9_]*:.*\n" "") (beginning-of-buffer) (while (search-forward "; \\\n" nil t) (backward-char 1) (backward-delete-char 3) (beginning-of-line) (delete-whitespace) ) (beginning-of-buffer) ; Change all (remaining) multi-line commands to single lines. A multi-line ; command is one where continuation lines end in a backslash character. (while (search-forward "\\\n" nil t) (delete-whitespace) (backward-delete-char 2) ) (beginning-of-buffer) ; Change all variable references of the form $(VARNAME) to %VARNAME%. (replace-regexp "$(\\([A-Z0-9_]*\\))" "%\\1%") (beginning-of-buffer) ; Run the following UNIX shell command on waldorf: ; ~gfisher/classes/206/lib/add-ctrl-ms.csh make.bat ; where the command-line argument "\fCmake.bat\fP" is the file you just ; converted. This will convert UNIX-style the end-of-line characters to ; DOS-style. (load-file "~/work/support/administration/.add-ctrl-ms.el") (save-buffer)