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:42:20 -0700 Message-ID: <20080325214220.38405b4a@reforged> References: <000001c88e79$86451340$33160e98@ece.ncsu.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/6QblLs2+lVt7AhUUDYhRDH."; protocol="application/pgp-signature"; micalg=PGP-SHA1 X-Trace: ger.gmane.org 1206506862 30107 80.91.229.12 (26 Mar 2008 04:47:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 26 Mar 2008 04:47:42 +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 05:48:13 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 1JeNYa-00086H-Iy for geh-help-gnu-emacs@m.gmane.org; Wed, 26 Mar 2008 05:48:13 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JeNXz-0002Xa-Cc for geh-help-gnu-emacs@m.gmane.org; Wed, 26 Mar 2008 00:47:35 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JeNXJ-0002Mv-Dh for help-gnu-emacs@gnu.org; Wed, 26 Mar 2008 00:46:53 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JeNXG-0002KJ-Gz for help-gnu-emacs@gnu.org; Wed, 26 Mar 2008 00:46:50 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JeNXF-0002Jx-E9 for help-gnu-emacs@gnu.org; Wed, 26 Mar 2008 00:46:49 -0400 Original-Received: from wa-out-1112.google.com ([209.85.146.179]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JeNXE-0005iF-Tp for help-gnu-emacs@gnu.org; Wed, 26 Mar 2008 00:46:49 -0400 Original-Received: by wa-out-1112.google.com with SMTP id k34so4361549wah.10 for ; Tue, 25 Mar 2008 21:46:47 -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=FAzRQhpDB5Rgfd+2hR4nTie/onn+kpoKOG+TVjoZdvo=; b=GaqbIxWA78GIzM8GOeWQ2JxzjFYie2wR6EAVwVsyPuY9NXag2J00ys+cSouYr5WBHDamR0Erkdpv8Yq7ZSgkIcRjeY6t1w3ht4GkPHldbZVW4TA0ES2pwTTTUAO9VORz5jOSceF5kM3HKx9P+lRGzmZaX+8GN4zywo+ehfGfRG4= 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=tszjnZJXa3f2vzr2gXW0ItLmz1YApe+BUXLUPgyF1vP7hQHBQXA5U4T+5Yup/N/vEB0/b71Bk+tmoPx5vrxPwh2FqX98gZsPq95Ft/Gaw2tuCl+HDWRwbb9EhuneTbUELV0wCFjbRO2CvZ9KIehNPJI8oLSzYyTpeaitleRcvGU= Original-Received: by 10.114.197.1 with SMTP id u1mr14756210waf.61.1206506807613; Tue, 25 Mar 2008 21:46:47 -0700 (PDT) Original-Received: from reforged ( [71.217.206.83]) by mx.google.com with ESMTPS id m28sm19308016poh.7.2008.03.25.21.46.46 (version=SSLv3 cipher=OTHER); Tue, 25 Mar 2008 21:46:46 -0700 (PDT) In-Reply-To: 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:52693 Archived-At: --Sig_/6QblLs2+lVt7AhUUDYhRDH. Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Wed, 26 Mar 2008 06:19:17 +0200 Eli Zaretskii wrote: > > 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 (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))) )) (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) "Ma= kefile")) (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 appr= oach it. Hope it helps. Cheers, Mike Mattie --Sig_/6QblLs2+lVt7AhUUDYhRDH. Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFH6dQsdfRchrkBInkRAtxkAJ4n+AOOXLLzM5jjTqXsPOrdAOZA0wCfQ4/n z9aU96IMN660J9PfBzXltiA= =BD/P -----END PGP SIGNATURE----- --Sig_/6QblLs2+lVt7AhUUDYhRDH.--