Re: [SYSTEM-NT2K/CYGWIN][NEWBIE] circle30bpl19-OasisOLCv2.0.1

From: Daniel A. Koepke (dkoepke@circlemud.org)
Date: 11/18/01


On Mon, 19 Nov 2001, Jason Pay wrote:

> OK, Im editing the makefile.in, Ive added the following files to the
> CXREF_FILES section,

A quick search on Google for "make tutorial" turns up a plethora of good
hits, the first of which is:

  http://www.eng.hawaii.edu/Tutor/Make/

This site appears to be a good, quick introduction to Make, with some
background material that a novice will undoubtedly find invaluable at some
stage of his development.  You can also find more thorough documentation
for the GNU Make program by typing 'info make' at the shell prompt,
assuming that the info documentation was installed.  If you don't know how
to use info, hit '?' once inside the program for help.

Before you read on, familiarize yourself with Make, as I will assume some
basic knowledge of the program from herein.

                                * * * * *

Now, here's what you need to know about CircleMUD's Makefile.  As you can
see (and, now, I hope, understand), CXREF_FILES is the list of files used
by the cross-reference generating rules.  While it's nice to keep this
list up-to-date (in case you ever want to use cxref), it's not necessary
for compiling.  Instead, note that OBJFILES is used as the dependencies
for the $(BINDIR)/circle rule, which makes the CircleMUD executable.
You'll want to, then, add the name of the object file which corresponds to
your .c file to the OBJFILES list.

Now, look lower in the file: right before the object file dependencies,
there's a comment which mentions using gcc -MM to automagically generate
the list.  Try running gcc -MM on a C file from the shell.  For
instance:

  % gcc -MM config.c
  config.o: config.c conf.h sysdep.h structs.h interpreter.h

Note how this matches the target:dependencies line in Makefile.in for this
file.  Once you're comfortable with what gcc -MM does, you can try using
the following script that writes object file rules to Makefile.in for you:

  #!/bin/bash
  # Mailer Code(tm) by dak, 18 Nov 2001

  CFILE=${$1%.o}.c
  OFILE=${$1%.c}.o
  COUNT=`grep -c "^$OFILE: $CFILE" Makefile.in`

  if [ ! -f $CFILE -o ! -r $(CFILE) ]; then
    echo "$0: $CFILE: file not found or not readable"
    exit 1
  elif [ $COUNT != "0" ]; then
    echo "$0: $CFILE: found rule for $OFILE in Makefile.in"
    exit 1
  fi

  gcc -MM $CFILE >> Makefile.in
  echo -e "\t\$(CC) -c \$(CFLAGS) $CFILE"

Using this (assuming it works -- it's Mailer Code(tm)), you end up with an
easy three-step process for adding new files to your Makefiles:

  * Edit Makefile.in to add the object files to OBJFILES list.
  * Run the script for each new file to generate dependencies.
  * Run config.status to regenerate Makefile from Makefile.in.

-dak

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/06/01 PST