For loop in cli batch - for-loop

I've a bunch of videos that I need to batch remux with MKVtoolnix using cmd. For that I'm using this cmd. I'm not aware of how to run this cmd in loop.
This is the cmd:
"C:\Program Files\MKVToolNix\mkvmerge.exe" --ui-language en --output ^"E:\Output\Video - 001.mkv^" --language 0:mul --track-name ^"0:Video - 001^" --display-dimensions 0:768x576 --language 1:hi --track-name ^"1:Video - 001^" --language 2:ta --track-name ^"2:Video - 001^" --default-track-flag 2:yes --language 3:te --track-name ^"3:Video - 001^" ^"^(^" ^"E:\Batch\Video - 001.mkv^" ^"^)^" --attachment-name cover_small.jpg --attachment-mime-type image/jpeg --attach-file ^"E:\cover\cover_small.jpg^" --attachment-name cover.jpg --attachment-mime-type image/jpeg --attach-file ^"E:\cover\cover.jpg^" --attachment-name cover_land.jpg --attachment-mime-type image/jpeg --attach-file ^"E:\cover\cover_land.jpg^" --title ^"Video - 001^" --track-order 0:0,0:2,0:3,0:1
As of now I'm doing like this
"C:\Program Files\MKVToolNix\mkvmerge.exe" --ui-language en --output ^"E:\Output\Video - 001.mkv^" --language 0:mul --track-name ^"0:Video - 001^" --display-dimensions 0:768x576 --language 1:hi --track-name ^"1:Video - 001^" --language 2:ta --track-name ^"2:Video - 001^" --default-track-flag 2:yes --language 3:te --track-name ^"3:Video - 001^" ^"^(^" ^"E:\Batch\Video - 001.mkv^" ^"^)^" --attachment-name cover_small.jpg --attachment-mime-type image/jpeg --attach-file ^"E:\cover\cover_small.jpg^" --attachment-name cover.jpg --attachment-mime-type image/jpeg --attach-file ^"E:\cover\cover.jpg^" --attachment-name cover_land.jpg --attachment-mime-type image/jpeg --attach-file ^"E:\cover\cover_land.jpg^" --title ^"Video - 001^" --track-order 0:0,0:2,0:3,0:1
"C:\Program Files\MKVToolNix\mkvmerge.exe" --ui-language en --output ^"E:\Output\Video - 002.mkv^" --language 0:mul --track-name ^"0:Video - 002^" --display-dimensions 0:768x576 --language 1:hi --track-name ^"1:Video - 002^" --language 2:ta --track-name ^"2:Video - 002^" --default-track-flag 2:yes --language 3:te --track-name ^"3:Video - 002^" ^"^(^" ^"E:\Batch\Video - 002.mkv^" ^"^)^" --attachment-name cover_small.jpg --attachment-mime-type image/jpeg --attach-file ^"E:\cover\cover_small.jpg^" --attachment-name cover.jpg --attachment-mime-type image/jpeg --attach-file ^"E:\cover\cover.jpg^" --attachment-name cover_land.jpg --attachment-mime-type image/jpeg --attach-file ^"E:\cover\cover_land.jpg^" --title ^"Video - 002^" --track-order 0:0,0:2,0:3,0:1
.....etc
I need to run this command in a loop for n times

set /a serial=1000
:again
set /a serial+=1
"C:\Program Files\MKVToolNix\mkvmerge.exe" ...
if %serial% leq 1234 goto again
Then replace each 001 in your mkvmerge.exe line with %serial:~-3% which will then execute mkvmerge.exe with the last 3 digits of the serial number.
The loop will execute 234 times with 1234 set as the limit, 001..234.
Here's the actual test file I created
#ECHO OFF
SETLOCAL
set /a serial=1000
:again
set /a serial+=1
ECHO "C:\Program Files\MKVToolNix\mkvmerge.exe" --ui-language en --output ^"E:\Output\Video - %serial:~-3%.mkv^"
if %serial% leq 1010 goto again
ECHO done...
GOTO :EOF
The first two lines simply suppress command-echoing and establish a local environment so that changes will be discarded when the batch terminates.
I truncated the mkvmerge line as the remainder should be more of the same, and echoed it since executing it makes no sense on my system.
Without the echo, the mkvmerge should run.
This is the output I obtained.
"C:\Program Files\MKVToolNix\mkvmerge.exe" --ui-language en --output "E:\Output\Video - 001.mkv"
"C:\Program Files\MKVToolNix\mkvmerge.exe" --ui-language en --output "E:\Output\Video - 002.mkv"
"C:\Program Files\MKVToolNix\mkvmerge.exe" --ui-language en --output "E:\Output\Video - 003.mkv"
"C:\Program Files\MKVToolNix\mkvmerge.exe" --ui-language en --output "E:\Output\Video - 004.mkv"
"C:\Program Files\MKVToolNix\mkvmerge.exe" --ui-language en --output "E:\Output\Video - 005.mkv"
"C:\Program Files\MKVToolNix\mkvmerge.exe" --ui-language en --output "E:\Output\Video - 006.mkv"
"C:\Program Files\MKVToolNix\mkvmerge.exe" --ui-language en --output "E:\Output\Video - 007.mkv"
"C:\Program Files\MKVToolNix\mkvmerge.exe" --ui-language en --output "E:\Output\Video - 008.mkv"
"C:\Program Files\MKVToolNix\mkvmerge.exe" --ui-language en --output "E:\Output\Video - 009.mkv"
"C:\Program Files\MKVToolNix\mkvmerge.exe" --ui-language en --output "E:\Output\Video - 010.mkv"
"C:\Program Files\MKVToolNix\mkvmerge.exe" --ui-language en --output "E:\Output\Video - 011.mkv"
done...

Related

How to avoid running all targets every time a makefile is run?

