mescc: Use file-name as global prefix.
[mes.git] / scripts / mescc
index bc324ad845ca96c23d75af9834d6c08d8d98bcba..b37de93fc2d9a0919b14ee7886ffc61377028dc5 100755 (executable)
@@ -167,6 +167,7 @@ Environment variables:
   (let* ((options (parse-opts args))
          (files (option-ref options '() '()))
          (file (car files))
+         (file-name (car (string-split (basename file) #\.)))
          (preprocess? (option-ref options 'E #f))
          (compile? (option-ref options 'c #f))
          (debug-info? (option-ref options 'g #f))
@@ -192,17 +193,17 @@ Environment variables:
         (if (and (not compile?)
                  (not preprocess?)) (set-port-encoding! (current-output-port) "ISO-8859-1"))
         (cond ((pair? objects) (let ((objects (map read-object objects)))
-                                 (if compile? (objects->M1 objects)
-                                     (objects->elf objects))))
+                                 (if compile? (objects->M1 file-name objects)
+                                     (objects->elf file objects))))
               ((pair? asts) (let* ((infos (map main:ast->info asts))
                                    (objects (map info->object infos)))
-                              (if compile? (objects->M1 objects)
-                                  (objects->elf objects))))
+                              (if compile? (objects->M1 file-name objects)
+                                  (objects->elf file objects))))
               ((pair? sources) (if preprocess? (map (source->ast pretty-print/write defines includes) sources)
                                    (let* ((infos (map (source->info defines includes) sources))
                                           (objects (map info->object infos)))
-                                     (if compile? (objects->M1 objects)
-                                         (objects->elf objects))))))))))
+                                     (if compile? (objects->M1 file-name objects)
+                                         (objects->elf file objects))))))))))
 
 (main (command-line))
 'done