EmbDev.net

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


von Pablo M. (pablet)


Rate this post
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

von Kshitij S. (kshitij)


Rate this post
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 :)

von Pablo M. (pablet)


Rate this post
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.

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.