-
Notifications
You must be signed in to change notification settings - Fork 3
/
makefile.lnx
170 lines (134 loc) · 6.43 KB
/
makefile.lnx
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
##########################################################
#
# Copyright (c) 2016 - 2017 Simon Southwell. All rights reserved.
#
# Date: 12th August 2016
#
# Makefile for C 'lnxmico32' instruction set simulator
#
# This file is part of the lnxmico32 instruction set simulator.
#
# lnxmico32 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.
#
# lnxmico32 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 lnxmico32. If not, see <http://www.gnu.org/licenses/>.
#
# $Id: makefile.lnx,v 3.7 2017/07/31 15:44:14 simon Exp $
# $Source: /home/simon/CVS/src/cpu/mico32/makefile.lnx,v $
#
##########################################################
##########################################################
# Definitions
##########################################################
BASENAME=lnxmico32
LIBBASENAME=libmico32
OSTYPE:=$(shell uname -o)
# 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 lm32_cache.cpp
else
TARGET=${BASENAME}
COVEXCL=${TARGET}.cpp lm32_cpu_disassembler.cpp lm32_cpu_c.cpp lm32_get_config.cpp lm32_cache.cpp
endif
LIBTARGET=${LIBBASENAME}.a
LIBSOTARGET=${LIBBASENAME}.so
LIBOBJS=lm32_cpu.o lm32_cpu_inst.o lm32_cpu_disassembler.o lm32_cpu_c.o lm32_cache.o lm32_tlb.o lm32_cpu_elf.o
OBJECTS=${TARGET}.o lm32_get_config.o lnxuart.o lnxtimer.o lm32_gdb.o
LCOVINFO=lm32.info
COVLOGFILE=cov.log
COVDIR=cov_html
SRCDIR=./src
OBJDIR=./obj_lnx
TESTDIR=./test
CC=g++
CC_C=gcc
# Architecture options for external setting (e.g -m32 or -m64)
ARCHOPTS=
# Local options specific to lnxmico32 project
LOCALOPTS=-DLM32_FAST_COMPILE -DLM32_MMU
#LOCALOPTS=
# 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 -DLNXMICO32 -D_GNU_SOURCE
COPTS=-Ofast -fomit-frame-pointer -march=native -D_GNU_SOURCE -DLNXMICO32 ${LOCALOPTS}
else
#COPTS=-g -fPIC -DLNXMICO32
COPTS= -fPIC -Ofast -fomit-frame-pointer -march=native -DLNXMICO32 ${LOCALOPTS} -Wno-format
endif
COVOPTS=
#COVOPTS=-coverage
##########################################################
# Dependency definitions
##########################################################
all : ${TARGET}
${OBJDIR}/${TARGET}.o : ${SRCDIR}/lm32_cpu.h ${SRCDIR}/lm32_cpu_hdr.h ${SRCDIR}/lnxuart.h ${SRCDIR}/lnxtimer.h ${SRCDIR}/lm32_cache.h
${OBJDIR}/lm32_cpu.o : ${SRCDIR}/lm32_cpu.h ${SRCDIR}/lm32_cpu_hdr.h ${SRCDIR}/lm32_cpu_mico32.h ${SRCDIR}/lm32_cache.h
${OBJDIR}/lm32_cpu_inst.o : ${SRCDIR}/lm32_cpu.h ${SRCDIR}/lm32_cpu_hdr.h ${SRCDIR}/lm32_cpu_mico32.h
${OBJDIR}/lm32_cache.o : ${SRCDIR}/lm32_cpu_hdr.h ${SRCDIR}/lm32_cache.h
${OBJDIR}/lm32_tlb.o : ${SRCDIR}/lm32_cpu_hdr.h ${SRCDIR}/lm32_tlb.h
${OBJDIR}/lm32_cpu_disassembler.o : ${SRCDIR}/lm32_cpu.h ${SRCDIR}/lm32_cpu_hdr.h ${SRCDIR}/lm32_cpu_mico32.h
${OBJDIR}/lm32_cpu_c.o : ${SRCDIR}/lm32_cpu.h ${SRCDIR}/lm32_cpu_hdr.h ${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
${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_get_config.o : ${SRCDIR}/lm32_cpu_hdr.h
${OBJDIR}/lnxuart.o : ${SRCDIR}/lm32_cpu.h ${SRCDIR}/lm32_cpu_hdr.h ${SRCDIR}/lm32_cache.h ${SRCDIR}/lnxmico32.h
${OBJDIR}/lnxtimer.o : ${SRCDIR}/lm32_cpu.h ${SRCDIR}/lm32_cpu_hdr.h ${SRCDIR}/lm32_cache.h
##########################################################
# Compilation rules
##########################################################
${TARGET} : ${OBJECTS:%=${OBJDIR}/%} ${LIBTARGET} ${LIBSOTARGET}
@$(CC) ${OBJECTS:%=${OBJDIR}/%} ${LIBTARGET} ${ARCHOPTS} ${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} ${ARCHOPTS} ${COVOPTS} ${LIBOBJS:%=${OBJDIR}/%}
${OBJDIR}/%.o : ${SRCDIR}/%.cpp
@$(CC) ${ARCHOPTS} $(COPTS) ${COVOPTS} -c $< -o $@
${OBJDIR}/%.o : ${SRCDIR}/%.c
@$(CC_C) ${ARCHOPTS} $(COPTS) ${COVOPTS} -c $< -o $@
##########################################################
# 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
##########################################################
# 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:
@/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