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

Subversion Repositories openrisc

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

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
OR32_TOOL_PREFIX=or32-elf-
33
 
34
OR32_LD=$(OR32_TOOL_PREFIX)ld
35
OR32_AS=$(OR32_TOOL_PREFIX)as
36
OR32_CC=$(OR32_TOOL_PREFIX)gcc
37
OR32_AR=$(OR32_TOOL_PREFIX)ar
38
OR32_RANLIB=$(OR32_TOOL_PREFIX)ranlib
39
OR32_OBJDUMP=$(OR32_TOOL_PREFIX)objdump
40
OR32_OBJCOPY=$(OR32_TOOL_PREFIX)objcopy
41
 
42 392 julius
# SW_ROOT should be set by whatever is running this
43 349 julius
 
44 392 julius
# Special case for CPU drivers
45
CPU_DRIVER ?=$(SW_ROOT)/drivers/or1200
46
 
47 530 julius
DESIGN_NAME ?=orpsoc
48
 
49
# If BOARD is set, we'll first scan that path for which drivers they have
50 403 julius
# and will override any locally named driver directories here.
51 468 julius
ifdef BOARD
52
BOARD_PATH=$(SW_ROOT)/../boards/$(BOARD)
53 530 julius
 
54
ifeq ($(V), 1)
55
$(info BOARD is set to : $(BOARD_PATH))
56
endif
57
 
58 468 julius
BOARD_SPECIFIC_DRIVERS=$(shell if [ -e \
59
        $(BOARD_PATH)/sw/drivers ]; then \
60
        ls $(BOARD_PATH)/sw/drivers; \
61
        fi)
62
BOARD_SW_TESTS=$(shell if [ -e $(BOARD_PATH)/sw/tests ]; then\
63
        ls $(BOARD_PATH)/sw/tests; \
64
        fi)
65 530 julius
 
66
# Set RTL_VERILOG_INCLUDE_DIR
67
RTL_VERILOG_INCLUDE_DIR=$(BOARD_PATH)/rtl/verilog/include
68
#We don't actually want this
69
#DESIGN_NAME ?=$(strip $(shell echo $(BOARD)|  cut -d '/' -f 2))
70
 
71 403 julius
endif
72
 
73 392 julius
COMMON_SW_DRIVERS=$(shell ls $(SW_ROOT)/drivers )
74 403 julius
COMMON_SW_DRIVERS_WITHOUT_BOARD_DRIVERS=$(filter-out $(BOARD_SPECIFIC_DRIVERS),$(COMMON_SW_DRIVERS))
75 392 julius
 
76 403 julius
#
77
# Create paths pointing to each driver directory
78
#
79
SW_DRIVER_PATHS=$(addprefix $(SW_ROOT)/drivers/,$(COMMON_SW_DRIVERS_WITHOUT_BOARD_DRIVERS))
80
# If any board paths add them here
81
SW_DRIVER_PATHS += $(addprefix $(BOARD_PATH)/sw/drivers/,$(BOARD_SPECIFIC_DRIVERS))
82 392 julius
 
83
 
84 403 julius
# Add /include to each path - the expected include directories
85
SW_DRIVER_INCLUDE_PATHS=$(addsuffix /include,$(SW_DRIVER_PATHS))
86
# Now add the -I to the front of each so we can pass this to GCC
87
INCLUDE_FLAGS=$(addprefix -I,$(SW_DRIVER_INCLUDE_PATHS))
88
 
89
 
90
print-driver-paths:
91
        $(Q)echo "\tDrivers in use from common sw path"; echo;
92
        @echo $(COMMON_SW_DRIVERS); echo; echo
93
        $(Q)echo "\tDrivers in use from board sw path"; echo;
94
        @echo $(BOARD_SPECIFIC_DRIVERS); echo; echo;
95
        $(Q)echo "\tCommon sw drivers without board drivers"; echo;
