Problem with makefile

OP #1174681
Hello *,

I'm trying to compile my first "Hello World" project using Eclipse and
the Codesourcery tool chain. I have configured and installed everything
but I get this error when try to compile:

***multiple target patterns. Stop.


Here is the code of the makefile and the line where the error comes:


######################################################################## 
######################
# Start of user section
#

# Define project name here
PROJECT = helloFirst
PROJ_DIR = "D:/Tools/HelloFirst"

# Define linker script file here
LDSCRIPT = "C:/Program Files/CodeSourcery/Sourcery
G++/m68k-elf/lib/m5475/m5485evb-ram.ld"

# List all user C define here, like -D_DEBUG=1
UDEFS =

# Define ASM defines here
UADEFS =

# List C source files here
SRC = $(PROJ_DIR)/src/hello.c

# List ASM source files here
#ASRC =

# List all user directories here
UINCDIR =   $(PROJ_DIR)/. \
                  $(PROJ_DIR)/src \
                  $(PROJ_DIR)/inc


# List the user directory to look for the libraries here
ULIBDIR = "C:/cygwin/lib"

# List all user libraries here
ULIBS = -lm

# Define optimisation level here
OPT = -O0

#
# End of user defines
######################################################################## 
######################


OBJDIR = .obj
INCDIR  = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR))
LIBDIR  = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
DEFS    = $(DDEFS) $(UDEFS)
ADEFS   = $(DADEFS) $(UADEFS)
OBJS    = $(patsubst $(PROJ_DIR)/%, $(PROJ_DIR)/$(OBJDIR)/%,
$(ASRC:.s=.o) $(SRC:.c=.o))
LIBS    = $(DLIBS) $(ULIBS)

INCDIR += -I"C:/Program Files/CodeSourcery/Sourcery G++
Lite/lib/gcc/m68k-elf/4.2.3/include" \
              -I"C:/Program Files/CodeSourcery/Sourcery G++
Lite/m68k-elf/include" \
              -I"C:/Program Files/CodeSourcery/Sourcery G++
Lite/m68k-elf/include/sys" \
              -I"C:/Program Files/CodeSourcery/Sourcery G++
Lite/m68k-elf/include/machine" \
              -I"C:/Program Files/CodeSourcery/Sourcery G++
Lite/lib/gcc/m68k-elf/4.2.3/install-tools/include"


MCFLAGS = -mcpu=548x

ASFLAGS = $(MCFLAGS) -g
-Wa,--register-prefix-optional,-amhls=$(@:.o=.lst) $(ADEFS)
CPFLAGS = $(MCFLAGS) $(OPT) -g -fomit-frame-pointer \
                  -fno-builtin -ffreestanding -nostdinc          \
                  -Wall -Wstrict-prototypes -fverbose-asm        \
                  -Wa,-ahlms=$(@:.o=.lst) $(DEFS)
LDFLAGS = $(MCFLAGS) -T$(LDSCRIPT) \
                  -fno-builtin -ffreestanding -nostdinc          \
                  -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch
$(LIBDIR)

# Generate dependency information
CPFLAGS += -MD -MP -MF .dep/$(@F).d

#
# makefile rules
#
.SECONDEXPANSION:

all: $(OBJS) $(PROJECT).elf $(PROJECT).bin  # ß------Error comes
here-------<

$(OBJDIR)/%o : %c | $$(@D)/.tmp
      $(CC) -c $(CPFLAGS) -I . $(INCDIR) $< -o $@

$(OBJDIR)/%.o : %.s | $$(@D)/.tmp
      $(AS) -c $(ASFLAGS) $< -o $@

%elf: $(OBJS)
      $(CC) $(OBJS) $(LDFLAGS) $(LIBS) -o $@

%bin: %elf
      $(BIN) $< $@

%/.tmp:
      -mkdir $(subst /,\,$*)
      -touch $@

.PRECIOUS: %/.tmp

Please, can some one help me with this topic? I don’t have any
experience with makefile, I looked already the documentation on the GNU
website and many forums but couldn’t find any solution.


Many thanks in advance
Pablo
#1174682
> # Define linker script file here
> LDSCRIPT = "C:/Program Files/CodeSourcery/Sourcery
> G++/m68k-elf/lib/m5475/m5485evb-ram.ld"

Suggestion 1: Try to ensure that there are no spaces(as in Program
Files) in the installation path.

> # List all user C define here, like -D_DEBUG=1
> $(OBJDIR)/%o : %c | $$(@D)/.tmp
>       $(CC) -c $(CPFLAGS) -I . $(INCDIR) $< -o $@

Suggestion 2: Shouldn't that be %.o and %.c ??

> $(OBJDIR)/%.o : %.s | $$(@D)/.tmp
>       $(AS) -c $(ASFLAGS) $< -o $@
>
> %elf: $(OBJS)
>       $(CC) $(OBJS) $(LDFLAGS) $(LIBS) -o $@

Suggestion 3: %.elf ?? Did you make an error when copying the Makefile?

> %bin: %elf
>       $(BIN) $< $@

> Please, can some one help me with this topic? I don’t have any
> experience with makefile,

Neither do I(atleast, not that much). Just google "Makefile tutorials".
You will end up learning about Makefiles anyway, so why not start now :)
OP #1174683
Thank you for your answer.
I solve the problem by writing the include statements like that:

INCDIR += -IC:/CodeSourcery/SourceryGLite/m68k-elf/include   \
  -IC:/CodeSourcery/SourceryGLite/lib/gcc/m68k-elf/4.3.2/include

I change the directory of the include files to avoid whitespaces,
although it also can work by writing the whitespaces as "\ ".

I foud out that tabs are also very important.

Thanks again.

Reply

A question of your own? This thread is over 17 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.