From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mike Mattie Newsgroups: gmane.emacs.help Subject: Re: help with makefile command line Date: Tue, 25 Mar 2008 21:57:13 -0700 Message-ID: <20080325215713.1c99642a@reforged> References: <000001c88e79$86451340$33160e98@ece.ncsu.edu> <20080325214220.38405b4a@reforged> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/iaDwsPv6z8nfpOalya0AnJO"; protocol="application/pgp-signature"; micalg=PGP-SHA1 X-Trace: ger.gmane.org 1206507732 32077 80.91.229.12 (26 Mar 2008 05:02:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 26 Mar 2008 05:02:12 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Mar 26 06:02:43 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JeNmX-0002CD-CN for geh-help-gnu-emacs@m.gmane.org; Wed, 26 Mar 2008 06:02:37 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JeNlv-0007ul-Me for geh-help-gnu-emacs@m.gmane.org; Wed, 26 Mar 2008 01:01:59 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JeNle-0007ug-JR for help-gnu-emacs@gnu.org; Wed, 26 Mar 2008 01:01:42 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JeNld-0007uQ-PH for help-gnu-emacs@gnu.org; Wed, 26 Mar 2008 01:01:42 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JeNld-0007uC-Lp for help-gnu-emacs@gnu.org; Wed, 26 Mar 2008 01:01:41 -0400 Original-Received: from wa-out-1112.google.com ([209.85.146.182]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JeNlc-000815-VV for help-gnu-emacs@gnu.org; Wed, 26 Mar 2008 01:01:41 -0400 Original-Received: by wa-out-1112.google.com with SMTP id k34so4367645wah.10 for ; Tue, 25 Mar 2008 22:01:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:date:from:to:subject:message-id:in-reply-to:references:x-mailer:mime-version:content-type; bh=J2W+wT7117FHBZw49X/US7+UGu2zKt3KrTNVOKn/KwQ=; b=Y2uL4Updupt9WxhTyp+0QowHb/ROXwOYzHdm7MB6W3DgYIDHZVpo7fN0ws3VtJA3Ap+HGwt16b5slhuKyl956YPqr8NJMZ/FyOhbhlG17SNV4xik7luz4Z6qfAhkBlYTL9SRZxiPXdVCp96skfRvSEAhYkH6+EpvGefBRu/ZmGA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=date:from:to:subject:message-id:in-reply-to:references:x-mailer:mime-version:content-type; b=iodqaolYHKTLtHuKVuHzebLvXIKG26KAeS3PAgsRtO/lmpGXiUoakZPbu+5um1YFv43eVjOXaVCizbVoEE8nFW58r41ENpDJIfSzvX/XPqYX7sUwpeULB2Akb8kEgWuSqjJs4VfdJ7f7crNXQ7YsbGrxk6JLoCuCBhxNTteZ4Iw= Original-Received: by 10.114.132.5 with SMTP id f5mr8399123wad.125.1206507699870; Tue, 25 Mar 2008 22:01:39 -0700 (PDT) Original-Received: from reforged ( [71.217.206.83]) by mx.google.com with ESMTPS id z15sm19546190pod.11.2008.03.25.22.01.38 (version=SSLv3 cipher=OTHER); Tue, 25 Mar 2008 22:01:39 -0700 (PDT) In-Reply-To: <20080325214220.38405b4a@reforged> X-Mailer: Claws Mail 3.0.2 (GTK+ 2.12.8; i686-pc-linux-gnu) X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:52694 Archived-At: --Sig_/iaDwsPv6z8nfpOalya0AnJO Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Tue, 25 Mar 2008 21:42:20 -0700 Mike Mattie wrote: > On Wed, 26 Mar 2008 06:19:17 +0200 > Eli Zaretskii wrote: >=20 > > > From: "Balaji V. Iyer" > > > Date: Tue, 25 Mar 2008 09:09:56 -0400 > > >=20 > > > 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 > >=20 > > 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. > >=20 > > > thus I would lke the default line to be > > > =20 > > > "gcc -ansi -O4 -Wall " > > > =20 > > > How do I do this? > >=20 > > Customize the variable compile-command. > >=20 > > > I tried the following command but it doesn't seem to work (If > > > anyone have a better idea please let me know). > > > =20 > > > (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)))))) > >=20 > > Where did you put this and how did you use it? > >=20 > >=20 >=20 > (defun string-join (prefix list) > ;; This is analogous to the perl5 join function. > ;; given a and a of strings join the > ;; strings with 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))) )) >=20 >=20 > (setq my-warnings '("-Wall")) > (setq my-optimization '("-O2")) >=20 > (defun create-compile-command ( target source ) > (string-join " " (cons > (or (getenv "CC") "gcc") > (append my-warnings my-optimization (list "-o" > target source))))) >=20 > (create-compile-command "foo" "foo.c") >=20 > (defun my-compile () > (interactive) > (lexical-let* > ((source (file-name-nondirectory buffer-file-name)) > (target (file-name-sans-extension source))) >=20 > (if (file-readable-p (concat (file-name-directory > buffer-file-name) "Makefile")) (compile) > (let > (compile-command (create-compile-command)) > (compile))) )) >=20 > 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 argu= ment ? =20 > Cheers, > Mike Mattie --Sig_/iaDwsPv6z8nfpOalya0AnJO Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFH6depdfRchrkBInkRAgzeAJ4vxsDN/+h5py9UTGwqW4z6dBMXkQCg6DJ/ e0emWXfIpWrtB9r5ZJ5B2P0= =wzXe -----END PGP SIGNATURE----- --Sig_/iaDwsPv6z8nfpOalya0AnJO--