EmbDev.net

Forum: ARM programming with GCC/GNU tools Problem with makefile


Author: Pablo Martinez (pablet)
Posted on:

Rate this post
0 useful
not useful
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

Author: Kshitij Singh (kshitij)
Posted on:

Rate this post
0 useful
not useful
> # 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 :)

Author: Pablo Martinez (pablet)
Posted on:

Rate this post
0 useful
not useful
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

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.