This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FW: Novice!!!


 Hi,

I'm not very experienced with GCC and I'm having trouble linking assembly files into my project. After compiling I run the object-file in a simulator (Atmel AVRStudio 4.06), and I notice that the assembly files (*.S) are not included in the source files listing, only the c files (*.c). I use a Make-file to compile with the following setup:

Makefile:
----------------------------------------------------------------------
# Set output name here
TARGET = targetfile

# Set all sources here
CSRC = basic_functions.c interrupt_handlers.c bootloader.c
ASRC = sleep.S loadapp.S

# Set CPU here
MCU  = atmega162

# Set compilation flags here
CFLAGS  = -Wall -W -O1 -mcall-prologues -mno-tablejump -g
ASFLAGS = -g -x assembler-with-cpp -Wa,-gstabs -Wall -W

# ---------------------------------------------------------------
# Do not alter anything below this line unless Guru
# ---------------------------------------------------------------

# Update dependencies
DEPEND_SHELL := $(shell \
 if [ ! -f ".depend" ]; then \
  touch ".depend"; \
  make depend; \
  echo "created"; \
 fi )


# Set other cflags (generic, not project specific)
CFLAGS2 = -mmcu=$(MCU)

# Object files are created from asm and C sources
OBJ = $(CSRC:%.c=%.o) $(ASRC:%.S=%.o)

# If Makefile is altered, project will rebuild.
DEPEND = Makefile

# Tool names
CC  = avr-gcc
OBJCP  = avr-objcopy
RM  = rm
ECHO  = echo

# Compilation Rules
%.eep : $(TARGET).elf
 @$(ECHO) "Creating Intel-Hex file for EEPROM $@"
 @$(OBJCP) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
  --change-section-lma .eeprom=0 -O ihex $< $@

%.obj : $(TARGET).elf
 @$(ECHO) "Creating AVR Object file for AVR Studio"
 @$(OBJCP) -O avrobj $< $@

%.bin : $(TARGET).elf
 @$(ECHO) "Creating binary file for ATMEL JTAG ICE"
 @$(OBJCP) -O binary $< $@

%.elf : $(OBJ) $(DEPEND)
 @$(ECHO) "Linking objects and libraries into $(TARGET).elf"
 @$(CC) $(CFLAGS) $(CFLAGS2) $(OBJ) $(LIBDIRS) $(LIBS) -o $(TARGET).elf
 avr-size $(TARGET).elf

%.hex : $(TARGET).elf
 @$(ECHO) "Creating Intel-Hex file $@"
 @$(OBJCP) -O ihex $< $@

%.o:%.c $(DEPEND)
 @$(ECHO) "Compiling $<"
 @$(CC) $(CFLAGS) $(CFLAGS2) -c $< -o $@

%.o:%.S $(DEPEND)
 @$(ECHO) "Assembling $<"
 @$(CC) $(CFLAGS) $(CFLAGS2) -c $< -o $@

all: $(TARGET).hex $(TARGET).eep $(TARGET).obj $(TARGET).elf

depend: force
 @$(ECHO) "Updating dependencies"
 @$(ECHO) "" > .depend
 $(CC) $(CFLAGS) $(INCLUDEDIRS) -M $(CSRC) $(ASRC) 1>>.depend

clean: force
 $(RM) -f *~ *.o

distclean: force
 $(RM) -f *~ $(TARGET).elf $(TARGET).hex $(TARGET).eep $(TARGET).obj *.o .depend

force:
#
# Include dependency files if they exist
#
ifneq ($(wildcard .depend),)
include .depend
endif
--------------------------------------------------------------------------------
<end Makefile>
 
My actual trouble is that the  "ASRC" files will not include themselves into the project.

Is there anything you can see here or mayby something in general that you can think of that is helpful when using both .c and .S files in your project? Should the functions defined in your assembler files be declared in a specific manner that I am unaware of?

ANY help would be greatly appreciated, and please forgive a stupid user if these questions are sent to the wrong mail address or are just plain stupid questions :)

 

Best regards,
Erling U. Wiken


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]