delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/02/26/15:16:31

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: "Thomas Tutone" <Thomas8675309NO_SPAM AT yahoo DOT com>
Newsgroups: comp.os.msdos.djgpp
References: <c1kne5$3p$1 AT alpha2 DOT radio-msu DOT net>
Subject: Re: How can I create a makefile automatically?
Lines: 90
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <egs%b.99342$hR.1953378@bgtnsc05-news.ops.worldnet.att.net>
Date: Thu, 26 Feb 2004 20:01:14 GMT
NNTP-Posting-Host: 12.77.20.8
X-Complaints-To: abuse AT worldnet DOT att DOT net
X-Trace: bgtnsc05-news.ops.worldnet.att.net 1077825674 12.77.20.8 (Thu, 26 Feb 2004 20:01:14 GMT)
NNTP-Posting-Date: Thu, 26 Feb 2004 20:01:14 GMT
Organization: AT&T Worldnet
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

"Anthony" <akantsel AT integra DOT rmt DOT ru> wrote:

> When I create a project which has several source files, libs etc, is there
> an easy way to generate a makefile for it? I know I can run a gcc -MM for
> each file and save output, add some optional entries for 'make release',
> 'make debug', ... by hands. But may be there are some tools that can do it
> for me? I know I can export makefile in RHIDE, but I'm looking for a kind
of
> command-line script that I can use in MultiEdit.

As Mr. Broeker says, at the end of the day, makefile
writing is an integral part of the job of creating a
big multi-source program in C or C++.

Having said that, there are a few things you can do to
automate the process.

First, as you note, RHIDE will export a make file.
Similarly, VIDE, which in a prior message you
indicated you used, generates make files which you can
then modify to work with DJGPP without too much
effort.  At the very least, this gives you a base to
work from.

Second, and probably more usefully for your needs, you
can write your makefiles so that they automatically
regenerate their own dependencies.  While you still
have to write the glue, the make file will know what
headers to include, etc., without your having modify
the make file.  The basic theory is that the makefile
uses cpp -MM to generate the dependencies, which it
saves to a separate file, then reads in that file to
obtain the dependencies.  Here's a web page that
explains the technique (the owner of the website is
one of the gnu make developers, so you'll find a lot
of useful stuff on the website):

http://make.paulandlesley.org/autodep.html

Here's a very simple example (untested, from memory,
so you will probably need to fiddle with it to get it
to work):

# autodependency generating makefile
CXX = gxx
CXXFLAGS = -g -Wall -W -pedantic
SRCS= main.cpp scanner.cpp parser.cpp \
      environ.cpp native.cpp prim.cpp

all: intrpret

#get the objs
OBJS = $(SRCS:.cpp=.o)

#Main Target
intrpret: $(OBJS)
	  $(CXX) $(OBJS) -o $@.exe

depend.m: $(SRCS) makefile
	  $(CXX) $(CXXFLAGS) -MM $(SRCS) > depend.m

#include the dependency file
include depend.m

# end of example makefile

The idea is that this makefile will regenerate the
dependencies if any source file or the makefile itself
is modified.

A warning:  It sounds like you expect to run the
makefile from multiedit.  I don't use multiedit, but
my advice from before stands:  DJGPP and windows
programs do not interact well.  I would be surprised
if multiedit can successfully compile DJGPP programs
from within multiedit.  You'll probably find that, as
I recommended, you can use multiedit to do your
editing, but you will still have to call make from the
command line.

Best regards,

Tom






- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019