-
Notifications
You must be signed in to change notification settings - Fork 3
/
makefile
199 lines (158 loc) · 6.9 KB
/
makefile
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
##########################################################
#
# Copyright (c) 2012 Simon Southwell. All rights reserved.
#
# Date: 9th April 2013
#
# Makefile for C 'cpumico32' instruction set simulator
#
# This file is part of the cpumico32 instruction set simulator.
#
# cpumico32 is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# cpumico32 is distributed in the hope that 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 cpumico32. If not, see <http://www.gnu.org/licenses/>.
#
# $Id: makefile,v 3.7 2017/07/18 09:33:48 simon Exp $
# $Source: /home/simon/CVS/src/cpu/mico32/makefile,v $
#
##########################################################
##########################################################
# Definitions
##########################################################
BASENAME=cpumico32
LIBBASENAME=libmico32
LNXTARGET=lnxmico32
OSTYPE:=$(shell uname -o)
OSTYPE_S:=$(shell uname -s)
# If BUILDC is defined (as something---doesn't matter what), then we're
# doing a build of the C top level program.
ifneq ($(BUILDC),)
TARGET = ${BASENAME}_c
COVEXCL = ${TARGET}.c lm32_cpu_disassembler.cpp lm32_cpu_c.cpp lm32_get_config.cpp
else
TARGET = ${BASENAME}
COVEXCL = ${TARGET}.cpp lm32_cpu_disassembler.cpp lm32_cpu_c.cpp lm32_get_config.cpp
endif
LIBTARGET = ${LIBBASENAME}.a
LIBSOTARGET= ${LIBBASENAME}.so
LIBOBJS = lm32_cpu.o lm32_cpu_inst.o lm32_cpu_elf.o lm32_cpu_disassembler.o lm32_cpu_c.o lm32_cache.o lm32_tlb.o
OBJECTS = ${TARGET}.o lm32_get_config.o lm32_gdb.o
LCOVINFO = lm32.info
COVLOGFILE = cov.log
COVDIR = cov_html
SRCDIR = ./src
OBJDIR = ./obj
TESTDIR = ./test
SIMDIR = ./HDL/test
SYNTHDIR = ./HDL/synth/altera
CC = g++
CC_C = gcc
# GCC in CYGWIN gives tedious warnings that all code is relocatable, and
# so -fPIC not required. So shut it up. Also define _GNU_SOURCE for tty code.
ifeq (${OSTYPE}, Cygwin)
COPTS = -g -D_GNU_SOURCE -DLM32_MMU
else
COPTS = -g -fPIC -DLM32_MMU -Wno-format
endif
ifeq (${OSTYPE_S},windows32)
TGTDIR = ../../../msvc/Release
else
TGTDIR = ../../../
endif
COVOPTS=
#COVOPTS=-coverage
.SILENT:
##########################################################
# Dependency definitions
##########################################################
all : ${TARGET} ${LNXTARGET}
${OBJDIR}/${TARGET}.o : ${SRCDIR}/lm32_cpu.h ${SRCDIR}/lm32_cpu_hdr.h
${OBJDIR}/lm32_cpu.o : ${SRCDIR}/lm32_cpu.h ${SRCDIR}/lm32_cpu_hdr.h ${SRCDIR}/lm32_cpu_mico32.h ${SRCDIR}/lm32_cpu_elf.h ${SRCDIR}/lm32_cache.h ${SRCDIR}/lm32_cpu.cpp
${OBJDIR}/lm32_cpu_elf.o : ${SRCDIR}/lm32_cpu.h ${SRCDIR}/lm32_cpu_hdr.h ${SRCDIR}/lm32_cpu_mico32.h ${SRCDIR}/lm32_cpu_elf.cpp ${SRCDIR}/lm32_cpu_elf.h
${OBJDIR}/lm32_cpu_inst.o : ${SRCDIR}/lm32_cpu.h ${SRCDIR}/lm32_cpu_hdr.h ${SRCDIR}/lm32_cpu_mico32.h ${SRCDIR}/lm32_cpu_inst.cpp
${OBJDIR}/lm32_cache.o : ${SRCDIR}/lm32_cpu_hdr.h ${SRCDIR}/lm32_cache.cpp ${SRCDIR}/lm32_cache.h
${OBJDIR}/lm32_tlb.o : ${SRCDIR}/lm32_cpu_hdr.h ${SRCDIR}/lm32_tlb.cpp ${SRCDIR}/lm32_tlb.h
${OBJDIR}/lm32_cpu_disassembler.o : ${SRCDIR}/lm32_cpu.h ${SRCDIR}/lm32_cpu_hdr.h ${SRCDIR}/lm32_cpu_mico32.h ${SRCDIR}/lm32_cpu_disassembler.cpp
${OBJDIR}/lm32_cpu_c.o : ${SRCDIR}/lm32_cpu.h ${SRCDIR}/lm32_cpu_hdr.h ${SRCDIR}/lm32_cpu.h ${SRCDIR}/lm32_cpu_c.cpp ${SRCDIR}/lm32_cpu_c.h
${OBJDIR}/lm32_gdb.o : ${SRCDIR}/lm32_cpu.h ${SRCDIR}/lm32_cpu_hdr.h ${SRCDIR}/lm32_gdb.cpp ${SRCDIR}/lm32_gdb.h
##########################################################
# Compilation rules
##########################################################
ifeq ($(OSTYPE_S),windows32)
${TARGET}:
runmsbuild.bat ${BASENAME}
else
${TARGET} : ${OBJECTS:%=${OBJDIR}/%} ${LIBTARGET} ${LIBSOTARGET}
@$(CC) ${OBJECTS:%=${OBJDIR}/%} ${LIBTARGET} ${ARCHOPT} ${COVOPTS} ${LDOPTS} -o ${TARGET}
${LIBTARGET}: ${LIBOBJS:%=${OBJDIR}/%}
@rm -f ${LIBTARGET}
@ar rcs $@ ${LIBOBJS:%=${OBJDIR}/%}
${LIBSOTARGET}: ${LIBOBJS:%=${OBJDIR}/%}
@rm -f ${LIBSOTARGET}
@$(CC) -shared -Wl,-soname,${LIBSOTARGET} -o ${LIBSOTARGET} ${COVOPTS} ${LIBOBJS:%=${OBJDIR}/%}
${OBJDIR}/%.o : ${SRCDIR}/%.cpp
@$(CC) ${ARCHOPT} $(COPTS) ${COVOPTS} -c $< -o $@
${OBJDIR}/%.o : ${SRCDIR}/%.c
@$(CC_C) ${ARCHOPT} $(COPTS) ${COVOPTS} -c $< -o $@
endif
${LNXTARGET}:
@make -f makefile.lnx
##########################################################
# Microsoft Visual C++ 2010
##########################################################
MSVCDIR=./msvc
MSVCCONF="Release"
mscv_dummy:
MSVC: mscv_dummy
@MSBuild.exe ${MSVCDIR}/${BASENAME}.sln /nologo /v:q /p:Configuration=${MSVCCONF} /p:OutDir='..\..\'
@rm -f *.pdb *.ilk
##########################################################
# Test
##########################################################
.PHONY: test sim hwtest
# Rule for running tests on the model
test: ${TARGET}
@cd ${TESTDIR}; ./runtest.py -e ${TGTDIR}/${TARGET}
# Rule for running tests on the simulation
sim:
@make -C ${SIMDIR} regression
# Rule for running tests on the hardware
hwtest:
@make -C ${SYNTHDIR} regression
# Rule to run all tests
alltest: test sim hwtest
##########################################################
# coverage
##########################################################
coverage:
@lcov -c -d ${OBJDIR} -o ${LCOVINFO} > ${COVLOGFILE}
@lcov -r ${LCOVINFO} ${COVEXCL} -o ${LCOVINFO} >> ${COVLOGFILE}
@genhtml -o ${COVDIR} ${LCOVINFO} >> ${COVLOGFILE}
##########################################################
# Clean up rules
##########################################################
clean:
@make -f makefile.lnx clean
@if [ -d ${SIMDIR} ]; then make -C ${SIMDIR} clean; fi
@/bin/rm -rf ${TARGET} ${LIBTARGET} ${LIBSOTARGET} \
${OBJDIR}/*.o ${OBJDIR}/*.gc* ${TESTDIR}/instructions/*/test.o \
${TESTDIR}/instructions/*/test.elf ${COVDIR} *.info
cleanmsvc:
@/bin/rm -rf *.pdb ${MSVCDIR}/*.sdf ${MSVCDIR}/*.suo ${LIBBASENAME}.dll \
${MSVCDIR}/Debug ${MSVCDIR}/Release ${MSVCDIR}/ipch \
${MSVCDIR}/${BASENAME}/Debug \
${MSVCDIR}/${BASENAME}/release \
${MSVCDIR}/${LIBBASENAME}/*.vcxproj.user \
${MSVCDIR}/${LIBBASENAME}/Debug \
${MSVCDIR}/${LIBBASENAME}/release
sparkle: clean cleanmsvc
@/bin/rm -f *.exe *.log