2018-07-26 12:28:21 -05:00
################################ MAKEFILE OPTIONS ####################################
# If ENABLE_GRAPHICS is set to true, VPR requires X11 to compile.
# On Ubuntu, type 'make packages' or
# 'sudo apt-get install libx11-dev' to install.
# Please look online for information on how to install X11 on other Linux distributions.
# Please note that a Mac can run the graphics if the X11 library is installed.
2019-04-26 13:23:47 -05:00
ENABLE_GRAPHICS = false
2018-07-26 12:28:21 -05:00
# can be true or false
export BUILD_TYPE = debug
# can be debug or release - this option gets inherited by the library libarchfpga
# by default, though libarchfpga's build type can be set independently in libarchfpga's Makefile.
COMPILER = g++
OPTIMIZATION_LEVEL_FOR_RELEASE_BUILD = -O3
# can be -O0 (no optimization) to -O3 (full optimization), or -Os (optimize space)
#############################################################################################
CC = $( COMPILER)
LIB_DIR = -L.
2019-04-26 13:23:47 -05:00
LIB = -lm -lvpr -lreadline
SHELL_LIB = -lm -lvpr_shell -lreadline
FPGA_SPICE_SRC_DIR = SRC/fpga_x2p
2018-07-26 12:28:21 -05:00
SRC_DIR = SRC
OBJ_DIR = OBJ
2019-05-03 12:48:41 -05:00
OTHER_DIR = -ISRC/util -ISRC/timing -ISRC/pack -ISRC/place -ISRC/base -ISRC/route -ISRC/power -ISRC/mrfpga -ISRC/fpga_spice -I$( FPGA_SPICE_SRC_DIR) /base -I$( FPGA_SPICE_SRC_DIR) /bitstream -I$( FPGA_SPICE_SRC_DIR) /bitstream -I$( FPGA_SPICE_SRC_DIR) /clb_pin_remap -I$( FPGA_SPICE_SRC_DIR) /spice -I$( FPGA_SPICE_SRC_DIR) /verilog -I$( FPGA_SPICE_SRC_DIR) /router -I../libarchfpga/SRC -I../libprinthandler/SRC/TIO_InputOutputHandlers -I$( FPGA_SPICE_SRC_DIR) /shell
2018-07-26 12:28:21 -05:00
WARN_FLAGS = -Wall -Wpointer-arith -Wcast-qual -D__USE_FIXED_PROTOTYPES__ -ansi -pedantic -Wshadow -Wcast-align -D_POSIX_SOURCE -Wno-write-strings
DEBUG_FLAGS = -g
OPT_FLAGS = $( OPTIMIZATION_LEVEL_FOR_RELEASE_BUILD)
2019-05-03 12:48:41 -05:00
INC_FLAGS = -I../libarchfpga/SRC/include -I../libarchfpga/SRC/fpga_spice_include
2018-07-26 12:28:21 -05:00
FLAGS = $( INC_FLAGS) $( WARN_FLAGS) -D EZXML_NOMMAP -D_POSIX_C_SOURCE
UNAME := $( shell uname)
# determine build env
i f e q ( $( UNAME ) , D a r w i n )
MAC_OS = true
e l s e
MAC_OS = false
e n d i f
i f n e q ( , $( findstring release , $ ( BUILD_TYPE ) ) )
FLAGS := $( FLAGS) $( OPT_FLAGS)
e l s e # DEBUG build
FLAGS := $( FLAGS) $( DEBUG_FLAGS)
e n d i f
i f n e q ( , $( findstring true , $ ( ENABLE_GRAPHICS ) ) )
# The following block defines the X11 directories. If X11 library
# is located elsewhere, change it here.
ifneq ( ,$( findstring true, $( MAC_OS) ) )
LIB_DIR := $( LIB_DIR) -L/usr/X11/lib
INC_FLAGS := $( INC_FLAGS) -I/opt/X11/include
else
LIB_DIR := $( LIB_DIR) -L/usr/lib/X11
PACKAGEINSTALL := if cat /etc/issue | grep Ubuntu -c >>/dev/null; then if ! dpkg -l | grep libx11-dev -c >>/dev/null; then sudo apt-get install libx11-dev; fi ; fi
PACKAGENOTIFICATION := if cat /etc/issue | grep Ubuntu -c >>/dev/null; then if ! dpkg -l | grep libx11-dev -c >>/dev/null; then echo "\n\n\n\n*****************************************************\n* VPR has detected that graphics are enabled, *\n* but the required graphics package libx11-dev *\n* is missing. Try: *\n* a) Type 'make packages' to install libx11-dev *\n* automatically if not already installed. *\n* b) Type 'sudo apt-get install libx11-dev' to *\n* install manually. *\n* c) If libx11-dev is installed, point the Makefile *\n* to where your X11 libraries are installed. *\n* d) If you wish to run VPR without graphics, set *\n* the flag ENABLE_GRAPHICS = false at the top *\n* of the Makefile in VPR's parent directory. *\n*****************************************************\n\n\n\n" ; fi ; fi
endif
LIB := $( LIB) -lX11
e l s e
FLAGS := $( FLAGS) -DNO_GRAPHICS
e n d i f
EXE = vpr
2018-09-04 18:31:30 -05:00
OBJ = $( patsubst $( SRC_DIR) /%.c, $( OBJ_DIR) /%.o,$( wildcard $( SRC_DIR) /*.c $( SRC_DIR) /*/*.c $( FPGA_SPICE_SRC_DIR) /*/*.c) )
2018-07-26 12:28:21 -05:00
OBJ_DIRS = $( sort $( dir $( OBJ) ) )
DEP := $( OBJ:.o= .d)
# notify is an order-only prerequisite - note the "|"
$(EXE) : $( OBJ ) Makefile libvpr .a | notify
$( CC) $( FLAGS) OBJ/main.o -o $( EXE) $( LIB_DIR) $( LIB)
2019-04-26 13:23:47 -05:00
SHELL_EXE = vpr_shell
# cmd-shell interface main
$(SHELL_EXE) : $( OBJ ) Makefile libvpr_shell .a | notify
$( CC) $( FLAGS) OBJ/shell_main.o -o $( SHELL_EXE) $( LIB_DIR) $( SHELL_LIB)
2018-07-26 12:28:21 -05:00
# if graphics enabled but libx11-dev is not installed, notify the user
notify :
@ $( PACKAGENOTIFICATION)
#if graphics enabled but libx11-dev is not installed, install it
packages :
@ $( PACKAGEINSTALL)
libarchfpga :
@ cd ../libarchfpga && make
libvpr.a : $( OBJ ) Makefile libarchfpga
@ cp ../libarchfpga/libarchfpga.a $@
@ ar rcs $@ $( OBJ)
@ ar d $@ main.o
2019-04-26 13:23:47 -05:00
libvpr_shell.a : $( OBJ ) Makefile libarchfpga
@ cp ../libarchfpga/libarchfpga.a $@
@ ar rcs $@ $( OBJ)
@ ar d $@ shell_main.o
2018-07-26 12:28:21 -05:00
# Enable a second round of expansion so that we may include
# the target directory as a prerequisite of the object file.
.SECONDEXPANSION :
# The directory follows a "|" to use an existence check instead of the usual
# timestamp check. Every write to the directory updates the timestamp thus
# without this, all but the last file written to a directory would appear
# to be out of date.
2019-05-04 00:03:04 -05:00
$(OBJ) : $( OBJ_DIR ) /%.o :$( SRC_DIR ) /%.c | $$( dir $ $ @D )
2018-07-26 12:28:21 -05:00
$( CC) $( FLAGS) -MD -MP -I$( OTHER_DIR) -ISRC/util -c $< -o $@
# Silently create target directories as need
$(OBJ_DIRS) :
@ mkdir -p $@
- i n c l u d e $( DEP )
2019-04-26 13:23:47 -05:00
.PHONY : all vpr shell_vpr
all : $( EXE ) $( SHELL_EXE )
vpr : $( EXE )
shell_vpr : $( SHELL_EXE )
2018-07-26 12:28:21 -05:00
clean :
2019-04-26 13:23:47 -05:00
rm -f $( SHELL_EXE) $( EXE) $( OBJ) $( DEP) libvpr.a libvpr_shell.a
2018-07-26 12:28:21 -05:00
cd ../libarchfpga && make clean
clean_coverage : clean
rm -rf ./usr
find ./OBJ -regex ".*.\(gcda\|gcno\)" -exec rm -f { } \;
rm -f *.html
find ./SRC -iname "*.html" -exec rm -f { } \;
ctags :
cd $( SRC_DIR) && ctags *.[ ch]
# This is using Target-specific variable values. See: http://www.gnu.org/software/make/manual/make.html#Target_002dspecific
coverage : FLAGS = $( DEBUG_FLAGS ) $( INC_FLAGS ) -pedantic -D EZXML_NOMMAP -fprofile -arcs -ftest -coverage -lgcov
coverage : $( EXE )
./coverage_reset.sh