OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [sw/] [Makefile.inc] - Blame information for rev 397

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 349 julius
######################################################################
2
####                                                              ####
3 392 julius
#### Common software makefile for inclusion by others             ####
4 349 julius
####                                                              ####
5
######################################################################
6
####                                                              ####
7
#### Copyright (C) 2010 Authors and OPENCORES.ORG                 ####
8
####                                                              ####
9
#### This source file may be used and distributed without         ####
10
#### restriction provided that this copyright statement is not    ####
11
#### removed from the file and that any derivative work contains  ####
12
#### the original copyright notice and the associated disclaimer. ####
13
####                                                              ####
14
#### This source file is free software; you can redistribute it   ####
15
#### and/or modify it under the terms of the GNU Lesser General   ####
16
#### Public License as published by the Free Software Foundation; ####
17
#### either version 2.1 of the License, or (at your option) any   ####
18
#### later version.                                               ####
19
####                                                              ####
20
#### This source is distributed in the hope that it will be       ####
21
#### useful, but WITHOUT ANY WARRANTY; without even the implied   ####
22
#### warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ####
23
#### PURPOSE.  See the GNU Lesser General Public License for more ####
24
#### details.                                                     ####
25
####                                                              ####
26
#### You should have received a copy of the GNU Lesser General    ####
27
#### Public License along with this source; if not, download it   ####
28
#### from http://www.opencores.org/lgpl.shtml                     ####
29
####                                                              ####
30
######################################################################
31
 
32 360 julius
DESIGN_NAME=orpsoc
33 349 julius
 
34
OR32_TOOL_PREFIX=or32-elf-
35
 
36
OR32_LD=$(OR32_TOOL_PREFIX)ld
37
OR32_AS=$(OR32_TOOL_PREFIX)as
38
OR32_CC=$(OR32_TOOL_PREFIX)gcc
39
OR32_AR=$(OR32_TOOL_PREFIX)ar
40
OR32_RANLIB=$(OR32_TOOL_PREFIX)ranlib
41
OR32_OBJDUMP=$(OR32_TOOL_PREFIX)objdump
42
OR32_OBJCOPY=$(OR32_TOOL_PREFIX)objcopy
43
 
44 392 julius
# SW_ROOT should be set by whatever is running this
45 349 julius
 
46 392 julius
# Special case for CPU drivers
47
CPU_DRIVER ?=$(SW_ROOT)/drivers/or1200
48
 
49
# Rest of drivers, check if we have any that we should use board-specific
50
# versions of.
51
# Expecting BOARD_SPECIFIC_DRIVERS and BOARD_PATH to be set
52
COMMON_SW_DRIVERS=$(shell ls $(SW_ROOT)/drivers )
53
COMMON_SW_DRIVERS_EXCLUDE_BOARD_DRIVERS_CMD=$(shell for driver in $(BOARD_SPECIFIC_DRIVERS); do echo -n "grep -v $$driver"; done)
54
COMMON_SW_DRIVERS_WITHOUT_BOARD_DRIVERS=$(shell echo $(COMMON_SW_DRIVERS) $(COMMON_SW_DRIVERS_EXCLUDE_BOARD_DRIVERS_CMD))
55
 
56
# Add paths to the common drivers
57
SW_DRIVER_PATHS=$(shell for driver in $(COMMON_SW_DRIVERS_WITHOUT_BOARD_DRIVERS); do echo $(SW_ROOT)/drivers/$$driver; done)
58
# If anything in BOARD_SPECIFIC_DRIVERS, add it to SW_DRIVER_PATHS
59
# It's expected BOARD_PATH points to the board's path and the heirarchy of
60
# sw/drivers exists
61
SW_DRIVER_PATHS += $(shell for driver in $(BOARD_SPECIFIC_DRIVERS); do echo $(BOARD_PATH)/sw/drivers/$$driver; done)
62
 
63
# Now assemble all of the include paths for the drivers, prefix with -I for GCC
64
DRIVER_INCLUDE_PATHS=$(shell for driverpath in $(SW_DRIVER_PATHS); do echo "-I$$driverpath/include"; done)
65
 
66
# If BOARD_PATH isn't set, then we're not compiling for a board, so use the
67
# generic board.h include path, otherwise, use that board's
68
ifeq ($(BOARD_PATH),)
69
DRIVER_INCLUDE_PATHS +=-I$(SW_ROOT)/board/include
70
else
71
DRIVER_INCLUDE_PATHS +=-I$(BOARD_PATH)/sw/board/include
72
endif
73
 
