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

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

Re: Makefile Question.


From: Roger Leigh
Subject: Re: Makefile Question.
Date: Sun, 17 Jul 2005 19:40:58 +0100
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

"Jaemin Kang" <zaemin@orgio.net> writes:

> I'm trying to compile my source files on Linux(Redhat 9).
[...]
> But I got an error message.
>
> make: *** No rule to make target 'Object.o' needed by 'all'. Stop.
>

> OUTPUT_DIR          = ..\..\..\objs
> THERON_SRC_DIR      = ..\..\..\src

Fix your directory separators.  It's '/', unless you really wanted
....objs ('\' escapes the following char).

> ARM_CC              = arm-elf-gcc
> OBJ_CMD             = -o
> OUT                 = -c
> OPT                 = -O2
> CFLAGS              = $(OUT) $(OPT)

There's a lot of redundancy here:

CC = arm-elf-gcc
CFLAGS = -O2

> SRC_FILE = $(@F:.o=.c)
> OBJ_FILE = $(OBJ_CMD) $(OUTPUT_DIR)\$(@F)
>
> .SUFFIXES :
> .SUFFIXES : .o .c
>
> {$(THERON_SRC_DIR)}.c.o :
>       @echo -----------------------------------------------------
>       @echo OBJECT $(@F)
>       $(ARM_CC) $(CFLAGS) $(OBJ_FILE) $(SRC_FILE)
>       @echo -----------------------------------------------------

This is largely non-standard.  Try

%.o: %.c
     $(CC) $(CFLAGS) -o $@ -c $<

For "Object.o", this will run

arm-elf-ecc -O2 -o Object.o -c Object.c

> THERON_OBJS            =                \
>                          Object.o       \
>                          File.o         \
>                          AnsiFile.o     \
>                          BrewFile.o     \
>                          Memory.o       \
>                          AnsiMemory.o   \
>                          BrewMemory.o   \
>                          brew_stdutil.o

This is OK.  As a stylistic and RSI-prevention measure, I wouldn't use
mixed-case filenames.  Use spaces or underscores as separators.

THERON_OBJS            =                \
                         object.o       \
                         file.o         \
                         ansi-file.o    \
                         brew-file.o    \
                         memory.o       \
                         ansi-memory.o  \
                         brew-memory.o  \
                         brew-stdutil.o

> all : $(THERON_OBJS)

Err.. don't you want to end up with an executable or library at this
point?  If "all" is the default rule, you might want to make it the
first.

myprog: $(THERON_OBJS)
        $(CSS) -o $@ $^ $(LIBS)

where $(LIBS) are dependent libraries.

> clean :
>       @echo
>       @echo CLEAN
>       -rm /f $(THERON_OBJS)
>       @echo

Why not just

clean :
        -rm /f $(THERON_OBJS)

?

> It seems that The GNU make doen't understand below line.
>
> '{$(THERON_SRC_DIR)}.c.o :'
>
> My source files and the makefile are in different directory.
>
> Can anyone tell me how to handle this?

Use autoconf and automake, and let them handle separate source and
object directories, cross-compiling and cross-platform portability for
you.  You might also want to read the GNU make reference manual; it's
very good.


Regards,
Roger

- -- 
Roger Leigh
                Printing on GNU/Linux?  http://gimp-print.sourceforge.net/
                Debian GNU/Linux        http://www.debian.org/
                GPG Public Key: 0x25BFB848.  Please sign and encrypt your mail.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iD8DBQFC2qY0VcFcaSW/uEgRAnptAJ49i2cUbdjdowklkx7EgR0PZ/tTCgCgxNCv
SWlwdG0JAyhqH6IBOg9UDag=
=GCaM
-----END PGP SIGNATURE-----


reply via email to

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