summaryrefslogtreecommitdiff
path: root/Demo/PIC18_SDCC/Makefile
blob: 8e0c582911b938a0d4fd234928fcc7e8f2ac61e2 (plain)
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
#########################################################################################
# GAYE Abdoulaye Walsimou, <walsimou@walsimou.com>
# Copyright(C) 2009 GAYE Abdoulaye Walsimou, <walsimou@walsimou.com>  All rights reserved.
#
# This program is free software; you can distribute it and/or modify it
# under the terms of the GNU General Public License
# (Version 2 or later) published by the Free Software Foundation.
#
# This program is distributed in the hope it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
#########################################################################################
#
# \file         Makefile
# \brief	Makefile of PIC18/SDCC port
# \author       GAYE Abdoulaye Walsimou, <walsimou@walsimou.com>
# \date         February 2009
#########################################################################################

CC=sdcc
AS=gpasm
LD=gplink

#Device selection
ifeq ($(DEVICE),)
DEVICE:=18f452
else
DEVICE:=$(DEVICE)
endif

#SDCC pic16 libraries
ifeq ($(PIC16_LIB_PATH),)
PIC16_LIB_PATH:=/usr/local/share/sdcc/lib/pic16
else
PIC16_LIB_PATH:=$(PIC16_LIB_PATH)
endif

#type of pic used
ARCH=pic16

#set MAINFILE
ifeq ($(MAINFILE),)
MAINFILE:=main.c
else
MAINFILE:=$(MAINFILE)
endif
MAINFILE_ASM:=$(MAINFILE:.c=.asm)
MAINFILE_OBJ:=$(MAINFILE:.c=.o)

# Setup paths to source code
SOURCE_PATH=../../Source
PORT_PATH=$(SOURCE_PATH)/portable/SDCC/PIC18
DEMO_PATH=$(PWD)
COMMON_DEMO_PATH=../Common

#
# Source files
#

SOURCE_FILES= tasks.c list.c queue.c
SOURCE_OBJ=$(SOURCE_FILES:.c=.o)

PORT_FILES= port.c
PORT_OBJ=$(PORT_FILES:.c=.o)

COMMON_DEMO_FILES= integer.c
COMMON_DEMO_OBJ=$(COMMON_DEMO_FILES:.c=.o)

VPATH=$(SOURCE_PATH):$(PORT_PATH):$(DEMO_PATH):$(COMMON_DEMO_PATH)/Minimal

# Setup Compilers and linker FLAGS
SDCC_CFLAGS=	-m$(ARCH) -p$(DEVICE) -I. -I$(SOURCE_PATH)/include -I$(COMMON_DEMO_PATH)/include        \
                -DSDCC_PIC18 --debug --mplab-comp --pstack-model=large --model-large

GPASM_CFLAGS= -g
LDFLAGS= -s $(DEVICE).lkr --map -I$(PIC16_LIB_PATH)
LIBS= libdev$(DEVICE).lib libio$(DEVICE).lib crt0iz.o libc18f.lib libsdcc.lib libm18f.lib

All: $(SOURCE_OBJ) $(PORT_OBJ) $(COMMON_DEMO_OBJ)
	$(CC) -S $(MAINFILE) -o  $(MAINFILE_ASM) $(SDCC_CFLAGS)
	$(AS) -c $(MAINFILE_ASM) -o $(MAINFILE_OBJ) $(GPASM_CFLAGS)
	$(LD) -c -o freertos.hex $^ $(MAINFILE_OBJ) $(LIBS) $(LDFLAGS)

$(SOURCE_OBJ) $(PORT_OBJ) $(COMMON_DEMO_OBJ): %.o: %.asm
	$(AS) -c $< -o $@ $(GPASM_CFLAGS)

%.asm: %.c
	$(CC) -S $< -o $@ $(SDCC_CFLAGS)

clean:
	rm -rf *.o *.asm *.cod *.lst *.hex *.adb *.lib *.calltree *.p *.map *.cof *.coff

cleanAll: clean