1*ebfedea0SLionel Sambuc 2*ebfedea0SLionel Sambuc 3*ebfedea0SLionel Sambuc(defun generate-obj-macro (mname &optional postfix &rest slist) 4*ebfedea0SLionel Sambuc "Generates a macro definition for an OBJs dependency based on a list of source definitions" 5*ebfedea0SLionel Sambuc 6*ebfedea0SLionel Sambuc (let* 7*ebfedea0SLionel Sambuc ((replist (apply 'append (mapcar (lambda (sdef) 8*ebfedea0SLionel Sambuc (goto-char 0) 9*ebfedea0SLionel Sambuc (let* 10*ebfedea0SLionel Sambuc ((def (buffer-substring-no-properties 11*ebfedea0SLionel Sambuc (search-forward (concat sdef " = \\\n") nil t) 12*ebfedea0SLionel Sambuc (search-forward "\n\n" nil t))) 13*ebfedea0SLionel Sambuc (st (split-string 14*ebfedea0SLionel Sambuc (replace-regexp-in-string "^.*\\.h.*\n" "" def) 15*ebfedea0SLionel Sambuc "\\s-+\\\\?\\|\n" t))) 16*ebfedea0SLionel Sambuc st)) slist))) 17*ebfedea0SLionel Sambuc (def-start (search-forward (concat mname " = \\\n") nil t)) 18*ebfedea0SLionel Sambuc (def-end (search-forward "\n\n" nil t)) 19*ebfedea0SLionel Sambuc 20*ebfedea0SLionel Sambuc (repl (mapconcat 21*ebfedea0SLionel Sambuc (lambda (s) 22*ebfedea0SLionel Sambuc (concat "\t" 23*ebfedea0SLionel Sambuc (replace-regexp-in-string 24*ebfedea0SLionel Sambuc "\\(\\s-*\\)\\(.*\\)\\.c" "\\1$(OBJ)\\\\\\2.obj" s) 25*ebfedea0SLionel Sambuc " \\")) 26*ebfedea0SLionel Sambuc replist "\n")) 27*ebfedea0SLionel Sambuc (erepl (if postfix 28*ebfedea0SLionel Sambuc (concat repl "\n" postfix "\n\n") 29*ebfedea0SLionel Sambuc (concat repl "\n\n"))) 30*ebfedea0SLionel Sambuc ) 31*ebfedea0SLionel Sambuc (delete-region def-start def-end) 32*ebfedea0SLionel Sambuc (insert erepl)) 33*ebfedea0SLionel Sambuc ) 34*ebfedea0SLionel Sambuc 35