From: Mike Mattie <codermattie@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: help with makefile command line
Date: Tue, 25 Mar 2008 21:57:13 -0700 [thread overview]
Message-ID: <20080325215713.1c99642a@reforged> (raw)
In-Reply-To: <20080325214220.38405b4a@reforged>
[-- Attachment #1: Type: text/plain, Size: 2868 bytes --]
On Tue, 25 Mar 2008 21:42:20 -0700
Mike Mattie <codermattie@gmail.com> wrote:
> On Wed, 26 Mar 2008 06:19:17 +0200
> Eli Zaretskii <eliz@gnu.org> wrote:
>
> > > From: "Balaji V. Iyer" <bviyer@ncsu.edu>
> > > Date: Tue, 25 Mar 2008 09:09:56 -0400
> > >
> > > I use the compile option extenstively in emacs. When I type
> > > "M-x compile" the default line is "make -k" Many times I do not
> > > have a make file
> >
> > You don't need a Makefile to perform simple tasks, because Make
> > knows a lot of built in rules out of the box. For example, to
> > compile a .c source file foo.c into a program foo, all you need is
> > say "make -k foo", and Make will do it even without a Makefile.
> >
> > > thus I would lke the default line to be
> > >
> > > "gcc -ansi -O4 -Wall <c_source_file>"
> > >
> > > How do I do this?
> >
> > Customize the variable compile-command.
> >
> > > I tried the following command but it doesn't seem to work (If
> > > anyone have a better idea please let me know).
> > >
> > > (function
> > > (lambda ()
> > > (unless (or (file-exists-p "makefile")
> > > (file-exists-p "Makefile"))
> > > (setq compile-command
> > > (concat "gcc -Wall -O3 -o"
> > > (file-name-sans-extension
> > > (file-name-nondirectory buffer-file -name))
> > > " "
> > > (file-name-nondirectory buffer-file-name))))))
> >
> > Where did you put this and how did you use it?
> >
> >
>
> (defun string-join (prefix list)
> ;; This is analogous to the perl5 join function.
> ;; given a <prefix> and a <list> of strings join the
> ;; strings with <prefix> as a seperator between the
> ;; list values.
> ;;
> ;; The result is a single string value.
> (apply 'concat
> (car list)
> (if (cdr list) (prefix-strings prefix (cdr list))) ))
>
>
> (setq my-warnings '("-Wall"))
> (setq my-optimization '("-O2"))
>
> (defun create-compile-command ( target source )
> (string-join " " (cons
> (or (getenv "CC") "gcc")
> (append my-warnings my-optimization (list "-o"
> target source)))))
>
> (create-compile-command "foo" "foo.c")
>
> (defun my-compile ()
> (interactive)
> (lexical-let*
> ((source (file-name-nondirectory buffer-file-name))
> (target (file-name-sans-extension source)))
>
> (if (file-readable-p (concat (file-name-directory
> buffer-file-name) "Makefile")) (compile)
> (let
> (compile-command (create-compile-command))
> (compile))) ))
>
> I haven't used compile in a while, but this is a sketch of how I
> would approach it. Hope it helps.
as cute as elisp is why not create a generic Makefile, and supply a -f argument ?
> Cheers,
> Mike Mattie
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
next prev parent reply other threads:[~2008-03-26 4:57 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-25 13:09 help with makefile command line Balaji V. Iyer
2008-03-25 14:04 ` William Xu
2008-03-26 4:19 ` Eli Zaretskii
2008-03-26 4:25 ` Mike Mattie
2008-03-26 4:42 ` Mike Mattie
2008-03-26 4:57 ` Mike Mattie [this message]
2008-03-26 16:20 ` Nikolaj Schumacher
[not found] <mailman.9409.1206451688.18990.help-gnu-emacs@gnu.org>
2008-03-27 15:36 ` step
2008-03-27 17:28 ` Richard G Riley
2008-03-28 2:51 ` stan
2008-03-28 3:01 ` Richard G Riley
2008-03-28 7:11 ` stan
2008-03-28 12:57 ` Richard G Riley
2008-03-28 20:33 ` stan
2008-03-29 13:18 ` Richard G Riley
2008-03-29 15:33 ` Kevin Rodgers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080325215713.1c99642a@reforged \
--to=codermattie@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).