74 397 julius
# For now, only apps path is in root sw directory
75
SW_APPS_PATH=$(SW_ROOT)/apps
76
 
77 392 julius
VECTORS_OBJ ?=$(CPU_DRIVER)/crt0.o
78
ORPSOC_LIB ?=$(SW_ROOT)/lib/liborpsoc.a
79
SUPPORT_LIBS ?=$(ORPSOC_LIB)
80
 
81
# All driver compilations will generate an object file of this name to be
82
# included into the liborpsoc library
83
DRIVER_OBJ=compiled.o
84
 
85 349 julius
# Machine flags - uncomment one or create custom combination of flags
86
# All software div, mul and FPU
87
#MACH_FLAGS ?=-msoft-mul -msoft-div -msoft-float
88
# FPGA default - only hardware multiply
89
#MACH_FLAGS ?=-mhard-mul -msoft-div -msoft-float
90
# All hardware flags
91
#MARCH_FLAGS ?=-mhard-mul -mhard-div -mhard-float
92
# Hardware integer arith, soft float
93
MARCH_FLAGS ?=-mhard-mul -mhard-div -msoft-float
94
 
95 392 julius
OR32_CFLAGS ?=-g -nostdlib -O2 $(MARCH_FLAGS) \
96
                $(DRIVER_INCLUDE_PATHS) \
97
                -I$(SW_ROOT)/lib/include
98 349 julius
 
99 392 julius
OR32_LDFLAGS ?=-lgcc -T$(CPU_DRIVER)/link.ld -e 256
100
OR32_ARFLAGS ?=-r
101 393 julius
# RTL_VERILOG_INCLUDE_DIR *MUST* be set!
102 392 julius
# Backup one - default, but may be wrong!
103 393 julius
RTL_VERILOG_INCLUDE_DIR ?= $(SW_ROOT)/../rtl/verilog/include
104 349 julius
 
105 393 julius
DESIGN_VERILOG_DEFINES=$(RTL_VERILOG_INCLUDE_DIR)/$(DESIGN_NAME)-defines.v
106 392 julius
DESIGN_PROCESSED_VERILOG_DEFINES=$(SW_ROOT)/lib/include/$(DESIGN_NAME)-defines.h
107 349 julius
 
108 393 julius
OR1200_VERILOG_DEFINES=$(RTL_VERILOG_INCLUDE_DIR)/or1200_defines.v
109 392 julius
OR1200_PROCESSED_VERILOG_DEFINES=$(SW_ROOT)/lib/include/or1200-defines.h
110 349 julius
 
111 361 julius
PROCESSED_DEFINES=$(DESIGN_PROCESSED_VERILOG_DEFINES) $(OR1200_PROCESSED_VERILOG_DEFINES)
112 349 julius
 
113 393 julius
ELF_DEPENDS+= $(SUPPORT_LIBS)
114 361 julius
 
115 349 julius
# Set V=1 when calling make to enable verbose output
116
# mainly for debugging purposes.
117
ifeq ($(V), 1)
118
Q=
119
else
120
Q ?=@
121
endif
122
 
123
# Our local utilities
124 392 julius
UTILS_BIN2HEX=$(SW_ROOT)/utils/bin2hex
125 349 julius
$(UTILS_BIN2HEX):
126 392 julius
        $(Q)$(MAKE) -C $(SW_ROOT)/utils bin2hex
127 349 julius
 
128 392 julius
UTILS_BIN2VMEM=$(SW_ROOT)/utils/bin2vmem
129 349 julius
$(UTILS_BIN2VMEM):
130 392 julius
        $(Q)$(MAKE) -C $(SW_ROOT)/utils bin2vmem
131 349 julius
 
132 397 julius
processed-verilog-headers: $(PROCESSED_DEFINES)
133
 
134 349 julius
# Rule to generate C header file from Verilog file with `defines in it
135
$(DESIGN_PROCESSED_VERILOG_DEFINES): $(DESIGN_VERILOG_DEFINES)
136
        $(Q)echo; echo "\t### Creating software defines header from verilog defines ###";
137 392 julius
        $(Q)echo "//This file is autogenerated from "$<" do not change!" > $@