How can I avoid rebuilding of targets every time even though there are no changes to them? I have looked at these answers: answer1, answer2, answer3, but I still could not solve my problem. I think I understand conceptually why this problem occurs. It is just that I was unable to apply the solutions to my case.
Here is my makefile:
.PHONY: all dircreate dircreate_sub
# Create shortcuts to directories ##############################################
DAT4 = data/4-Year/
RES4 = data/results/4-Year/
FIG4 = figures/4-Year/
DAT2 = data/2-Year/
RES2 = data/results/2-Year/
FIG2 = figures/2-Year/
DEPVARS = \
ret.1st.2nd.term.left \
ret.1st.2nd.year.left \
ret.1st.7th.year.grad \
ret.1st.5th.year.grad
# Create directories ###########################################################
dircreate:
mkdir -p \
data/ \
data/4-Year/ \
data/2-Year/ \
data/results/ \
data/results/4-Year \
data/results/2-Year \
figures/ \
figures/4-Year/ \
figures/2-Year/
dircreate_sub:
for d in $(DEPVARS); do \
mkdir -p data/4-Year/$$d ; \
mkdir -p data/2-Year/$$d ; \
mkdir -p data/results/4-Year/$$d ; \
mkdir -p data/results/2-Year/$$d ; \
mkdir -p figures/4-Year/$$d ; \
mkdir -p figures/2-Year/$$d ; \
done;
#TARGETS_DATAPREP := \
#$(foreach dat, $(DAT4) $(DAT2), $\
# $(foreach filename, \
# train_index_outer.RDS \
# train_outer.RDS \
# train_inter_outer.RDS, $\
# $(foreach depvar, $(DEPVARS),$(dat)$(depvar)/$(filename))))
# Data prep:####################################################################
TARGETS_DATAPREP := \
$(foreach filename, $\
train_index_outer.RDS \
train_outer.RDS \
train_inter_outer.RDS \
entire_data.RDS \
entire_inter_data.RDS, $\
$(foreach depvar, $(DEPVARS),$(DAT4)$(depvar)/$(filename)))
$(TARGETS_DATAPREP): \
dataprep.R \
funcs.R \
../core/data/analysis.data.RDS
Rscript $<
# benchmark:####################################################################
DEPENDENCIES_BENCHMARK := \
$(foreach filename, $\
train_index_outer.RDS \
train_outer.RDS \
train_inter_outer.RDS \
entire_data.RDS \
entire_inter_data.RDS, $\
$(foreach depvar, $(DEPVARS),$(DAT4)$(depvar)/$(filename)))
TARGETS_BENCHMARK := \
$(foreach filename, $\
logreg_inner.RDS \
l1logreg_inner.RDS \
l1logreg.int_inner.RDS \
rf_inner.RDS \
xgb_inner.RDS \
logreg_outer.RDS \
l1logreg_outer.RDS \
l1logreg.int_outer.RDS \
rf_outer.RDS \
xgb_outer.RDS, $\
$(foreach depvar, $(DEPVARS),$(RES4)$(depvar)/$(filename)))
$(TARGETS_BENCHMARK): \
benchmark.R \
funcs.R \
$(DEPENDENCIES_BENCHMARK)
Rscript $<
# Process:######################################################################
TARGETS_PROCESS := \
$(foreach filename, $\
processed_inner.RDS \
processed_inner_outer.RDS, $\
$(foreach depvar, $(DEPVARS),$(RES4)$(depvar)/$(filename)))
$(TARGETS_PROCESS): \
process.R \
funcs.R \
$(TARGETS_BENCHMARK)
Rscript $<
# Graphs:#######################################################################
TARGETS_GRAPHS := \
$(foreach filename, $\
ave_auc_inner.png \
ave_ppv10_inner.png \
dist_auc_inner.png \
dist_ppv10_inner.png \
roc_inner.png \
ave_auc_outer.png \
ave_ppv10_outer.png \
dist_auc_outer.png \
dist_ppv10_outer.png \
roc_outer.png \
ave_auc_ppv10_inner_outer.png \
roc_inner_outer.png \
thresh_inner_outer.png, $\
$(foreach depvar, $(DEPVARS),$(FIG4)$(depvar)/$(filename)))
$(TARGETS_GRAPHS): \
graphs.R \
funcs.R \
$(TARGETS_PROCESS)
Rscript $<
# Make all
all: $(TARGETS_PROCESS)
So, the make -nd tells me dircreate needs to be remade every time. That's why I also tried adding a variable called, say, OUTDIRS and also created a rule for it. So, instead of dircreate, I added this bit:
OUTDIRS: $(DAT4) $(RES4) $(FIG4) $(DAT2) $(RES2) $(FIG2)
OUTDIRS := \
for d in $(DEPVARS); do \
$(DAT4)$$d ; \
$(DAT2)$$d ; \
$(RES4)$$d ; \
$(RES2)$$d ; \
$(FIG4)$$d ; \
$(FIG2)$$d ; \
done;
$(OUTDIRS):
mkdir -p $#
But, this time I get a missing separator error at $(OUTDIRS): mkdir -p $#, which, I know, is unrelated to the main question, but I am wondering if the way I am going about is at least on the right track?
Suppose you have
DIRS := 2-Year 4-Year
DEPVARS := term year
and you want to construct:
2-Year/term 2-Year/year 4-Year/term 4-Year/year
You can do it this way:
OUTDIRS := $(foreach d,$(DIRS),$(addprefix $(d)/,$(DEPVARS)))
And once you have that working you can abstract it into a function:
Multiply= $(foreach d,$(1),$(addprefix $(d)/,$(2)))
OUTDIRS:=$(call Multiply, $(DIRS), $(DEPVARS))
And one you have that working you can use it to construct those trees of yours:
DIRS := data data/results figures
DIRS := $(DIRS) $(call Multiply, $(DIRS), 4-Year 2-Year)
DEPVARS := $(addprefix ret.1st., 2nd.term.left 2nd.year.left 7th.year.grad 5th.year.grad)
OUTDIRS:=$(call Multiply, $(DIRS), $(DEPVARS))
$(OUTDIRS):
mkdir -p $#
Note that if you want Make to create whichever of those directories don't exist, you must add another rule before the $(OUTDIRS) rule:
.PHONY: all-dirs
all-dirs: $(OUTDIRS)

Compilation error GNU Fortran - finalization

