examples/AVR/Slave/Makefile
author Christian Taedcke <hacking@taedcke.com>
Mon, 23 Jan 2012 21:40:59 +0100
changeset 709 4a8b50dcc4c0
parent 675 e5c5101c4f0b
permissions -rw-r--r--
win32:
- Added visual studio 2010 solution file and project files. Some driver that
does not work are disabled in the configuration manager.
413
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
     1
###############################################################################
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
     2
# Makefile for the project SlaveAVR
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
     3
###############################################################################
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
     4
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
     5
## General Flags
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
     6
PROJECT = SlaveAVR
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
     7
MCU = at90can128
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
     8
TARGET = AVR
675
e5c5101c4f0b FIXED: - The AVR example now compiles in linux.
Christian Taedcke <hacking@taedcke.com>
parents: 413
diff changeset
     9
CC = avr-gcc
413
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    10
SRC = ../../../src
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    11
DRV = ../../../drivers/AVR
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    12
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    13
## Options common to compile, link and assembly rules
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    14
COMMON = -mmcu=$(MCU)
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    15
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    16
## Compile options common for all C compilation units.
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    17
CFLAGS = $(COMMON)
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    18
CFLAGS += -Wall -gdwarf-2 -Os -fsigned-char -fpack-struct
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    19
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d 
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    20
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    21
## Assembly specific flags
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    22
ASMFLAGS = $(COMMON)
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    23
ASMFLAGS += $(CFLAGS)
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    24
ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    25
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    26
## Linker flags
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    27
LDFLAGS = $(COMMON)
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    28
LDFLAGS +=  -Wl,-Map=$(PROJECT).map
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    29
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    30
## Intel Hex file production flags
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    31
HEX_FLASH_FLAGS = -R .eeprom
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    32
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    33
HEX_EEPROM_FLAGS = -j .eeprom
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    34
HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    35
HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    36
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    37
## Include Directories
675
e5c5101c4f0b FIXED: - The AVR example now compiles in linux.
Christian Taedcke <hacking@taedcke.com>
parents: 413
diff changeset
    38
INCLUDES = -I../../../include/AVR -I../../../include
413
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    39
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    40
## Objects that must be built in order to link
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    41
OBJECTS = 	$(DRV)/can_AVR.o\
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    42
		$(DRV)/timer_AVR.o\
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    43
		$(SRC)/dcf.o\
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    44
		$(SRC)/timer.o\
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    45
		$(SRC)/emcy.o\
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    46
		$(SRC)/lifegrd.o\
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    47
		$(SRC)/lss.o\
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    48
		$(SRC)/nmtMaster.o\
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    49
		$(SRC)/nmtSlave.o\
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    50
		$(SRC)/objacces.o\
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    51
		$(SRC)/pdo.o\
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    52
		$(SRC)/sdo.o\
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    53
		$(SRC)/states.o\
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    54
		$(SRC)/sync.o\
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    55
		ObjDict.o\
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    56
		ds401.o\
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    57
		main.o
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    58
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    59
## Build
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    60
all: $(PROJECT).elf $(PROJECT).hex $(PROJECT).eep $(PROJECT).lss size
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    61
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    62
## Compile
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    63
%.o: %.c
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    64
#	@echo " "
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    65
	@echo "---------------------------------------------------------------------------"
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    66
	@echo "**Compiling $< -> $@"
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    67
#	@echo "*********************************************"
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    68
	$(CC) $(INCLUDES) $(CFLAGS) -c $<
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    69
#	$(CC) $(INCLUDES) $(CFLAGS) -c -o $@ $< 
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    70
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    71
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    72
##Link
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    73
$(PROJECT).elf: $(OBJECTS)
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    74
#	@echo " "
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    75
	@echo "---------------------------------------------------------------------------"
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    76
	@echo "**Linking :  $@"
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    77
#	@echo "*********************************************"
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    78
	$(CC) $(LDFLAGS) $(LIBDIRS) $(LIBS) $(^F) -o $@
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    79
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    80
%.hex: $(PROJECT).elf
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    81
	avr-objcopy -O ihex $(HEX_FLASH_FLAGS)  $< $@
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    82
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    83
%.eep: $(PROJECT).elf
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    84
	-avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    85
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    86
%.lss: $(PROJECT).elf
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    87
	avr-objdump -h -S $< > $@
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    88
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    89
size: $(PROJECT).elf
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    90
	@echo
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    91
	@avr-size -C --mcu=${MCU} $(PROJECT).elf
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    92
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    93
## Clean target
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    94
.PHONY: clean
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    95
clean:
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    96
	-rm -rf *.o $(PROJECT).elf dep/* $(PROJECT).hex $(PROJECT).eep $(PROJECT).lss $(PROJECT).map
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    97
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    98
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    99
## Other dependencies
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
   100
-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
   101