138
        $(Q)echo "#ifndef _"$(DESIGN_NAME)"_DEFINES_H_" >> $@
139
        $(Q)echo "#define _"$(DESIGN_NAME)"_DEFINES_H_" >> $@
140
        $(Q)cat $< | sed s://.*::g | sed 's/'\`'/'#'/g' >> $@
141
        $(Q)echo "#endif" >> $@
142
        $(Q)echo; echo >> $@
143 349 julius
 
144
# This works (doesn't error), but for now we have to remove all of the numbers
145
# in verilog format, eg. 8'b0010_0000 or 32'h0000_0f00, or 32'd256 etc. as it's
146
# not so straight forward to convert these
147
$(OR1200_PROCESSED_VERILOG_DEFINES): $(OR1200_VERILOG_DEFINES)
148
        $(Q)echo; echo "\t### Creating OR1200 software defines header from verilog defines ###";
149 392 julius
        $(Q)echo "//This file is autogenerated from "$<" do not change!" > $@
150
        $(Q)echo "#ifndef _OR1200_DEFINES_H_" >> $@
151
        $(Q)echo "#define _OR1200_DEFINES_H_" >> $@
152
        $(Q)cat $< | sed s://.*::g | grep -v \'[dhb] | sed 's/'\`'/'#'/g' >> $@
153
        $(Q)echo "#endif" >> $@
154
        $(Q)echo; echo >> $@
155 349 julius
 
156
# Default make
157
%.flashin: %.bin $(UTILS_BIN2HEX)
158
        $(Q)$(UTILS_BIN2HEX) $< 1  -size_word > $@
159
 
160
%.vmem: %.bin $(UTILS_BIN2VMEM)
161
        $(Q)$(UTILS_BIN2VMEM) $< > $@
162
 
163 393 julius
%.elf: %.c $(ELF_DEPENDS) $(VECTORS_OBJ)
164 349 julius
        $(Q)$(OR32_CC) $^ $(OR32_CFLAGS) $(OR32_LDFLAGS) -o $@
165
 
166
%.elf: %.S $(ELF_DEPENDS)
167
        $(Q)$(OR32_CC) $^ $(OR32_CFLAGS) $(OR32_LDFLAGS) -o $@
168
 
169
%.o: %.S
170
        $(Q)$(OR32_CC) $(OR32_CFLAGS) -c $< -o $@
171
 
172
%.o: %.c
173
        $(Q)$(OR32_CC) $(OR32_CFLAGS) -c $< -o $@
174
 
175 392 julius
COMPILE_SRCS_BASENAMES=$(basename $(COMPILE_SRCS))
176
COMPILE_OBJS=$(COMPILE_SRCS_BASENAMES:%=%.o)
177 349 julius
 
178 392 julius
$(DRIVER_OBJ): $(COMPILE_OBJS)
179
        $(Q)$(OR32_LD) $(OR32_ARFLAGS) $^ -o $@
180
 
181
# Rule to make all necessary driver objects
182
 
183
$(ORPSOC_LIB): $(PROCESSED_DEFINES)
184 349 julius
        $(Q)echo; echo "\t### Building software support library ###"; echo
185 392 julius
        $(Q)$(MAKE) -C $(SW_ROOT)/lib liborpsoc.a
186 349 julius
 
187
$(VECTORS_OBJ):
188 392 julius
        $(Q)$(MAKE) -C $(CPU_DRIVER) crt0.o
189 349 julius
 
190
# This relies on the local clean rule of each makefile
191
clean-all: distclean
192
 
193
clean-support:
194
        $(Q)$(MAKE) -C ../support clean
195
 
196
# List of software directories, exclude include/
197
SWDIRS=$(shell ls ../ | grep -v include)
198
 
199
distclean:
200
        $(Q)for dir in $(SWDIRS); do if [ -d ../$$dir ]; then $(MAKE) -C ../$$dir clean; fi; done
201 392 julius
        $(Q)for dir in $(SW_DRIVER_PATHS); do $(MAKE) -C $$dir clean; done
202 397 julius
        $(Q)for dir in `ls $(SW_APPS_PATH)`; do $(MAKE) -C $(SW_ROOT)/apps/$$dir clean; done
203 349 julius
        $(Q)rm -f $(PROCESSED_DEFINES)

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.