make-w32
[Top][All Lists]
Advanced

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

Re: strange behavior with makefile


From: Paul Smith
Subject: Re: strange behavior with makefile
Date: Mon, 20 Jan 2014 08:17:43 -0500

On Mon, 2014-01-20 at 00:45 -0800, Uwe wrote:
> I am just before getting mad with that makefile. I already shortened my
> large makefile to just a few lines:

> SRC_DIR   = ..\src
> OUT_DIR   = ..\out
> TMP_DIR   = ..\tmp

> # Compiler
> CC = ..\..\tools\compiler\cx6808
> CFLAGS = -pp -vl +nowiden +debug -oc -co$(TMP_DIR) -cl$(OUT_DIR)
> 
> C_FILES_APP = bootload.c can.c
> OBJ_FILES = $(C_FILES_APP:.c=.o)
> 
> all: h08 s19
> 
> h08: $(TARGET).h08
> s19: $(TARGET).s19
> 
> $(TARGET).h08: $(OBJ_FILES)
> 
> *Call from command shell:*
> ..\..\tools\make\make -n -s -f makefile all

So, here you've asked make to build the "all" target.  make sees that to
do that it needs to build the "h08" target.  To do that it needs to
build the "$(TARGET).h08" target.  To do THAT it needs to build the
"bootload.o" and "can.o" targets.

Then it looks for a rule that can build these targets.  There are no
rules defined in your makefile that specify how to build a .o file, so
make uses the built-in rule for compiling a .o from a .c, which is this
(use "make -pf- <nul" to see a complete list of built-in rules):

  %.o: %.c
          $(COMPILE.c) $(OUTPUT_OPTION) $<

where "COMPILE.c" is "$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c" and
"OUTPUT_OPTION" is "-o $@".

> *Output:*
> ..\..\tools\compiler\cx6808 -pp -vl +nowiden +debug -oc -co..\tmp -cl..\out  
> -c -o bootload.o ..\src/bootload.c
> ..\..\tools\compiler\cx6808 -pp -vl +nowiden +debug -oc -co..\tmp -cl..\out  
> -c -o can.o ..\src/can.c
> make: *** No rule to make target `TEST.s19', needed by `s19'.  Stop.
> 
> Why does make indicate that it wants to make a compiler call and why with
> those options -c -o and why is there a / instead of a \ ???

The above explains why the compiler is called: because you've asked make
to build a .o file.

In your makefile you've set CC and CFLAGS, so that's where those values
come from.  You can see where the -o and -c come from: the default
rules.  If that's not the correct set of operations for your compiler,
you need to either define your own pattern rule, or if you want to use
the default rule you need to reset the COMPILE.c variable to contain the
command you want to use.

As for why the "/" instead of "\", make is a POSIX tool and it deals
with "/" as a directory separator.  The Windows port of make has some
facilities to read Windows paths instead, but when make constructs a
pathname (as it does here as a result of vpath) it will always use "/"
as the directory separator.

However, almost all Windows commands accept both "\" and "/" as
directory separators, so usually this is not a problem.




reply via email to

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