96
        @echo $(COMMON_SW_DRIVERS_WITHOUT_BOARD_DRIVERS); echo; echo;
97
        $(Q)echo "\tAll drivers and their paths"; echo;
98
        @echo $(SW_DRIVER_PATHS); echo; echo
99
 
100 408 julius
print-include-paths:
101
        $(Q)echo "\tSoftware include paths"; echo;
102
        @echo $(INCLUDE_FLAGS); echo; echo
103 403 julius
 
104 392 julius
# If BOARD_PATH isn't set, then we're not compiling for a board, so use the
105
# generic board.h include path, otherwise, use that board's
106 403 julius
ifdef BOARD_PATH
107
INCLUDE_FLAGS +=-I$(BOARD_PATH)/sw/board/include
108 392 julius
else
109 403 julius
INCLUDE_FLAGS +=-I$(SW_ROOT)/board/include
110 392 julius
endif
111
 
112 397 julius
# For now, only apps path is in root sw directory
113
SW_APPS_PATH=$(SW_ROOT)/apps
114
 
115 392 julius
VECTORS_OBJ ?=$(CPU_DRIVER)/crt0.o
116
ORPSOC_LIB ?=$(SW_ROOT)/lib/liborpsoc.a
117
SUPPORT_LIBS ?=$(ORPSOC_LIB)
118
 
119
# All driver compilations will generate an object file of this name to be
120
# included into the liborpsoc library
121
DRIVER_OBJ=compiled.o
122
 
123 349 julius
# Machine flags - uncomment one or create custom combination of flags
124
# All hardware flags
125
#MARCH_FLAGS ?=-mhard-mul -mhard-div -mhard-float
126
# Hardware integer arith, soft float
127
MARCH_FLAGS ?=-mhard-mul -mhard-div -msoft-float
128 408 julius
# FPGA default - only hardware multiply
129 425 julius
#MARCH_FLAGS ?=-mhard-mul -msoft-div -msoft-float
130 408 julius
# All software div, mul and FPU
131 425 julius
#MARCH_FLAGS ?=-msoft-mul -msoft-div -msoft-float
132 349 julius
 
133 392 julius
OR32_CFLAGS ?=-g -nostdlib -O2 $(MARCH_FLAGS) \
134 403 julius
                $(INCLUDE_FLAGS) \
135 415 julius
                -I$(SW_ROOT)/lib/include \
136 349 julius
 
137 506 julius
LINK_SCRIPT_OPT ?=-T$(CPU_DRIVER)/link.ld
138
 
139
OR32_LDFLAGS ?=-L$(SW_ROOT)/lib -lorpsoc -lgcc $(LINK_SCRIPT_OPT) -e 256
140 392 julius
OR32_ARFLAGS ?=-r
141 393 julius
# RTL_VERILOG_INCLUDE_DIR *MUST* be set!
142 392 julius
# Backup one - default, but may be wrong!
143 393 julius
RTL_VERILOG_INCLUDE_DIR ?= $(SW_ROOT)/../rtl/verilog/include
144 349 julius
 
145 393 julius
DESIGN_VERILOG_DEFINES=$(RTL_VERILOG_INCLUDE_DIR)/$(DESIGN_NAME)-defines.v
146 392 julius
DESIGN_PROCESSED_VERILOG_DEFINES=$(SW_ROOT)/lib/include/$(DESIGN_NAME)-defines.h
147 349 julius
 
148 393 julius
OR1200_VERILOG_DEFINES=$(RTL_VERILOG_INCLUDE_DIR)/or1200_defines.v
149 392 julius
OR1200_PROCESSED_VERILOG_DEFINES=$(SW_ROOT)/lib/include/or1200-defines.h
150 349 julius
 
151 487 julius
PROCESSED_DEFINES +=$(DESIGN_PROCESSED_VERILOG_DEFINES) $(OR1200_PROCESSED_VERILOG_DEFINES)
152 349 julius
 
