help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Emacs users a dying breed?


From: Dan Espen
Subject: Re: Emacs users a dying breed?
Date: Sat, 23 Jun 2012 20:16:46 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux)

notbob <notbob@nothome.com> writes:

> On 2012-06-21, Ken Goldman <kgoldman@us.ibm.com> wrote:
>
>> I think Pascal was saying that you Makefile (not /usr/bin/make) might
>> not be in the same directory as your code.
>>
>> If you don't have a makefile there, you can also do 'make -f 
>> pathtomakefile' and emacs will remember it for the next time.
>>
>> If you don't have a makefile at all, it's time to create one.
>>
>> Bonus:  Check out M-x next-error.  I have both compile and next-error 
>> bound to Fn keys since I use them constantly.
>
> OK.  I'll risk looking stupid one more time.  ;)
>
> What, exactly, is this "Makefile"?

A Makefile is  a file using that name (Makefile)  that you normally keep
in the  same directory as your source  code.  In that file  you keep the
rules it takes to build your source code.

Start here for documentation:

http://www.gnu.org/software/make/manual/

The basic idea is to list your files, show how they inter-relate and are
used to build your project.


A simple example of a Makefile:

SRC:=hello.c
TARG:=$(subst .c,,$(SRC))

all: $(TARG)

%: %.c
        cc $< $@

test:   $(TARG)
        ./$(TARG)


Anything starting in column 1 and ending in a ":" is a target.
(Something you want to make.)

Things listed after the colon (":") are things you need to make
the target.

Things following a TAB in column 1 are rules.  The rules you need
to make the target.

Makefiles can get a lot more elaborate and can do a lot of things
for you.  If you need to compile 3 subroutines for a main before
you link the main, the makefile can ensure that you do that.

Anyway, it's definitely worth the time to learn and a great
productivity booster.  It's also not only for building programs.
I use them to upload web pages to a server.

For example:

UP_SITE:=ftpmysite.somewhere.net
uploads:=$(wildcard *.jpg *.html *.gif *.css )
targets:=$(addprefix .upload/,$(uploads))

all: $(targets)

define install_html
(\
echo -e "binary\n"\
 "cd deck\n"\
 "put $(subst .upload/,,$@)\n"\
 "close\n"\
 "quit\n"\
 ) | ftp $(UP_SITE)
endef

.upload/%: %
        $(install_html)
        echo "`date`" > $@
clean:
        rm .upload/*


-- 
Dan Espen


reply via email to

[Prev in Thread] Current Thread [Next in Thread]