I am trying to compile a large code in using GNU compiler.
However, when I try to compile the attached piece of code with GNU Fortran (GCC) 6.1.0, some routines using type fn_grid_nodes_t throw this error message:
#bld .. linking, ...
Undefined symbols for architecture x86_64:
"___final_fn_core_grids_dts_Fn_grid_nodes_t.3665", referenced from:
___fn_depot_utils_MOD_fn_clean_depot in fn_depot_utils.o
Note that using Intel compiler > 15.0, the compilation is successful.
I suspect it is due to how GNU and Intel handle finalization.
Does anyone have any suggestion/workaround about this?
type :: fn_grid_nodes_t
! mpi communicator
type(fmpi_fcomm_t) :: fcomm
! grid description
type(fn_grid_descrp_t) :: grid_descrp
! grid partition description
type(fn_parts_descrp_t) :: parts_descrp
! node hdr plan
type(fn_node_hdr_plan_t) :: node_hdr_plan
! node elem plan
type(fn_node_elem_plan_t) :: node_elem_plan
! exchanger
type(fn_exchr_t) :: exchr_nghb
! active node count
integer(kp_i) :: active_ncnt = -1_kp_i
! dynamic node array
type(fn_node_t),allocatable :: nodes(:)
! auxiliary
real(kp_r),allocatable :: aux_block(:,:,:,:)
end type fn_grid_nodes_t
Thanks for your answers - some additional details:
OS = MacOS Sierra 10.12.1
Compilation: Makefile
Flags: -g -Wall -Wextra -fbacktrace -fbounds-check -fcheck-array-temporaries
Optimization: -O2
Example of compilation of the module:
# FORCE DEPENDECY BETWEEN MODULE AND OBJECT FILES:
$(INCLUDE_DIR)/fn_core_grids_dts.mod \
: $(OBJ_DIR)/fn_core_grids_dts.o
#printf "$(MK_DECOR_BLD) .. build assumed, <$(MK_COLOR_PURPLE)$#$(MK_COLOR_NORMAL)> <-- <$(MK_COLOR_PURPLE)$<$(MK_COLOR_NORMAL)> ... "
#set -e; \
$(MK_COLOR_CMD_SET_RED); \
_tic=$$($(DATE_EPOCH_SEC)); \
$(TOUCH) $#; \
_toc=$$($(DATE_EPOCH_SEC)); \
$(MK_COLOR_CMD_SET_NORMAL); \
printf "[$(MK_COLOR_BLUE)%3.3ds$(MK_COLOR_NORMAL)]" $$(( $$_toc - $$_tic ))
#printf "$(MK_DECOR_OK)\n"
# COMPILE MODULE:
$(OBJ_DIR)/fn_core_grids_dts.o \
: .concoct/fnode-3d/drv/./src/core/grids/write_fn_core_grids_dts/fn_core_grids_dts.f90 \
$(INCLUDE_DIR)/fn_core_nodes_dts.mod \
$(INCLUDE_DIR)/fn_infix_fmpi.mod \
$(INCLUDE_DIR)/fn_core_grids_common.mod \
$(INCLUDE_DIR)/fn_core_exchangers_dts.mod
#printf "$(MK_DECOR_BLD) .. compiling <$(MK_COLOR_YELLOW)$#$(MK_COLOR_NORMAL)> ... "
#set -e; \
$(MK_COLOR_CMD_SET_RED); \
_tic=$$($(DATE_EPOCH_SEC)); \
$(MKDIRP) $(OBJ_DIR) $(INCLUDE_DIR); \
$(FC) -c $< -o $# $(FCFLAGS) $(FCFT_DIRSRCH_MOD) $(INCLUDE_DIR) $(addprefix $(FCFT_DIRSRCH_INCLUDE),$(wildcard $(IDIRS) $(PREPROC_DIR))); \
$(TOUCH) $#; \
_toc=$$($(DATE_EPOCH_SEC)); \
$(MK_COLOR_CMD_SET_NORMAL); \
printf "[$(MK_COLOR_BLUE)%3.3ds$(MK_COLOR_NORMAL)]" $$(( $$_toc - $$_tic ))
#printf "$(MK_DECOR_OK)\n"
Portion of makefile causing the issue:
# FORCE DEPENDECY BETWEEN MODULE AND OBJECT FILES:
$(INCLUDE_DIR)/fn_depot_utils.mod \
: $(OBJ_DIR)/fn_depot_utils.o
#printf "$(MK_DECOR_BLD) .. build assumed, <$(MK_COLOR_PURPLE)$#$(MK_COLOR_NORMAL)> <-- <$(MK_COLOR_PURPLE)$<$(MK_COLOR_NORMAL)> ... "
#set -e; \
$(MK_COLOR_CMD_SET_RED); \
_tic=$$($(DATE_EPOCH_SEC)); \
$(TOUCH) $#; \
_toc=$$($(DATE_EPOCH_SEC)); \
$(MK_COLOR_CMD_SET_NORMAL); \
printf "[$(MK_COLOR_BLUE)%3.3ds$(MK_COLOR_NORMAL)]" $$(( $$_toc - $$_tic ))
#printf "$(MK_DECOR_OK)\n"
# COMPILE MODULE:
$(OBJ_DIR)/fn_depot_utils.o \
: .concoct/fnode-3d/drv/./src/depot/write_fn_depot_utils/fn_depot_utils.f90 \
$(INCLUDE_DIR)/fn_depot_common.mod \
$(INCLUDE_DIR)/fn_depot_share.mod
#printf "$(MK_DECOR_BLD) .. compiling <$(MK_COLOR_YELLOW)$#$(MK_COLOR_NORMAL)> ... "
#set -e; \
$(MK_COLOR_CMD_SET_RED); \
_tic=$$($(DATE_EPOCH_SEC)); \
$(MKDIRP) $(OBJ_DIR) $(INCLUDE_DIR); \
$(FC) -c $< -o $# $(FCFLAGS) $(FCFT_DIRSRCH_MOD) $(INCLUDE_DIR) $(addprefix $(FCFT_DIRSRCH_INCLUDE),$(wildcard $(IDIRS) $(PREPROC_DIR))); \
$(TOUCH) $#; \
_toc=$$($(DATE_EPOCH_SEC)); \
$(MK_COLOR_CMD_SET_NORMAL); \
printf "[$(MK_COLOR_BLUE)%3.3ds$(MK_COLOR_NORMAL)]" $$(( $$_toc - $$_tic ))
#printf "$(MK_DECOR_OK)\n"
Note that fn_depot_common.mod includes module fn_core_grids_dts.
It is definitely not an issue related to a missing module not being included where needed.

check variable is empty before add into dependency