153 415 julius
# Mother makefile can set this if extra things are needed to be built and
154
# compild with a certain app.
155
ELF_DEPENDS ?=
156 361 julius
 
157 349 julius
# Set V=1 when calling make to enable verbose output
158
# mainly for debugging purposes.
159
ifeq ($(V), 1)
160
Q=
161
else
162
Q ?=@
163
endif
164
 
165
# Our local utilities
166 392 julius
UTILS_BIN2HEX=$(SW_ROOT)/utils/bin2hex
167 349 julius
$(UTILS_BIN2HEX):
168 392 julius
        $(Q)$(MAKE) -C $(SW_ROOT)/utils bin2hex
169 349 julius
 
170 392 julius
UTILS_BIN2VMEM=$(SW_ROOT)/utils/bin2vmem
171 349 julius
$(UTILS_BIN2VMEM):
172 392 julius
        $(Q)$(MAKE) -C $(SW_ROOT)/utils bin2vmem
173 349 julius
 
174 397 julius
processed-verilog-headers: $(PROCESSED_DEFINES)
175
 
176 349 julius
# Rule to generate C header file from Verilog file with `defines in it
177
$(DESIGN_PROCESSED_VERILOG_DEFINES): $(DESIGN_VERILOG_DEFINES)
178
        $(Q)echo; echo "\t### Creating software defines header from verilog defines ###";
179 392 julius
        $(Q)echo "//This file is autogenerated from "$<" do not change!" > $@
180
        $(Q)echo "#ifndef _"$(DESIGN_NAME)"_DEFINES_H_" >> $@
181
        $(Q)echo "#define _"$(DESIGN_NAME)"_DEFINES_H_" >> $@
182
        $(Q)cat $< | sed s://.*::g | sed 's/'\`'/'#'/g' >> $@
183
        $(Q)echo "#endif" >> $@
184
        $(Q)echo; echo >> $@
185 349 julius
 
186
# This works (doesn't error), but for now we have to remove all of the numbers
187
# in verilog format, eg. 8'b0010_0000 or 32'h0000_0f00, or 32'd256 etc. as it's
188
# not so straight forward to convert these
189
$(OR1200_PROCESSED_VERILOG_DEFINES): $(OR1200_VERILOG_DEFINES)
190
        $(Q)echo; echo "\t### Creating OR1200 software defines header from verilog defines ###";
191 392 julius
        $(Q)echo "//This file is autogenerated from "$<" do not change!" > $@
192
        $(Q)echo "#ifndef _OR1200_DEFINES_H_" >> $@
193
        $(Q)echo "#define _OR1200_DEFINES_H_" >> $@
194
        $(Q)cat $< | sed s://.*::g | grep -v \'[dhb] | sed 's/'\`'/'#'/g' >> $@
195
        $(Q)echo "#endif" >> $@
196
        $(Q)echo; echo >> $@
197 349 julius
 
198
# Default make
199
%.flashin: %.bin $(UTILS_BIN2HEX)
200 415 julius
        $(Q)$(UTILS_BIN2HEX) $< 1  -size_word -pad $(HEX_IMAGE_PADDING) > $@
201 349 julius
 
202
%.vmem: %.bin $(UTILS_BIN2VMEM)
203
        $(Q)$(UTILS_BIN2VMEM) $< > $@
204
 
205 655 julius
%.flash16: %.bin $(UTILS_BIN2VMEM)
206
        $(Q)$(UTILS_BIN2VMEM) $< -bpw=2 > $@
207
 
208 415 julius
%.elf: %.c $(VECTORS_OBJ) $(ELF_DEPENDS) $(SUPPORT_LIBS)
209
        $(Q)$(OR32_CC) $< $(VECTORS_OBJ) $(ELF_DEPENDS) $(OR32_CFLAGS) \
210
        $(OR32_LDFLAGS) -o $@
211 349 julius
 
