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

Subversion Repositories openrisc

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

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