2
#*****************************************************************************
4
# DESCRIPTION: Verilator: Makefile for verilog source
6
# Code available from: http://www.veripool.org/verilator
8
#*****************************************************************************
10
# Copyright 2003-2011 by Wilson Snyder. This program is free software; you can
11
# redistribute it and/or modify it under the terms of either the GNU
12
# Lesser General Public License Version 3 or the Perl Artistic License
15
# Verilator is distributed in the hope that it will be useful,
16
# but WITHOUT ANY WARRANTY; without even the implied warranty of
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
# GNU General Public License for more details.
20
#****************************************************************************/
22
#### Start of system configuration section. ####
24
# Unfortunately configure uses relative paths, and this makefile is called
25
# from a level lower, so we need to move up if it's relative, not if absolute.
26
config_srcdir = @srcdir@
27
ifeq ($(config_srcdir),.)
29
else # Run an experiment
30
ifeq ($(shell -e $(config_srcdir)/../Makefile_obj.in),)
31
srcdir = $(config_srcdir)
33
srcdir = $(config_srcdir)/..
37
incdir = $(srcdir)/../include
38
# Bldsrc may differ from srcdir if configure wan't run from the kit top
52
# Directory in which to install data across multiple architectures
53
datarootdir = @datarootdir@
55
# Directory in which to install package specific files
56
# Generally ${prefix}/share/verilator
57
pkgdatadir = @pkgdatadir@
60
CFG_WITH_DEFENV = @CFG_WITH_DEFENV@
61
CPPFLAGSNOWALL += @CPPFLAGS@
64
#### End of system configuration section. ####
66
VPATH += . $(bldsrc) $(srcdir)
67
TGT = ../../verilator_bin
75
COPT = -ggdb -DVL_DEBUG
83
#CCMALLOC = /usr/local/lib/ccmalloc-gcc.o -lccmalloc -ldl
85
# -lfl not needed as Flex invoked with %nowrap option
88
CPPFLAGSNOWALL += -MMD
89
CPPFLAGSNOWALL += -I. -I$(bldsrc) -I$(srcdir) -I$(incdir)
90
CPPFLAGSNOWALL += -DYYDEBUG # Required to get nice error messages
91
#CPPFLAGSNOWALL += -DVL_LEAK_CHECKS # If running valgrind or other hunting tool
92
CPPFLAGSNOWALL += $(COPT)
93
CPPFLAGS = $(CPPFLAGSNOWALL)
94
ifeq ($(VERILATOR_AUTHOR_SITE),1) # Local... Else don't burden users
95
CPPFLAGSNOWALL += -MP # Only works on recent GCC versions
96
CPPFLAGS += -W -Wall -Wno-unused-parameter -Wno-char-subscripts -Werror
97
#CPPFLAGS += -pedantic-errors
100
ifneq ($(SYSTEMPERL),) # Intuit SYSTEMPERL_INCLUDE as it's new
101
SYSTEMPERL_INCLUDE ?= $(SYSTEMPERL)/src
102
#else if set, leave as-is.
103
#else if SYSTEMPERL="" don't set _INCLUDE so source will figure it out
106
# Allow RPM builds to specify hardcoded data directories
108
ifeq ($(CFG_WITH_DEFENV),yes)
109
CPPFLAGS += -DDEFENV_SYSTEMC=\"$(SYSTEMC)\"
110
CPPFLAGS += -DDEFENV_SYSTEMC_ARCH=\"$(SYSTEMC_ARCH)\"
111
CPPFLAGS += -DDEFENV_SYSTEMPERL=\"$(SYSTEMPERL)\"
112
CPPFLAGS += -DDEFENV_SYSTEMPERL_INCLUDE=\"$(SYSTEMPERL_INCLUDE)\"
113
ifeq ($(VERILATOR_ROOT),) # Use what we're given, or intuit
114
CPPFLAGS += -DDEFENV_VERILATOR_ROOT=\"$(pkgdatadir)\"
116
CPPFLAGS += -DDEFENV_VERILATOR_ROOT=\"$(VERILATOR_ROOT)\"
120
HEADERS = $(wildcard V*.h v*.h)
122
ASTGEN = $(srcdir)/astgen
123
BISONPRE = $(srcdir)/bisonpre
124
FLEXFIX = $(srcdir)/flexfix
126
######################################################################
129
all: make_info $(TGT)
132
@echo " Compile flags: " $(CXX) ${CPPFLAGS}
134
clean mostlyclean distclean maintainer-clean::
135
-rm -f *.o *.d perlxsi.c *_gen_*
137
-rm -f obj_* .objcache*
139
distclean maintainer-clean:: clean
239
# Building with fewer objects to better optimize
240
#OBJS += V3__CONCAT.o
246
V3__CONCAT.cpp: $(addsuffix .cpp, $(basename $(RAW_OBJS)))
247
$(PERL) $(srcdir)/../bin/verilator_includer $^ > $@
249
$(TGT): V3Ast__gen_classes.h $(OBJS)
250
@echo " Linking $@..."
252
${LINK} ${LDFLAGS} -o $@ $(OBJS) $(CCMALLOC) ${LIBS}
253
@-(cp $@.exe $@ || true)
254
# ok if cp failes on linux, it's there to insure executable works on NT
256
V3Number_test: V3Number_test.o
257
${LINK} ${LDFLAGS} -o $@ $^ ${LIBS}
261
%__gen.cpp: %.cpp $(ASTGEN) V3Ast.h V3AstNodes.h
262
$(PERL) $(ASTGEN) -I$(srcdir) $*.cpp
265
$(OBJCACHE) ${CXX} ${CPPFLAGS} -c $<
267
$(OBJCACHE) ${CC} ${CPPFLAGS} -c $<
269
V3ParseLex.o: V3ParseLex.cpp V3Lexer.yy.cpp V3ParseBison.c
270
$(OBJCACHE) ${CXX} ${CPPFLAGSNOWALL} -c $<
272
V3ParseGrammar.o: V3ParseGrammar.cpp V3ParseBison.c
273
$(OBJCACHE) ${CXX} ${CPPFLAGSNOWALL} -c $<
275
V3ParseImp.o: V3ParseImp.cpp V3ParseBison.c
276
$(OBJCACHE) ${CXX} ${CPPFLAGSNOWALL} -c $<
278
V3PreProc.o: V3PreProc.cpp V3PreLex.yy.cpp
279
$(OBJCACHE) ${CXX} ${CPPFLAGSNOWALL} -c $<
283
# Target rule called before parallel build to make generated files
284
serial:: V3Ast__gen_classes.h V3ParseBison.c
286
V3Ast__gen_classes.h : $(ASTGEN) V3Ast.h V3AstNodes.h
287
$(PERL) $(ASTGEN) -I$(srcdir) --classes
289
V3ParseBison.h: V3ParseBison.c
291
# Have only one output file in this rule to prevent parallel make issues
292
V3ParseBison.c: verilog.y $(BISONPRE)
293
@echo "If you get errors from verilog.y below, try upgrading bison to version 1.875 or newer."
294
$(PERL) $(BISONPRE) --yacc ${YACC} -d -v -o V3ParseBison.c $<
296
V3Lexer_pregen.yy.cpp: verilog.l V3ParseBison.h $(HEADERS)
298
${LEX} ${LFLAGS} -o$@ $<
300
V3Lexer.yy.cpp: V3Lexer_pregen.yy.cpp $(FLEXFIX)
301
$(PERL) $(FLEXFIX) V3Lexer <$< >$@
303
V3PreLex_pregen.yy.cpp: V3PreLex.l $(HEADERS)
305
${LEX} ${LFLAGS} -o$@ $<
307
V3PreLex.yy.cpp: V3PreLex_pregen.yy.cpp $(FLEXFIX)
308
$(PERL) $(FLEXFIX) V3PreLex <$< >$@
310
######################################################################
311
######################################################################
313
DEPS := $(wildcard *.d)