212 415 julius
%.elf: %.S $(ELF_DEPENDS) $(SUPPORT_LIBS)
213
        $(Q)$(OR32_CC) $< $(ELF_DEPENDS) $(OR32_CFLAGS) $(OR32_LDFLAGS) -o $@
214 349 julius
 
215 530 julius
%.o: %.S processed-verilog-headers
216 349 julius
        $(Q)$(OR32_CC) $(OR32_CFLAGS) -c $< -o $@
217
 
218 530 julius
%.o: %.c processed-verilog-headers
219 349 julius
        $(Q)$(OR32_CC) $(OR32_CFLAGS) -c $< -o $@
220
 
221 392 julius
COMPILE_SRCS_BASENAMES=$(basename $(COMPILE_SRCS))
222
COMPILE_OBJS=$(COMPILE_SRCS_BASENAMES:%=%.o)
223 349 julius
 
224 392 julius
$(DRIVER_OBJ): $(COMPILE_OBJS)
225
        $(Q)$(OR32_LD) $(OR32_ARFLAGS) $^ -o $@
226
 
227
# Rule to make all necessary driver objects
228
 
229 530 julius
$(ORPSOC_LIB):
230 349 julius
        $(Q)echo; echo "\t### Building software support library ###"; echo
231 392 julius
        $(Q)$(MAKE) -C $(SW_ROOT)/lib liborpsoc.a
232 349 julius
 
233 530 julius
$(VECTORS_OBJ):
234 392 julius
        $(Q)$(MAKE) -C $(CPU_DRIVER) crt0.o
235 349 julius
 
236
 
237 403 julius
# Get a list of the tests
238 408 julius
COMMON_SW_TESTS=$(shell ls $(SW_ROOT)/tests)
239
 
240 403 julius
# A list of the directories in each test directory (not always the same) and
241
# get a list of what's in them.
242 408 julius
SW_TESTS_SUBDIRS=$(shell for test in $(COMMON_SW_TESTS); do ls -d $(SW_ROOT)/tests/$$test/*; done)
243 349 julius
 
244 408 julius
# Add board test paths, if any, to be cleaned too
245
ifdef BOARD_PATH
246
SW_TESTS_SUBDIRS +=$(shell for test in $(BOARD_SW_TESTS); do ls -d $(BOARD_PATH)/sw/tests/$$test/*; done)
247
endif
248
 
249 403 julius
print-sw-tests:
250
        $(Q)echo; echo "\tSoftware tests"; echo;
251 408 julius
        $(Q)echo $(COMMON_SW_TESTS); echo
252
        $(Q)echo; echo "\tSoftware tests in board path (if any)"; echo;
253
        $(Q)echo $(BOARD_SW_TESTS); echo
254 349 julius
 
255 403 julius
print-sw-tests-subdirs:
256
        $(Q)echo; echo "\tSoftware tests subdirs"; echo;
257
        $(Q)echo $(SW_TESTS_SUBDIRS); echo
258
 
259
# This relies on the local clean rule of each makefile
260 449 julius
distclean: clean
261 403 julius
        $(Q)for testssubdir in $(SW_TESTS_SUBDIRS); do $(MAKE) -C $$testssubdir clean; done
262 392 julius
        $(Q)for dir in $(SW_DRIVER_PATHS); do $(MAKE) -C $$dir clean; done
263 397 julius
        $(Q)for dir in `ls $(SW_APPS_PATH)`; do $(MAKE) -C $(SW_ROOT)/apps/$$dir clean; done
264 403 julius
        $(Q)for dir in `ls $(SW_APPS_PATH)`; do $(MAKE) -C $(SW_ROOT)/apps/$$dir clean; done
265 408 julius
        $(Q)$(MAKE) -C $(SW_ROOT)/lib clean
266 479 julius
        $(Q)$(MAKE) -C $(SW_ROOT)/bootrom clean
267 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.