unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Multiple Compiler Options
@ 2021-08-09 19:21 Erin Hodgess
  2021-08-09 20:36 ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 4+ messages in thread
From: Erin Hodgess @ 2021-08-09 19:21 UTC (permalink / raw)
  To: help-gnu-emacs

Hello:

I am using Emacs with Fortran to compile programs.

I use the following hooks:

(add-hook 'fortran-mode-hook
          (lambda ()
            (set (make-local-variable 'compile-command)
                 (concat "gfortran " buffer-file-name " && ./a.out"  ) )))



Is there a way to have different compile commands with different options, please?



Thank you,
Sincerely,
Erin



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Multiple Compiler Options
  2021-08-09 19:21 Multiple Compiler Options Erin Hodgess
@ 2021-08-09 20:36 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-08-09 20:54   ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 4+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-08-09 20:36 UTC (permalink / raw)
  To: help-gnu-emacs

Erin Hodgess wrote:

> I am using Emacs with Fortran to compile programs.
>
> I use the following hooks:
>
> (add-hook 'fortran-mode-hook
>           (lambda ()
>             (set (make-local-variable 'compile-command)
>                  (concat "gfortran " buffer-file-name " && ./a.out"  ) )))
>
> Is there a way to have different compile commands with
> different options, please?

Well, in general you can of course define any command
(interactive function) you'd like to run anything you want,
but here it is better to have a Makefile and then just have
`compile-command' "make -k " or something.

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Multiple Compiler Options
  2021-08-09 20:36 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-08-09 20:54   ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-08-09 20:59     ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 4+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-08-09 20:54 UTC (permalink / raw)
  To: help-gnu-emacs

> here it is better to have a Makefile and then just have
> compile-command' "make -k " or something.

Here is a Makefile for a Hello World example with gfortran and
Fortran 90.

Now compile from Emacs (from the hello.f90 buffer) with
M-x compile RET (I have that C-c C-c).

You can also compile from the shell with 'make', run it with
'make run', and remove the executable (not the source) with
'make clean'.

OK, the files, in hello.f90:

program hello
  print *, 'Hello, Erin!'
end program hello

And in Makefile:

name=hello
src=${name}.f90

exe=${name}

all: ${src}
   gfortran $< -o ${exe}

run: ${exe}
   $<

clean:
   rm ${exe}

--
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Multiple Compiler Options
  2021-08-09 20:54   ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-08-09 20:59     ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 4+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-08-09 20:59 UTC (permalink / raw)
  To: help-gnu-emacs

> OK, the files, in hello.f90:
>
> program hello
>   print *, 'Hello, Erin!'
> end program hello
>
> And in Makefile:
>
> name=hello
> src=${name}.f90
>
> exe=${name}
>
> all: ${src}
>    gfortran $< -o ${exe}
>
> run: ${exe}
>    $<
>
> clean:
>    rm ${exe}

Yes, that works, here are the files:

  https://dataswamp.org/~incal/fortran/hello.f90
  https://dataswamp.org/~incal/fortran/Makefile

Heh, not so difficult this Fortran stuff, ey? :)

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-08-09 20:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-09 19:21 Multiple Compiler Options Erin Hodgess
2021-08-09 20:36 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-09 20:54   ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-09 20:59     ` Emanuel Berg via Users list for the GNU Emacs text editor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).