below code from AOSP build/core/Makefile
If someone set INSTALLED_RAMDISK_TARGET as empty(by accident) then recoveryimage will have no RAMDISK
How can I check if each of the dependencies is empty or not?
or is there any other suggestion?
1016 $(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
1017 $(INSTALLED_RAMDISK_TARGET) \
1018 $(INSTALLED_BOOTIMAGE_TARGET) \
1019 $(INTERNAL_RECOVERYIMAGE_FILES) \
1020 $(recovery_initrc) $(recovery_sepolicy) $(recovery_kernel) \
1021 $(INSTALLED_2NDBOOTLOADER_TARGET) \
1022 $(recovery_build_prop) $(recovery_resource_deps) \
1023 $(recovery_fstab) \
1024 $(RECOVERY_INSTALL_OTA_KEYS)
1025 $(call build-recoveryimage-target, $#)
I tried below method but in vain because foreach will skip variable which is empty
1016 RECOVERYIMAGE_REQUIRED := $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
1017 $(INSTALLED_RAMDISK_TARGET) \
1018 $(INSTALLED_BOOTIMAGE_TARGET) \
1019 $(INTERNAL_RECOVERYIMAGE_FILES) \
1020 $(recovery_initrc) $(recovery_sepolicy) $(recovery_kernel) \
1021 $(INSTALLED_2NDBOOTLOADER_TARGET) \
1022 $(recovery_build_prop) $(recovery_resource_deps) \
1023 $(recovery_fstab) \
1024 $(RECOVERY_INSTALL_OTA_KEYS)
1025 $(call build-recoveryimage-target, $#)
1026 $(foreach item,$(HOSDIMAGE_REQUIRED), \
1027 $(eval _item := $(strip $(item))) \
1028 $(if $(_item),$(info $(_item) checked),$(error dependency is empty)) \
1029 )
1030 $(INSTALLED_RECOVERYIMAGE_TARGET): $(RECOVERYIMAGE_REQUIRED)
Oh how I wish for a --error-undefined-variables to match the existing --warn-undefined-variables. In the mean time you can just use something like:
depvarnames := \
MKBOOTFS \
MKBOOTIMG \
MINIGZIP \
⋮
deps := $(foreach _,${depvarnames},$(or $_,$(error $$$_ is empty!)))
${INSTALLED_RECOVERYIMAGE_TARGET}: ${deps}
recipe
⋮
below is my solution, looks stupid but it really help me a lot
NULL :=
SPACE := $(NULL) $(NULL)
DQUOTE = "
RECOVERYIMAGE_REQUIRED := \
"$(MKBOOTFS)" \
"$(MKBOOTIMG)" \
"$(MINIGZIP)" \
"$(PRODUCT_OUT)/ramdisk.img" \
"$(PRODUCT_OUT)/boot.img" \
"$(rec_initrc)" \
"$(rec_kernel)" \
"$(rec_build_prop)" \
"$(rec_resource_deps)" \
"$(rec_fstab)"
$(foreach item, $(RECOVERYIMAGE_REQUIRED), \
$(eval _item := $(strip $(item))) \
$(if $(filter "", $(_item)),$(error dependency is empty),) \
)
RECOVERYIMAGE_OPTIONAL := \
"$(INSTALLED_2NDBOOTLOADER_TARGET)" \
$(foreach item, $(RECOVERYIMAGE_REQUIRED) $(RECOVERYIMAGE_OPTIONAL), \
$(if $(strip $(subst $(DQUOTE),$(SPACE),$(item))), \
$(eval RECOVERYIMAGE_FINAL_LIST += $(strip $(subst $(DQUOTE),$(SPACE),$(item)))), \
) \
)
$(INSTALLED_RECOVERYIMAGE_TARGET): $(RECOVERYIMAGE_FINAL_LIST)

Compiling ffmpeg for use in Android (ndk) for x86 architecture

I am trying to compile ffmpeg for Android but for the x86 architecture. I've successfully compiled an arm .so and it all works, and I though that by replacing arm with x86 in the relevant places within the build script would have done the trick. Unfortunately that's not the case and I get some strange things occurring.
First I get this while it's compiling ffmpeg:
/home/ankur/android-ndk-r8/platforms/android-8/arch-arm//usr/include/strings.h:49: warning: redundant redeclaration of 'index'
Notice the arch-arm instead of arch-x86. Finally I get this:
/home/ankur/android-ndk-r8/toolchains/x86-4.4.3/prebuilt/linux-x86/bin/i686-android-linux-ld: libavcodec/libavcodec.a(4xm.o): Relocations in generic ELF (EM: 40)
/home/ankur/android-ndk-r8/toolchains/x86-4.4.3/prebuilt/linux-x86/bin/i686-android-linux-ld: libavcodec/libavcodec.a(4xm.o): Relocations in generic ELF (EM: 40)
/home/ankur/android-ndk-r8/toolchains/x86-4.4.3/prebuilt/linux-x86/bin/i686-android-linux-ld: libavcodec/libavcodec.a(4xm.o): Relocations in generic ELF (EM: 40)
libavcodec/libavcodec.a(4xm.o): could not read symbols: File in wrong format
The build script I've created looks like this:
#!/bin/bash
NDK=~/android-ndk-r8
PLATFORM=$NDK/platforms/android-8/arch-x86/
PREBUILT=$NDK/toolchains/x86-4.4.3/prebuilt/linux-x86
function build_one_r8
{
./configure \
--disable-shared \
--enable-static \
--enable-gpl \
--enable-version3 \
--enable-nonfree \
--disable-doc \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-avdevice \
--disable-avfilter \
--disable-postproc \
--enable-small \
--cross-prefix=$PREBUILT/bin/i686-android-linux- \
--enable-cross-compile \
--target-os=linux \
--extra-cflags="-I$PLATFORM/usr/include" \
--arch=x86 \
--disable-symver \
--disable-debug \
--disable-stripping \
$ADDITIONAL_CONFIGURE_FLAG
sed -i 's/HAVE_LRINT 0/HAVE_LRINT 1/g' config.h
sed -i 's/HAVE_LRINTF 0/HAVE_LRINTF 1/g' config.h
sed -i 's/HAVE_ROUND 0/HAVE_ROUND 1/g' config.h
sed -i 's/HAVE_ROUNDF 0/HAVE_ROUNDF 1/g' config.h
sed -i 's/HAVE_TRUNC 0/HAVE_TRUNC 1/g' config.h
sed -i 's/HAVE_TRUNCF 0/HAVE_TRUNCF 1/g' config.h
make clean
make -j4 install
$PREBUILT/bin/i686-android-linux-ar d libavcodec/libavcodec.a inverse.o
$PREBUILT/bin/i686-android-linux-ld -rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -soname libffmpeg.so -shared -nostdlib -z,noexecstack -Bsymbolic --whole-archive --no-undefined -o $PREFIX/libffmpeg.so libavcodec/libavcodec.a libavformat/libavformat.a libavutil/libavutil.a libswscale/libswscale.a -lc -lm -lz -ldl -llog --warn-once --dynamic-linker=/system/bin/linker $PREBUILT/lib/gcc/i686-android-linux/4.4.3/libgcc.a
}
function build_one_r8_2
{
$PREBUILT/bin/i686-android-linux-ar d libavcodec/libavcodec.a inverse.o
$PREBUILT/bin/i686-android-linux-ld -rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -soname libffmpeg.so -shared -nostdlib -z,noexecstack -Bsymbolic --whole-archive --no-undefined -o $PREFIX/libffmpeg.so libavcodec/libavcodec.a libavformat/libavformat.a libavutil/libavutil.a libswscale/libswscale.a -lc -lm -lz -ldl -llog --warn-once --dynamic-linker=/system/bin/linker $PREBUILT/lib/gcc/i686-android-linux/4.4.3/libgcc.a
}
#x86
CPU=x86
OPTIMIZE_CFLAGS="-march=$CPU "
PREFIX=./android/$CPU
ADDITIONAL_CONFIGURE_FLAG=
build_one_r8
I hope I'm doing something wrong rather than this not being possible.
Thanks!
I've been able to compile for the Atom, BUT the GoogleTV has no support for the NDK, which explains why all my attempts of compiling NDK for my GoogleTV device have not work. I hope it's coming soon!
Here's my build script, if it's helpful, I see a few things I have set that you don't seem to which may be part of your problem. I source it from on directory below the ffmpeg source dir (source). I.E. the script is called build.sh and resides in ~/android/ffmpeg, the ffmpeg source is in ~/android/ffmpeg/source and my build output ends up in ~/android/build/armeabi-v7a when I run the script as such:
~/android/ffmpeg$ source build.sh
This is build.sh:
#!/bin/bash
NDK=~/android/ndk
SYSROOT=$NDK/platforms/android-9/arch-arm
TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-
ABI="armeabi-v7a"
CPU="armv7-a"
ARCH="arm"
FPU="vfpv3-d16"
ANDROID_LIBS=$SYSROOT/usr/lib
DEST="../build/ffmpeg/$ABI"
EXTRA_LDFLAGS="-Wl,--fix-cortex-a8 -L$ANDROID_LIBS -Wl,-rpath-link,$ANDROID_LIBS"
EXTRA_CXXFLAGS="-Wno-multichar -Wno-psabi -fno-exceptions -fno-rtti"
EXTRA_CFLAGS="-DANDROID -marm -march=$CPU -mfloat-abi=softfp -mfpu=$FPU"
function configure
{
./configure \
--target-os=linux \
--prefix=$DEST \
--cross-prefix=$TOOLCHAIN \
--sysroot=$SYSROOT \
--extra-cflags="$EXTRA_CFLAGS" \
--extra-ldflags="$EXTRA_LDFLAGS" \
--extra-cxxflags="$EXTRA_CXXFLAGS" \
--enable-cross-compile \
--extra-libs="-lgcc" \
--arch=$ARCH \
--cpu=$CPU \
--disable-debug \
--disable-runtime-cpudetect \
--disable-optimizations \
--disable-neon \
--disable-network \
--disable-armv5te \
--disable-armv6 \
--disable-armv6t2 \
--disable-armvfp \
--disable-everything \
--disable-doc \
--disable-decoders \
--disable-encoders \
--disable-demuxers \
--disable-muxers \
--disable-protocols \
--disable-indevs \
--disable-filters \
--disable-outdevs \
--disable-bsfs \
--disable-shared \
--disable-ffprobe \
--disable-ffserver \
--disable-avfilter \
--disable-swresample \
--disable-avdevice \
--disable-ffplay \
--disable-ffmpeg \
--disable-swscale-alpha \
--disable-avresample \
--enable-static \
--enable-pthreads \
--enable-protocol=file \
--enable-libvpx \
--enable-decoder=vp8 \
--enable-parser=vp8 \
--enable-demuxer=matroska
}
cd source
make clean &&
configure &&
make -j8 &&
rm -rf $DEST &&
mkdir -p $DEST &&
make install

What is the best practice of using make with Verilog simulators and VPI code

I have go to some reasonable stage with my first VPI project, which is intended
to aid digital filter design. At the moment I was working with Icarus, though
I'd like to test Verilator too and other simulator as some point.
So far I have this makefile, though this is intended to build the C code and
one simple testbench. I'd like to be able to include a makefile and build/simulate
different new Verilog projects.
I haven't found much example of Makefiles for HDL projects on the net.
I'm quite happy with my implementation to some extend and can carry-on
rolling my own, though would like to see any well organised larger scale
projects. I have't yet looked at the Makefiles in OpenRISC ...
An example that I'm really looking for is of VPI testbench project, e.g. you
have done your VPI code and now want to build a small ecosystem around it
using a hierarchy of Makefiles.
Let's say, we are taking just two simulators - Icarus and Verilator.
This seems to be a vary basic makefile. In our makefiles we have usually far more targets which also include the synthesis, par and simulation. Sadly they contain very vendor specific (Xilinx & Synopsys) stuff, which make it not very generic. Also we usually have a hierarchy of makefiles. We have a general, some module specifics, and also some subprojects (e.g. the memorysystem) specific.
But in case you are interrested I post one here, to give you an impression how one could look like:
.PHONY: default
default: rtlsim
.PHONY: help
help:
#echo "Syntax:"
#echo "-------"
#echo "make [make_target] [options]"
#echo ""
#echo "Arguments:"
#echo "----------"
#echo "make_target = [bits], timing, rtlsim, rtlsimgui, laysim, laysimgui"
#echo " bits: Generate bitstream (includes P&R)"
#echo " timing: Generate timing report using timing analyzer (includes P&R)"
#echo " rtlsim: VCS RTL simulation (text mode)"
#echo " rtlsimgui: VCS RTL simulation (interactive gui mode)"
#echo " laysim: VCS post-place-and-route simulation (text mode)"
#echo " laysimgui: VCS post-place-and-route simulation (interactive gui mode)"
#echo ""
#echo "Options:"
#echo "----------"
#echo "target = [ml507], ml310"
#echo " ml507: Use Virtex-5 xc5vfx70t-1 as target FPGA (Xilinx ML507)"
#echo " ml310: Use Virtex-II Pro xc2vp30-6 as target FPGA (Xilinx ML310)"
#echo "disregard_cache_stalls = [0], 1"
#echo " 0: for normal simulation"
#echo " 1: to disregard cache stalls (results may then be incorrect, but the simulation time without cache stalls is obtained)"
#echo "physical_synthesis = [0], 1"
#echo " 0: run Synplify without physical synthesis"
#echo " 1: run Synplify with physical synthesis"
#echo "BATCH_GUI = [default], GUI"
#echo " default: run Synplify in batch mode"
#echo " GUI: start Synplify GUI instead"
#echo "toplevel = [fpga], datapath, sequencer, hw_kernel, user, plb_marc, mci_marc"
#echo " Sets the toplevel file in the HW design hierarchy; relevant for area / timing reports"
#echo "marc = [1], 2"
#echo " Chooses between usage of MARC1 and MARC2 (use the latter for 256 bit LPU transfers)"
# defaults
ifndef target
target=ml507
endif
ifndef toplevel
toplevel=fpga
endif
ifndef disregard_cache_stalls
disregard_cache_stalls=0
endif
ifndef marc
marc=1
endif
ifeq "$(target)" "ml507"
TECHNOLOGY_NAME=VIRTEX5
TECHNOLOGY_PART=XC5VFX70T
TECHNOLOGY_PACKAGE=FF1136
TECHNOLOGY_SPEED_GRADE=-1
FREQUENCY=100.000
else
TECHNOLOGY_NAME=VIRTEX2P
TECHNOLOGY_PART=XC2VP30
TECHNOLOGY_PACKAGE=FF896
TECHNOLOGY_SPEED_GRADE=-6
FREQUENCY=100.000
endif
ifndef physical_synthesis
physical_synthesis=0
endif
ifndef BATCH_GUI
BATCH_GUI=default
endif
ifeq "$(BATCH_GUI)" "default"
BATCH_TCL=batch
else
BATCH_TCL=tcl
endif
ifdef area_timing_result_file
AREA_TIMING_RESULT_FILE=$(area_timing_result_file)
else
AREA_TIMING_RESULT_FILE=area_timing_results.$(target).$(toplevel).txt
endif
ifeq ($(disregard_cache_stalls),1)
DISREGARD_CACHE_STALLS=+define+DISREGARD_CACHE_STALLS
else
DISREGARD_CACHE_STALLS=
endif
# base directory for MARC, SimEnv, AddOns, etc.
ifeq "$(target)" "ml507"
PRAKTIKUM_BASE=$(COMRADE_ROOT_DIR)/COMRADE/sim_synth/v5
else
PRAKTIKUM_BASE=$(COMRADE_ROOT_DIR)/COMRADE/sim_synth/v2p
endif
BRAM_VERILOG=$(COMRADE_ROOT_DIR)/COMRADE/sim_synth/platform_independent/bram
# command to get the directory of the current test example,
# relative to Comrade's "tests" directory
TEST_EXAMPLE=$(shell pwd | sed 's/.*tests\///g' | sed 's/\/sim_env_acem3//g')
# name of target RC executable
PROG=main
# Modlib path
MODLIB=$(COMRADE_ROOT_DIR)/modlib
# path to the instantiated verilog modules
MODULES=..
# path to the instantiated verilog blackboxes
BLACKBOXES=../blackboxes
ifeq "$(target)" "ml507"
DESIGN=user.v mci_marc.tcl
else
DESIGN=user.v plb_marc.tcl
endif
# base name of synthesis-related files
ifeq "$(target)" "ml507"
NETLIST=mci_marc
else
NETLIST=plb_marc
endif
# base name of toplevel after synthesis
TOPLEVEL=system
# current directory (which is in some cases != $(PWD)...)
CURRENT_DIR=$(shell pwd)
# "HOME" on local /scratch
SCRHOME=/scratch/$(USER)/private/tmp/$(TEST_EXAMPLE)
# directory containing MARC
ifeq ($(marc),2)
MARC=$(PRAKTIKUM_BASE)/MARC_marc2
else
MARC=$(PRAKTIKUM_BASE)/MARC
endif
# directory containing the simulation environment
ifeq ($(marc),2)
SIMENV=$(PRAKTIKUM_BASE)/SimEnv_marc2
else
SIMENV=$(PRAKTIKUM_BASE)/SimEnv
endif
# directory containing additional files (IP cores, SW, ...)
ifeq ($(marc),2)
ADDONS=$(PRAKTIKUM_BASE)/AddOns_marc2
else
ADDONS=$(PRAKTIKUM_BASE)/AddOns
endif
# ML310 Linux kernel image
VMLINUX=$(ADDONS)/zImage.elf
# TTY for serial console
CONSOLETTY=/dev/ttyS0
# path to xilinx's simulation primitives
SIMPRIMS=$(XILINX)/verilog/src/simprims
UNISIMS=$(XILINX)/verilog/src/unisims
# RC definitions
ifeq "$(target)" "ml507"
DEVICE=xc5vfx70t
PARTTYPE=$(DEVICE)-ff1136-1
DEVDES=$(TOPLEVEL)-$(DEVICE)
else
DEVICE=xc2vp30
PARTTYPE=$(DEVICE)-ff896-6
DEVDES=$(TOPLEVEL)-$(DEVICE)
endif
# this is the name of synplify target subdirectory
IMPL=Simple.$(target).fpga
# configuration files for $(VIRSIM)
CFGRTL=default-rtl
VPDRTL=$(SCRHOME)/vcdplus-rtl-$(notdir $(PWD))
CFGLAY=default-lay
VPDLAY=$(SCRHOME)/vcdplus-lay-$(notdir $(PWD))
CFGSYN=default-syn
VPDSYN=$(SCRHOME)/vcdplus-syn-$(notdir $(PWD))
MDIRRTL=csrc.rtl
MDIRLAY=csrc.lay
MDIRSYN=csrc.syn
# path to the cross OS installation directory
#CROSS=/acs/ace/rtems
#CROSS=/images/ml310/ml310_rootfs_gentoo
CROSS=/cad/tools/acs-prak/ACS07/Cross
#CROSSBIN=$(CROSS)/bin
CROSSBIN=/cad/tools/crosscompiler/powerpc-405-linux/bin
# the RTEMS/ACE2 IO server
SERVER=$(CROSSBIN)/rtemsserver -l
# the compile-flow tools
#CC=$(CROSSBIN)/sparc-rtems-gcc
CC=$(CROSSBIN)/powerpc-405-linux-gnu-gcc
#LD=$(CROSSBIN)/sparc-rtems-gcc
LD=$(CROSSBIN)/powerpc-405-linux-gnu-gcc
COPY=$(CROSSBIN)/sparc-rtems-objcopy
BIT2O=$(CROSSBIN)/bit2o
VPP=vpp
SED=sed
XC=xc
ifeq ($(SYNPLIFY_VERSION),8.8)
SYNPLIFY=synplify_pro
else
SYNPLIFY=synplify_premier_dp
endif
NGDBUILD=ngdbuild
MAP=map
PAR=par
NETGEN=netgen
BITGEN=bitgen
TRCE=trce
IMPACT=impact
XMD=xmd
VCS=vcs
SIMVRTL=simv.rtl
SIMVLAY=simv.lay
SIMVSYN=simv.syn
VIRSIM=virsim
XPOWER=xpwr
# the compile options
#CCOPTS=-fasm -specs bsp_specs -qrtems -O3 -I include -I $(CROSS)/sparc-rtems/include/rtems-ace2
CCOPTS=-O3 -I $(CROSS)/usr/include
#LDOPTS=-fasm -specs bsp_specs -qrtems -O3
LDOPTS=-O3
COPYOPTS=-O binary
SYNPLIFYOPTS=$(filter %.tcl,$(DESIGN))
NGDBUILDOPTS=-uc $(ADDONS)/$(TOPLEVEL).ucf -sd $(ADDONS) -sd $(MODLIB) -sd $(MODLIB)/$(target)
MAPOPTS=-pr b -detail -timing -ol high -xe c -w
PAROPTS=-ol high -xe c -w
BITGENOPTS=
TRCEOPTS=-v 10
TRCEOPTS_HG=-v 10 -u 10
VCSOPTS=+v2k +notimingchecks -y . -y .. -y $(MARC) +incdir+$(MARC) -y $(SIMENV) +incdir+$(SIMENV) -y $(ADDONS) +incdir+$(ADDONS) -y $(MODLIB) +incdir+$(MODLIB) -y $(BRAM_VERILOG) +incdir+$(BRAM_VERILOG) $(DISREGARD_CACHE_STALLS)
# Don't change these
ifeq ($(target),ml507)
ifeq ($(disregard_cache_stalls),1)
VCSRTLOPTS=+define+TESTBENCH=testbench_rtl -v ../simdefs.v -v $(UNISIMS)/../glbl.v $(VCSOPTS) -y $(UNISIMS) -y $(SIMPRIMS) +libext+.v $(SIMENV)/testbench_rtl.v
else
VCSRTLOPTS=+define+TESTBENCH=testbench_rtl -v ../simdefs.v -v marc.v -v $(SIMENV)/ppc440.v -v $(SIMENV)/temac.v -v $(UNISIMS)/../glbl.v $(VCSOPTS) -y $(UNISIMS) -y $(SIMPRIMS) +libext+.v $(SIMENV)/testbench_rtl.v
endif
VCSSYNOPTS=+define+TESTBENCH=testbench_syn -v ../simdefs.v -v $(SIMENV)/ppc440.v -v $(SIMENV)/temac.v -v $(IMPL)/$(NETLIST).vm -v $(UNISIMS)/../glbl.v $(VCSOPTS) -y $(UNISIMS) -y $(SIMPRIMS) +libext+.v $(SIMENV)/testbench_syn.v
VCSLAYOPTS=+define+TESTBENCH=testbench_lay -v ../simdefs.v -v $(SIMENV)/ppc440.v -v $(IMPL)/$(DEVDES).v -v $(SIMPRIMS)/../glbl.v $(VCSOPTS) -y $(SIMPRIMS) +libext+.v $(SIMENV)/testbench_lay.v
else
ifeq ($(disregard_cache_stalls),1)
VCSRTLOPTS=+define+TESTBENCH=testbench_rtl -v ../simdefs.v -v $(UNISIMS)/../glbl.v $(VCSOPTS) -y $(UNISIMS) -y $(SIMPRIMS) +libext+.v $(SIMENV)/testbench_rtl.v
else
VCSRTLOPTS=+define+TESTBENCH=testbench_rtl -v ../simdefs.v -v marc.v -v $(SIMENV)/ppc405.v -v $(UNISIMS)/../glbl.v $(VCSOPTS) -y $(UNISIMS) -y $(SIMPRIMS) +libext+.v $(SIMENV)/testbench_rtl.v
endif
VCSSYNOPTS=+define+TESTBENCH=testbench_syn -v ../simdefs.v -v $(SIMENV)/ppc405.v -v $(IMPL)/$(NETLIST).vm -v $(UNISIMS)/../glbl.v $(VCSOPTS) -y $(UNISIMS) -y $(SIMPRIMS) +libext+.v $(SIMENV)/testbench_syn.v
VCSLAYOPTS=+define+TESTBENCH=testbench_lay -v ../simdefs.v -v $(SIMENV)/ppc405.v -v $(IMPL)/$(DEVDES).v -v $(SIMPRIMS)/../glbl.v $(VCSOPTS) -y $(SIMPRIMS) +libext+.v $(SIMENV)/testbench_lay.v
endif
# make rules
default: all
.c.o:
$(CC) -c $(CCOPTS) $<
$(PROG).exe: $(PROG).o $(DEVDES).o
$(LD) -o $(PROG).exe $(PROG).o $(DEVDES).o $(LDOPTS) $(CROSS)/sparc-rtems/lib/libacevapi.a -lm
$(PROG).bin: $(PROG).exe
$(COPY) $(COPYOPTS) $(PROG).exe $(PROG).bin
$(PROG): $(PROG).o
$(LD) -o $(PROG) $(PROG).o $(LDOPTS) $(CROSS)/usr/lib/libadmxrc2.so.2
# build hardware objects
#$(SIMENV)/%.v: $(ADDONS)/%.ngc
# $(NETGEN) -w -sim -ofmt verilog $< $#
# rm $(basename $#).nlf
$(DEVDES).o: $(IMPL)/$(DEVDES).o
cp $(IMPL)/$(DEVDES).o .
$(IMPL)/$(DEVDES).o: $(IMPL)/$(DEVDES).bit
cd $(IMPL); \
$(BIT2O) $(DEVDES).bit $(DEVDES).o config_$(TOPLEVEL) ;\
cd ..
$(VPDRTL).vpd: $(MARC)/*.v marc.v $(SIMENV)/*.v $(patsubst $(ADDONS)/%.ngc,$(SIMENV)/%.v,$(wildcard $(ADDONS)/*.ngc)) $(filter %.v,$(DESIGN))
mkdir -p -m 700 $(dir $(VPDRTL))
$(VCS) -line -PP +define+BATCH -Mupdate -Mdir=$(MDIRRTL) -o $(SIMVRTL) $(VCSRTLOPTS)
./$(SIMVRTL) +vpddrivers +vpdfile+$(VPDRTL).vpd
$(VPDLAY).vpd: $(SIMENV)/*.v $(IMPL)/$(DEVDES).v
mkdir -p -m 700 $(dir $(VPDLAY))
$(VCS) -line -PP +define+BATCH -Mupdate -Mdir=$(MDIRLAY) -o $(SIMVLAY) $(VCSLAYOPTS)
./$(SIMVLAY) +vpddrivers +vpdfile+$(VPDLAY).vpd
$(VPDSYN).vpd: $(SIMENV)/*.v $(patsubst $(ADDONS)/%.ngc,$(SIMENV)/%.v,$(wildcard $(ADDONS)/*.ngc)) $(IMPL)/$(NETLIST).vm
mkdir -p -m 700 $(dir $(VPDSYN))
$(VCS) -line -PP +define+BATCH -Mupdate -Mdir=$(MDIRSYN) -o $(SIMVSYN) $(VCSSYNOPTS)
./$(SIMVSYN) +vpddrivers +vpdfile+$(VPDSYN).vpd
$(IMPL)/$(DEVDES).v: $(IMPL)/$(DEVDES).ncd
cd $(IMPL); \
$(NETGEN) -w -sim -ofmt verilog -sdf_path ../$(IMPL)/$(DEVDES).sdf $(DEVDES) -pcf $(DEVDES).pcf; \
$(SED) -i -e 's/SIM_COLLISION_CHECK = "ALL"/SIM_COLLISION_CHECK = "GENERATE_X_ONLY"/g' $(DEVDES).v ;\
cd ..
$(IMPL)/$(DEVDES).hg.twr: $(IMPL)/$(DEVDES).ncd
cd $(IMPL); \
$(TRCE) $(TRCEOPTS_HG) $(DEVDES).ncd ;\
mv $(DEVDES).twr $(DEVDES).hg.twr
cd ..
$(IMPL)/$(DEVDES).twr: $(IMPL)/$(DEVDES).ncd
cd $(IMPL); \
$(TRCE) $(TRCEOPTS) $(DEVDES).ncd ;\
cd ..
$(IMPL)/$(DEVDES).bit: $(IMPL)/$(DEVDES).ncd
cd $(IMPL); \
$(BITGEN) -w $(BITGENOPTS) $(DEVDES) $(DEVDES);\
cd ..
$(IMPL)/$(DEVDES).ncd: $(IMPL)/$(DEVDES)_map.ncd
cd $(IMPL); \
$(PAR) $(PAROPTS) $(DEVDES)_map.ncd $(DEVDES).ncd $(DEVDES).pcf ;\
cd ..
$(IMPL)/$(DEVDES)_map.ncd: $(IMPL)/$(DEVDES).ngd
cd $(IMPL); \
XIL_TIMING_ALLOW_IMPOSSIBLE=1 $(MAP) $(MAPOPTS) -o $(DEVDES)_map.ncd $(DEVDES).ngd $(DEVDES).pcf ; \
cd ..
$(IMPL)/$(DEVDES).ngd: $(IMPL)/$(NETLIST).edf $(wildcard $(ADDONS)/*.ngc) $(wildcard $(ADDONS)/*.edf)
cd $(IMPL); \
$(NGDBUILD) $(NGDBUILDOPTS) -p $(PARTTYPE) $(TOPLEVEL) $(DEVDES).ngd; \
cd ..
$(IMPL)/$(NETLIST).edf $(IMPL)/$(NETLIST).vm: $(MARC)/*.v marc.v $(wildcard $(ADDONS)/*.v) $(filter %.v,$(DESIGN)) $(filter %.tcl,$(DESIGN))
DESIGN=$(CURRENT_DIR) IMPL=$(IMPL) NETLIST=$(NETLIST) MARC=$(MARC) \
ADDONS=$(ADDONS) MODULES=$(MODULES) MODLIB=$(MODLIB) BRAM_VERILOG=$(BRAM_VERILOG) BLACKBOXES=$(BLACKBOXES) \
TECHNOLOGY_NAME=$(TECHNOLOGY_NAME) TECHNOLOGY_PART=$(TECHNOLOGY_PART) \
TECHNOLOGY_PACKAGE=$(TECHNOLOGY_PACKAGE) TECHNOLOGY_SPEED_GRADE=$(TECHNOLOGY_SPEED_GRADE) \
FREQUENCY=$(FREQUENCY) PHYSICAL_SYNTHESIS=$(physical_synthesis) \
BATCH_GUI=$(BATCH_GUI) $(SYNPLIFY) -$(BATCH_TCL) $(SYNPLIFYOPTS)
# if link_marcdefs_v_$(target)_created does not exist, the marcdefs.v link is (re-)created
link_marcdefs_v_$(target)_created:
-rm -f link_marcdefs_v_ml310_created link_marcdefs_v_ml507_created 2>/dev/null
#touch link_marcdefs_v_$(target)_created
marcdefs.v: marcdefs.$(target).v link_marcdefs_v_$(target)_created
-rm -f marcdefs.v 2>/dev/null
ln -s marcdefs.$(target).v marcdefs.v
#touch marcdefs.v
marc.v: $(MARC)/marc.vpp marcdefs.v
$(VPP) $(MARC)/marc.vpp > marc.v 2>/dev/null
.PHONY: all
all: $(PROG) bits
#echo -e "OK, ML310 Linux executable for $(PROG) built. Run it using \n\tmake linux\nand after logging in, execute \n\t$(SCRHOME)/$(PROG)"
.PHONY: rtlsimbatch
rtlsimbatch: $(VPDRTL).vpd
$(VIRSIM) +define+RTLSIM +vpdfile+$(VPDRTL).vpd +cfgfile+$(CFGRTL).cfg $(VCSRTLOPTS)
.PHONY: rtlsimgui
ifeq ($(disregard_cache_stalls),1)
rtlsimgui: $(MARC)/*.v ../simdefs.v ../stimulus.v $(SIMENV)/*.v $(filter %.v,$(DESIGN))
mkdir -p -m 700 $(dir $(VPDRTL))
$(VCS) -line -RI -Mupdate -Mdir=$(MDIRRTL) -o $(SIMVRTL) +define+RTLSIM +vpdfile+$(VPDRTL).vpd +cfgfile+$(CFGRTL).cfg $(VCSRTLOPTS)
else
rtlsimgui: $(MARC)/*.v ../simdefs.v ../stimulus.v marc.v $(SIMENV)/*.v $(patsubst $(ADDONS)/%.ngc,$(SIMENV)/%.v,$(wildcard $(ADDONS)/*.ngc)) $(filter %.v,$(DESIGN))
mkdir -p -m 700 $(dir $(VPDRTL))
$(VCS) -line -RI -Mupdate -Mdir=$(MDIRRTL) -o $(SIMVRTL) +define+RTLSIM +vpdfile+$(VPDRTL).vpd +cfgfile+$(CFGRTL).cfg $(VCSRTLOPTS)
endif
.PHONY: rtlsim
ifeq ($(disregard_cache_stalls),1)
rtlsim: marcdefs.v ../simdefs.v ../stimulus.v $(SIMENV)/*.v $(filter %.v,$(DESIGN))
mkdir -p -m 700 $(dir $(VPDRTL))
$(VCS) -line -PP -Mupdate -Mdir=$(MDIRRTL) -o $(SIMVRTL) +define+RTLSIM +vpdfile+$(VPDRTL).vpd +cfgfile+$(CFGRTL).cfg $(VCSRTLOPTS)
./$(SIMVRTL)
else
rtlsim: $(MARC)/*.v ../simdefs.v ../stimulus.v marc.v $(SIMENV)/*.v $(patsubst $(ADDONS)/%.ngc,$(SIMENV)/%.v,$(wildcard $(ADDONS)/*.ngc)) $(filter %.v,$(DESIGN))
mkdir -p -m 700 $(dir $(VPDRTL))
$(VCS) -line -PP -Mupdate -Mdir=$(MDIRRTL) -o $(SIMVRTL) +define+RTLSIM +vpdfile+$(VPDRTL).vpd +cfgfile+$(CFGRTL).cfg $(VCSRTLOPTS)
./$(SIMVRTL)
endif
.PHONY: laysimbatch
laysimbatch: $(VPDLAY).vpd
$(VIRSIM) +vpdfile+$(VPDLAY).vpd +cfgfile+$(CFGLAY).cfg $(VCSLAYOPTS)
.PHONY: laysimgui
laysimgui: $(SIMENV)/*.v $(IMPL)/$(DEVDES).v
mkdir -p -m 700 $(dir $(VPDLAY))
$(VCS) -line -RI -Mupdate -Mdir=$(MDIRLAY) -o $(SIMVLAY) +vpdfile+$(VPDLAY).vpd +cfgfile+$(CFGLAY).cfg $(VCSLAYOPTS)
.PHONY: laysim
laysim: $(SIMENV)/*.v ../simdefs.v ../stimulus.v $(IMPL)/$(DEVDES).v
mkdir -p -m 700 $(dir $(VPDLAY))
$(VCS) -line -PP -Mupdate -Mdir=$(MDIRLAY) -o $(SIMVLAY) +vpdfile+$(VPDLAY).vpd +cfgfile+$(CFGLAY).cfg $(VCSLAYOPTS)
./$(SIMVLAY)
.PHONY: synsimbatch
synsimbatch: $(VPDSYN).vpd
$(VIRSIM) +vpdfile+$(VPDSYN).vpd +cfgfile+$(CFGSYN).cfg $(VCSSYNOPTS)
.PHONY: synsim
synsim: $(SIMENV)/*.v ../simdefs.v ../stimulus.v $(patsubst $(ADDONS)/%.ngc,$(SIMENV)/%.v,$(wildcard $(ADDONS)/*.ngc)) $(IMPL)/$(NETLIST).vm
mkdir -p -m 700 $(dir $(VPDSYN))
$(VCS) -line -RI -Mupdate -Mdir=$(MDIRSYN) -o $(SIMVSYN) +vpdfile+$(VPDSYN).vpd +cfgfile+$(CFGSYN).cfg $(VCSSYNOPTS)
.PHONY: timing
ifeq "$(physical_synthesis)" "1"
# Synplify creates .edf, .ncd and .twr in one call!
timing: $(IMPL)/$(NETLIST).edf
cat $(IMPL)/par_1/$(NETLIST).twr
$(COMRADE_ROOT_DIR)/COMRADE/scripts/XilinxReportReader/xrr $(TECHNOLOGY_NAME) \
$(IMPL)/par_1/$(NETLIST)_map.mrp $(IMPL)/par_1/$(NETLIST).twr >$(AREA_TIMING_RESULT_FILE)
else
# Create only .edf by Synplify, rest using Makefile
timing: $(IMPL)/$(DEVDES).twr
cat $(IMPL)/$(DEVDES).twr
$(COMRADE_ROOT_DIR)/COMRADE/scripts/XilinxReportReader/xrr $(TECHNOLOGY_NAME) \
$(IMPL)/$(DEVDES)_map.mrp $(IMPL)/$(DEVDES).twr >$(AREA_TIMING_RESULT_FILE)
endif
# create .vcd from .vpd for power analysis
$(VPDLAY).vcd: $(VPDLAY).vpd
vpd2vcd $(VPDLAY).vpd $(VPDLAY).vcd
# create .xad from .vcd for power analysis
$(VPDLAY).xad: $(VPDLAY).vcd
/cad/tools/ise-9.2/bin/lin/vcd2xad.pl -f $(VPDLAY).vcd
# create .saif from .vcd
$(VPDLAY).saif: $(VPDLAY).vcd
vcd2saif -i $(VPDLAY).vcd -o $(VPDLAY).saif
# power analysis
.PHONY: power
power: $(IMPL)/$(DEVDES).ncd $(VPDLAY).saif
$(XPOWER) -v -a $(IMPL)/$(DEVDES).ncd $(IMPL)/$(DEVDES).pcf -s $(VPDLAY).vcd
#echo "Power results written to file \"$(IMPL)/$(DEVDES).pwr\"."
# area results
.PHONY: area
area: $(IMPL)/$(DEVDES)_map.ncd
.PHONY: area_all
area_all:
# V2P
make area_datapath toplevel=datapath
make area_sequencer toplevel=sequencer
make area_hw_kernel toplevel=hw_kernel
make area_plb_marc toplevel=plb_marc
make area
# V5
make area_datapath toplevel=datapath target=ml507
make area_sequencer toplevel=sequencer target=ml507
make area_hw_kernel toplevel=hw_kernel target=ml507
.PHONY: timing_all
timing_all:
# V2P
make timing_datapath toplevel=datapath
make timing_sequencer toplevel=sequencer
make timing_hw_kernel toplevel=hw_kernel
make timing_plb_marc toplevel=plb_marc
make timing
# V5
make timing_datapath toplevel=datapath target=ml507
make timing_sequencer toplevel=sequencer target=ml507
make timing_hw_kernel toplevel=hw_kernel target=ml507
.PHONY: bits
bits: $(IMPL)/$(DEVDES).bit
.PHONY: download
download: bits
cd $(IMPL); \
echo -e "setMode -bscan \
\nsetCable -p lpt1 \
\naddDevice -p 1 -part xccace \
\naddDevice -p 2 -file $(DEVDES).bit \
\nprogram -p 2 \
\nquit" > download.cmd ; \
$(IMPACT) -batch download.cmd ; \
cd ..
.PHONY: linux
linux: $(PROG) $(VMLINUX) download
mkdir -p -m 700 $(SCRHOME)
cp -a $(PROG) $(SCRHOME)
cd $(IMPL); \
echo -e "connect ppc hw \
\nrst \
\nafter 1700 set end 1 \
\nvwait end \
\ndow $(VMLINUX) \
\ncon \
\nexit" > download.tcl ; \
echo -e "set bps 115200 \
\nset msdos "off" \
\nset del2bs "off" \
\nbind_function 1 \"quitchr\" \
\nshell \"$(XMD) -tcl download.tcl\" \
\necho \"Linux wird auf der seriellen Konsole gestartet...\" \
\n" > download.xc ; \
$(XC) -l $(CONSOLETTY) -s download.xc ; \
cd ..
.PHONY: cosim
cosim:
make -C cosimulation/
cosimulation/simv
.PHONY: cosim_gui
cosim_gui:
make -C cosimulation/
cosimulation/simv -gui
.PHONY: cosim_clean
cosim_clean:
make clean -C cosimulation/
.PHONY: clean
clean:
rm -f $(PROG).exe $(PROG).bin $(PROG).run $(PROG).o $(PROG) $(DEVDES).o $(VPDRTL).vpd $(VPDLAY).vpd $(VPDSYN).vpd $(SIMVRTL) $(SIMVLAY) $(SIMVSYN) marc.v stdout.log vcs.key
rm -rf Simple.ml310.* Simple.ml507.* $(IMPL) $(IMPL).datapath $(IMPL).sequencer $(IMPL).user $(IMPL).plb_marc
rm -rf $(SIMVRTL).daidir $(SIMVLAY).daidir $(SIMVSYN).daidir $(MDIRRTL) $(MDIRLAY) $(MDIRSYN)
# Switch between different top-level modules
ifeq "$(toplevel)" "datapath"
include Makefile.datapath
endif
ifeq "$(toplevel)" "sequencer"
include Makefile.sequencer
endif
ifeq "$(toplevel)" "hw_kernel"
include Makefile.hw_kernel
endif
ifeq "$(toplevel)" "user"
include Makefile.user
endif
ifeq "$(toplevel)" "plb_marc"
include Makefile.plb_marc
endif
ifeq "$(toplevel)" "mci_marc"
include Makefile.mci_marc
endif

Resources