-
Notifications
You must be signed in to change notification settings - Fork 18
/
Makefile_iar
107 lines (91 loc) · 4.1 KB
/
Makefile_iar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
###############################################################################
#SECU-3 - An open source, free engine control unit
#Copyright (C) 2007 Alexey A. Shabelnikov. Ukraine, Kiev
#
# Maklefile for build firmware of SECU-3 project using IAR
# Created by Alexey A. Shabelnikov, Kiev 17 July 2011.
#
# Note: It requires IAR compiler and linker
# Also: Before using of this Makefile you must define environment variable IAR_HOME.
# For instance "C:\Program Files\IAR Systems\Embedded Workbench 5.4" (without the double quotation marks)
# Additionaly make sure CC, LD and LIBS variables in this Makefile are correct.
#include platform-specific options from another file
include platform_cfg
TARGET = secu-3_app
OBJDIR = output
CC = "$(IAR_HOME)/avr/bin/iccavr.exe"
LD = "$(IAR_HOME)/avr/bin/xlink.exe"
#LD = "$(IAR_HOME)/common/bin/xlink.exe"
# Compile options common for all C compilation units.
CFLAGS = --cpu $(MCU)
CFLAGS += -DREALTIME_TABLES -DTHERMISTOR_CS -DCOOLINGFAN_PWM -DDIAGNOSTICS -DHALL_OUTPUT -DFUEL_PUMP -DREV9_BOARD
CFLAGS += -DSM_CONTROL -DSTROBOSCOPE -DDWELL_CONTROL -DVREF_5V -DGD_CONTROL -DSECU3T
CFLAGS += -DBL_BAUD_RATE=115200 -DFW_BAUD_RATE=115200 -DSPEED_SENSOR -DINTK_HEATING -DBLUETOOTH_SUPP -DIMMOBILIZER -DUNI_OUTPUT -DAIRTEMP_SENS
CFLAGS += -DLITTLE_ENDIAN_DATA_FORMAT -DENABLE_BIT_DEFINITIONS -DEGOS_HEATING
#CFLAGS += -DIOCFG_FUNC_INIT
CFLAGS += -ms -e --initializers_in_flash
CFLAGS += -s9
#CFLAGS += --cross_call_passes=1 --do_cross_call
CFLAGS += --eeprom_size $(EE_SIZE)
ifeq ($(MCU), m1284)
CFLAGS += --dlib_config "$(IAR_HOME)/avr/lib/dlib/dlAVR-3s-ec_mul-n.h"
else
CFLAGS += --dlib_config "$(IAR_HOME)/avr/lib/dlib/dlAVR-3s-ec_mul-sf-n.h"
endif
# non-native end of line sequence detected (this diagnostic is only issued once)
CFLAGS += --diag_suppress Pa050
# this pragma must immediately precede a declaration
CFLAGS += --diag_suppress Pe606
# undefined behavior: the order of volatile accesses is undefined in this statement
CFLAGS += --diag_suppress Pa082
# Linker flags
LDFLAGS = -Fintel-extended -xs -s main
LDFLAGS += -f "$(IAR_HOME)/avr/config/$(LNKXCL)"
LDFLAGS += -l $(OBJDIR)/secu3.map
LDFLAGS += -Z.boot_loader=$(BL_START) -Z.firmware_data=$(FWD_START)
ifeq ($(MCU), m1284)
LIBS = "$(IAR_HOME)/avr/lib/dlib/dlAVR-3s-ec_mul-n.r90"
else
LIBS = "$(IAR_HOME)/avr/lib/dlib/dlAVR-3s-ec_mul-sf-n.r90"
endif
#LIBS = "$(IAR_HOME)/avr/lib/dlib/dl3s-ec-sf.r90"
# Include Directories
INCLUDES = -I "$(IAR_HOME)/avr/inc/dlib" -I "$(IAR_HOME)/avr/inc"
# Define all source files.
SRC = adc.c bootldr.c ce_errors.c ckps.c crc16.c \
eeprom.c pwrvalve.c funconv.c fuelcut.c eculogic.c \
jumper.c knklogic.c knock.c measure.c params.c \
procuart.c secu3.c starter.c suspendop.c tables.c \
uart.c ventilator.c vstimer.c camsens.c fuelpump.c \
diagnost.c wdt.c ioconfig.c pwrrelay.c bc_input.c \
smcontrol.c choke.c hall.c bluetooth.c onewire.c \
immobiliz.c ckps2ch.c intkheat.c injector.c uni_out.c \
lambda.c ecudata.c gasdose.c gdcontrol.c carb_afr.c \
ckpsn+1.c mathemat.c obd.c dbgvar.c evap.c aircond.c \
egosheat.c ckps-cs.c pwm2.c grheat.c grvalve.c \
ckps-odd.c ltft.c ltft-kosh.c ringbuff.c
# Define all object files and dependencies
OBJECTS = $(SRC:%.c=$(OBJDIR)/%.r90)
DEPS = $(OBJECTS:$(OBJDIR)/%.r90=$(OBJDIR)/%.d)
# Define all listing files.
LST = $(SRC:%.c=$(OBJDIR)/%.lst)
#Thanks to guys from Microsoft we have to deal with spaces...
SPAT=$(shell echo "$(IAR_HOME)" | sed -e 's/\\\/\\\\\\\\\\\/g')
RPAT=$(shell echo "$(IAR_HOME)" | sed -e 's/\\\/\\\\\\\\\\\/g' -e 's/ /\\\\\\\\\\\ /g')
# Build
all: OBJ_DIRS $(TARGET).hex
#Include make files containing dependencies
-include $(DEPS)
#Create directory for object files
OBJ_DIRS :
@mkdir -p $(OBJDIR)
# Compile
$(OBJDIR)/%.r90 : sources/%.c
$(CC) $(INCLUDES) $(CFLAGS) $< -o $@ -lC $(OBJDIR:%.r90=$(OBJDIR)/%.lst) --dependencies=m $(OBJDIR:%.r90=$(OBJDIR)/%.d)
@sed -e 's/$(SPAT)/$(RPAT)/' $(patsubst %.r90, %.d, $@) > tmpfile; mv tmpfile $(patsubst %.r90, %.d, $@)
#Link
$(TARGET).hex: $(OBJECTS)
$(LD) $(LDFLAGS) $(OBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET).hex
# Clean target
clean:
@rm -f $(OBJECTS) $(LST) $(TARGET).hex $(OBJDIR)/*.map $(DEPS)