I'm working with some big script which produce some new input.sh file which consist of sequence of the commands step-by-step used as the input for some program called here pmemd.
Here I'd like to focus on how I obtain this input.sh. Using printf I have the following :
printf "#setenv CUDA_VISIBLE_DEVICES "1"\nmpirun -np 8 pmemd.MPI -O -i ../in/minim.in -o minim.out -p ./protein.parm7 -c ./protein.inpcrd -r minim.restrt\npmemd.cuda -O -i ../in/equil.in -o equil.out -p ./protein.parm7 -c ./minim.restrt -r equil.restrt -x equil.nc -ref ./minim.restrt\npmemd.cuda -O -i ../in/equil2.in -o equil2.out -p ./protein.parm7 -c equil.restrt -r equil2.restrt -x equil2.nc -ref equil.restrt\npmemd.cuda -O -i ../in/equil3.in -o equil3.out -p ./protein.parm7 -c equil2.restrt -r equil3.restrt -x equil3.nc -ref equil2.restrt\npmemd.cuda -O -i ../in/equil4.in -o equil4.out -p ./protein.parm7 -c equil3.restrt -r equil4.restrt -x equil4.nc -ref equil3.restrt\npmemd.cuda -O -i ../in/equil5.in -o equil5_1.out -p ./protein.parm7 -c equil4.restrt -r equil5_1.restrt -x equil5.nc -ref equil4.restrt\npmemd.cuda -O -i ../in/equil5.in -o equil5_2.out -p ./protein.parm7 -c equil5_1.restrt -r equil5_2.restrt -x equil5.nc -ref equil5_1.restrt\npmemd.cuda -O -i ../in/equil5.in -o equil5_3.out -p ./protein.parm7 -c equil5_2.restrt -r equil5_3.restrt -x equil5.nc -ref equil5_2.restrt\npmemd.cuda -O -i ../in/equil5.in -o equil5_4.out -p ./protein.parm7 -c equil5_3.restrt -r equil5_4.restrt -x equil5.nc -ref equil5_3.restrt\npmemd.cuda -O -i ../in/equil5.in -o equil5_5.out -p ./protein.parm7 -c equil5_4.restrt -r equil5_5.restrt -x equil5.nc -ref equil5_4.restrt\npmemd.cuda -O -i ../in/md.in -o md_${P}_${com_n}.out -p ./protein.parm7 -c equil5_5.restrt -r md.restrt -x md.nc" > ./input.sh
which result in the input.sh eventually consisted of the
#setenv CUDA_VISIBLE_DEVICES 1
mpirun -np 8 pmemd.MPI -O -i ../in/minim.in -o minim.out -p ./protein.parm7 -c ./protein.inpcrd -r minim.restrt
pmemd.cuda -O -i ../in/equil.in -o equil.out -p ./protein.parm7 -c ./minim.restrt -r equil.restrt -x equil.nc -ref ./minim.restrt
pmemd.cuda -O -i ../in/equil2.in -o equil2.out -p ./protein.parm7 -c equil.restrt -r equil2.restrt -x equil2.nc -ref equil.restrt
pmemd.cuda -O -i ../in/equil3.in -o equil3.out -p ./protein.parm7 -c equil2.restrt -r equil3.restrt -x equil3.nc -ref equil2.restrt
pmemd.cuda -O -i ../in/equil4.in -o equil4.out -p ./protein.parm7 -c equil3.restrt -r equil4.restrt -x equil4.nc -ref equil3.restrt
pmemd.cuda -O -i ../in/equil5.in -o equil5_1.out -p ./protein.parm7 -c equil4.restrt -r equil5_1.restrt -x equil5.nc -ref equil4.restrt
pmemd.cuda -O -i ../in/equil5.in -o equil5_2.out -p ./protein.parm7 -c equil5_1.restrt -r equil5_2.restrt -x equil5.nc -ref equil5_1.restrt
pmemd.cuda -O -i ../in/equil5.in -o equil5_3.out -p ./protein.parm7 -c equil5_2.restrt -r equil5_3.restrt -x equil5.nc -ref equil5_2.restrt
pmemd.cuda -O -i ../in/equil5.in -o equil5_4.out -p ./protein.parm7 -c equil5_3.restrt -r equil5_4.restrt -x equil5.nc -ref equil5_3.restrt
pmemd.cuda -O -i ../in/equil5.in -o equil5_5.out -p ./protein.parm7 -c equil5_4.restrt -r equil5_5.restrt -x equil5.nc -ref equil5_4.restrt
pmemd.cuda -O -i ../in/md.in -o md_OR5P3_plus-carvone.out -p ./protein.parm7 -c equil5_5.restrt -r md.restrt -x md.nc
as you can see this method is not very comfortable because it's not easy to edit containt of the input.sh within the initial script when I need to add some modification of future input.sh. Also As you notice the file consist of fragment which i need to obtain as the result of the some looping because it consist of several steps like 5_1, 5_2 etc (here each next step use the previous one as the input)
pmemd.cuda -O -i ../in/equil5.in -o equil5_1.out -p ./protein.parm7 -c equil4.restrt -r equil5_1.restrt -x equil5.nc -ref equil4.restrt
pmemd.cuda -O -i ../in/equil5.in -o equil5_2.out -p ./protein.parm7 -c equil5_1.restrt -r equil5_2.restrt -x equil5.nc -ref equil5_1.restrt
pmemd.cuda -O -i ../in/equil5.in -o equil5_3.out -p ./protein.parm7 -c equil5_2.restrt -r equil5_3.restrt -x equil5.nc -ref equil5_2.restrt
pmemd.cuda -O -i ../in/equil5.in -o equil5_4.out -p ./protein.parm7 -c equil5_3.restrt -r equil5_4.restrt -x equil5.nc -ref equil5_3.restrt
pmemd.cuda -O -i ../in/equil5.in -o equil5_5.out -p ./protein.parm7 -c equil5_4.restrt -r equil5_5.restrt -x equil5.nc -ref equil5_4.restrt
So I'd thankful if someone provide me with the ideas of how to add For or While loop within such printf operator or its alternatives.
Thanks for help!!
Gleb
Here's a shell script that generates most of the lines in your post:
prev=minim
for i in '' $(seq 2 4); do
cur=equil$i
printf 'pmemd.cuda -O -i ../in/%s.in -o %s.out -p ./protein.parm7 -c %s.restrt -r %s.restrt -x %s.nc -ref %s.restrt\n' $cur $cur $prev $cur $cur $prev
prev=$cur
done
for i in $(seq 5); do
cur=equil5_$i
printf 'pmemd.cuda -O -i ../in/equil5.in -o %s.out -p ./protein.parm7 -c %s.restrt -r %s.restrt -x equil5.nc -ref %s.restrt\n' $cur $prev $cur $prev
prev=$cur
done
This generates:
pmemd.cuda -O -i ../in/equil.in -o equil.out -p ./protein.parm7 -c minim.restrt -r equil.restrt -x equil.nc -ref minim.restrt
pmemd.cuda -O -i ../in/equil2.in -o equil2.out -p ./protein.parm7 -c equil.restrt -r equil2.restrt -x equil2.nc -ref equil.restrt
pmemd.cuda -O -i ../in/equil3.in -o equil3.out -p ./protein.parm7 -c equil2.restrt -r equil3.restrt -x equil3.nc -ref equil2.restrt
pmemd.cuda -O -i ../in/equil4.in -o equil4.out -p ./protein.parm7 -c equil3.restrt -r equil4.restrt -x equil4.nc -ref equil3.restrt
pmemd.cuda -O -i ../in/equil5.in -o equil5_1.out -p ./protein.parm7 -c equil4.restrt -r equil5_1.restrt -x equil5.nc -ref equil4.restrt
pmemd.cuda -O -i ../in/equil5.in -o equil5_2.out -p ./protein.parm7 -c equil5_1.restrt -r equil5_2.restrt -x equil5.nc -ref equil5_1.restrt
pmemd.cuda -O -i ../in/equil5.in -o equil5_3.out -p ./protein.parm7 -c equil5_2.restrt -r equil5_3.restrt -x equil5.nc -ref equil5_2.restrt
pmemd.cuda -O -i ../in/equil5.in -o equil5_4.out -p ./protein.parm7 -c equil5_3.restrt -r equil5_4.restrt -x equil5.nc -ref equil5_3.restrt
pmemd.cuda -O -i ../in/equil5.in -o equil5_5.out -p ./protein.parm7 -c equil5_4.restrt -r equil5_5.restrt -x equil5.nc -ref equil5_4.restrt
I might be misunderstanding your question, but it seems to be that you're not comfortable with such a big giant printf line. So, why not just divide it up. You can use >> to append to a file. This way, each line in your input.sh is a separate printf line:
printf "#setenv CUDA_VISIBLE_DEVICES \"1\"\n" > input.sh
printf "mpirun -np 8 pmemd.MPI -O -i ../in/minim.in -o minim.out -p ./protein.parm7 -c ./protein.inpcrd -r minim.restrt\n" >> input.sh
printf "pmemd.cuda -O -i ../in/equil.in -o equil.out -p ./protein.parm7 -c ./minim.restrt -r equil.restrt -x equil.nc -ref ./minim.restrt\n" >> input.sh
printf "pmemd.cuda -O -i ../in/equil2.in -o equil2.out -p ./protein.parm7 -c equil.restrt -r equil2.restrt -x equil2.nc -ref equil.restrt\n" >> input.sh
printf "pmemd.cuda -O -i ../in/equil3.in -o equil3.out -p ./protein.parm7 -c equil2.restrt -r equil3.restrt -x equil3.nc -ref equil2.restrt\n" >> input.sh
printf "pmemd.cuda -O -i ../in/equil4.in -o equil4.out -p ./protein.parm7 -c equil3.restrt -r equil4.restrt -x equil4.nc -ref equil3.restrt\n" >> input.sh
printf "pmemd.cuda -O -i ../in/equil5.in -o equil5_1.out -p ./protein.parm7 -c equil4.restrt -r equil5_1.restrt -x equil5.nc -ref equil4.restrt\n" >> input.sh
printf "pmemd.cuda -O -i ../in/equil5.in -o equil5_2.out -p ./protein.parm7 -c equil5_1.restrt -r equil5_2.restrt -x equil5.nc -ref equil5_1.restrt\n >> input.sh
printf "pmemd.cuda -O -i ../in/equil5.in -o equil5_3.out -p ./protein.parm7 -c equil5_2.restrt -r equil5_3.restrt -x equil5.nc -ref equil5_2.restrt\n" >> input.sh
printf "pmemd.cuda -O -i ../in/equil5.in -o equil5_4.out -p ./protein.parm7 -c equil5_3.restrt -r equil5_4.restrt -x equil5.nc -ref equil5_3.restrt\n" >> input.sh
printf "pmemd.cuda -O -i ../in/equil5.in -o equil5_5.out -p ./protein.parm7 -c equil5_4.restrt -r equil5_5.restrt -x equil5.nc -ref equil5_4.restrt\n" >> input.sh
printf "pmemd.cuda -O -i ../in/md.in -o md_${P}_${com_n}.out -p ./protein.parm7 -c equil5_5.restrt -r md.restrt -x md.nc\n" >> ./input.sh
Since printf doesn't automatically include a NL on the end, you could even divide up the individual input.sh lines for better readability:
printf " pmemd.cuda -O" >> input.sh
printf " -i ../in/equil.in" >> input.sh
printf " -o equil.out" >> input.sh
printf " -p ./protein.parm7" >> input.sh
printf " -c ./minim.restrt" >> input.sh
printf " -r equil.restrt" >> input.sh
printf " -x equil.nc" >> input.sh
printf " -ref ./minim.restrt" >> input.sh
printf "\n" >> input.sh
Now, if something is changed, you can quickly find the parameter and modify it.
You could also combine that with Chris Jester-Young's suggestion of using a for loop to increment your values:
for cur in '' $(seq 2 4)
do
printf ' pmemd.cuda -O ' >> input.sh
printf ' -i ../in/equil%s.in ' $cur >> input.sh
printf ' -o equil%s.out' $cur >> input.sh
printf ' -p ./protein.parm7" >> input.sh
printf ' -c equil%s.restrt' $prev >> input.sh
prinff ' -r equil%s.restrt' $cur >> input.sh
printf ' -x equil%s.nc' $cur >> input.sh
printf ' -ref equil%s.restrt\n' $prev >> input.sh
prev=$cur
done
Note how the spacing on each line makes it easier to read and understand the command.
Finally, if you don't mind writing out the entire file, you can use a here document.
The << starts the here document. The EOF is the parameter that tells the here document when it ends. This could be anything. For example, it could be INPUT_SH. If I put that parameter in single quotes, the shell won't interpolate variables.
cat <<'EOF' > input.sh
#setenv CUDA_VISIBLE_DEVICES "1"
mpirun -np 8 pmemd.MPI -O -i ../in/minim.in -o minim.out -p ./protein.parm7 -c ./protein.inpcrd -r minim.restrt
pmemd.cuda -O -i ../in/equil.in -o equil.out -p ./protein.parm7 -c ./minim.restrt -r equil.restrt -x equil.nc -ref ./minim.restrt
pmemd.cuda -O -i ../in/equil2.in -o equil2.out -p ./protein.parm7 -c equil.restrt -r equil2.restrt -x equil2.nc -ref equil.restrt
pmemd.cuda -O -i ../in/equil3.in -o equil3.out -p ./protein.parm7 -c equil2.restrt -r equil3.restrt -x equil3.nc -ref equil2.restrt
pmemd.cuda -O -i ../in/equil4.in -o equil4.out -p ./protein.parm7 -c equil3.restrt -r equil4.restrt -x equil4.nc -ref equil3.restrt
pmemd.cuda -O -i ../in/equil5.in -o equil5_1.out -p ./protein.parm7 -c equil4.restrt -r equil5_1.restrt -x equil5.nc -ref equil4.restrt
pmemd.cuda -O -i ../in/equil5.in -o equil5_2.out -p ./protein.parm7 -c equil5_1.restrt -r equil5_2.restrt -x equil5.nc -ref equil5_1.restrt
pmemd.cuda -O -i ../in/equil5.in -o equil5_3.out -p ./protein.parm7 -c equil5_2.restrt -r equil5_3.restrt -x equil5.nc -ref equil5_2.restrt
pmemd.cuda -O -i ../in/equil5.in -o equil5_4.out -p ./protein.parm7 -c equil5_3.restrt -r equil5_4.restrt -x equil5.nc -ref equil5_3.restrt
pmemd.cuda -O -i ../in/equil5.in -o equil5_5.out -p ./protein.parm7 -c equil5_4.restrt -r equil5_5.restrt -x equil5.nc -ref equil5_4.restrt
pmemd.cuda -O -i ../in/md.in -o md_${P}_${com_n}.out -p ./protein.parm7 -c equil5_5.restrt -r md.restrt -x md.nc
EOF
Related
I have a bash script:
#!/bin/bash
time srun -p my_partition -c 1 --mem=4G my_code -i my_file_1 -o my_output_file_1
time srun -p my_partition -c 1 --mem=4G my_code -i my_file_2 -o my_output_file_2
time srun -p my_partition -c 1 --mem=4G my_code -i my_file_3 -o my_output_file_3
time srun -p my_partition -c 1 --mem=4G my_code -i my_file_4 -o my_output_file_4
I want to know the average memory usage for each step (printed after the real/user/sys time) while the script is running.
I have tried
#!/bin/bash
time srun -p my_partition -c 1 --mem=4G --job-name"my_job" my_code -i my_file_1 -o my_output_file_1
time srun -p my_partition -c 1 --mem=4G --job-name"my_job" my_code -i my_file_2 -o my_output_file_2
time srun -p my_partition -c 1 --mem=4G --job-name"my_job" my_code -i my_file_3 -o my_output_file_3
time srun -p my_partition -c 1 --mem=4G --job-name"my_job" my_code -i my_file_4 -o my_output_file_4
sstat -a -j my_job --format=JobName,AveRSS,MaxRSS
You can try
#!/bin/bash
time srun -p my_partition -c 1 --mem=4G --job-name"my_job" my_code -i my_file_1 -o my_output_file_1
sstat -j ${SLURM_JOB_ID}.1 --format=JobName,AveRSS,MaxRSS
time srun -p my_partition -c 1 --mem=4G --job-name"my_job" my_code -i my_file_2 -o my_output_file_2
sstat -j ${SLURM_JOB_ID}.2 --format=JobName,AveRSS,MaxRSS
time srun -p my_partition -c 1 --mem=4G --job-name"my_job" my_code -i my_file_3 -o my_output_file_3
sstat -j ${SLURM_JOB_ID}.3 --format=JobName,AveRSS,MaxRSS
time srun -p my_partition -c 1 --mem=4G --job-name"my_job" my_code -i my_file_4 -o my_output_file_4
sstat -j ${SLURM_JOB_ID}.4 --format=JobName,AveRSS,MaxRSS
This shows the last saved screenshot (on my Desktop path):
ls -t | head -n1
This prints perfectly:
lp -o -scaling=50 -o media=Custom.60x42mm -o page-left=0 -o page-right=0 -o page-top=5 -o page-bottom=5 image.png
How does one combine them?
Without really knowing what I'm doing I've tried this:
ls -t | head -n1 |awk '{lp -o -scaling=50 -o media=Custom.60x42mm -o page-left=0 -o page-right=0 -o page-top=5 -o page-bottom=5 $0}'
which, naturally fails:
lp -o -scaling=50 -o media=Custom.60x42mm -o page-left=0 -o page-right=0 -o page-top=5 -o page-bottom=5 "$(ls -t | head -n1)"
Or more clear:
filetouse="$(ls -t | head -n1)"
lpoptions=( -o -scaling=50 -o media=Custom.60x42mm -o page-left=0 -o page-right=0 -o page-top=5 -o page-bottom=5 )
lp "${lpoptions[#]}" "${filetouse}"
Ok, just managed to do it.
This worked:
ls -t | head -n1 | xargs -I {} lp -o -scaling=50 -o media=Custom.60x42mm -o page-left=0 -o page-right=0 -o page-top=5 -o page-bottom=5 {}
Thanks to this question.
When running make I have the following compilation error:
/bin/sh: 1: /installed/CoinAll/include/coin: Permission denied
This is the Makefile:
#
P=farmer
#
EXE=$(P)
OBJS=main-farmer.o model-farmer.o param-farmer.o pm.h
ADDLIBS=-D.
ADDINCFLAGS=-I.
SRCDIR=~/coin-projects
##########
CXX=g++
CXXFLAGS=-O3 -fomit-frame-pointer -pipe -DNDEBUG -pedantic-errors -Wimplicit -Wparentheses -Wreturn-type -Wcast-qual -Wall -Wpointer-arith -Wwrite-strings -Wconversion
CXXLINKFLAGS=-Wl,--rpath -Wl,/installed/CoinAll/lib
CC=gcc
CFLAGS=-03 -fomit-frame-pointer -pipe -DNDEBUG -pedantic-errors -Wimplicit -Wparentheses -Wsequence-point -Wreturn-type -Wcast-qual -Wall
COININCDIR=/installed/CoinAll/include/coin
# COIN-OR libs
COINLIBDIR=/installed/CoinAll/lib
# Clp
LIBS=-L$(COINLIBDIR) -lCbc -lCgl -lOsiClp -lOsi -lClp -lCoinUtils -lm \
`cat $(COINLIBDIR)/cgl_addlibs.txt` \
`cat $(COINLIBDIR)/clp_addlibs.txt` \
`cat $(COINLIBDIR)/coinutils_addlibs.txt`
INCL=-I`$(CYGPATH_W)$(COININCDIR)`$(ADDINCFLAGS)
CYGPATH_W=
CLEANFILES=\
addBits.o addBits \
addColumns.o addColumns \
addRows.o addRows \
decompose.o decompose \
defaults.o defaults \
driver2.o driver2 \
driver.o driver \
driverC.o driverC \
dualCuts.o dualCuts \
ekk.o ekk \
ekk_interface.o ekk_interface \
hello.o hello \
makeDual.o makeDual \
minimum.o minimum \
network.o network \
piece.o piece \
rowColumn.o rowColumn \
sprint2.o sprint2 \
sprint.o sprint \
testBarrier.o testBarrier \
testBasis.o testBasis \
testGub2.o testGub2 \
testGub.o testGub \
testQP.o testQP \
useVolume.o useVolume
# Part 3
#
all: $(EXE)
.SUFFIXES: .cpp .c .o .obj
$(EXE):$(OBJS)
bla=;
for file in $(OBJS); do bla="$$bla `$(CYGPATH_W) $$file`"; done; \
$(CXX) $(CXXLINKFLAGS) $(CXXFLAGS) -o $# $$bla $(ADDLIBS) $(LIBS)
####
########
############
########
####
clean:
rm -rf $(CLEANFILES)
.cpp.o:
$(CXX) $(CXXFLAGS) $(INCL) -c -o $# `test -f '$<' || echo '$(SRCDIR)/'`$<
.cpp.obj:
$(CXX) $(CXXFLAGS) $(INCL) -c -o $# `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(SRCDIR)/$<'; fi`
.c.o:
$(CC) $(CFLAGS) $(INCL) -c -o $# `test -f '$<' || echo '$(SRCDIR)/'`$<
.c.obj:
$(CC) $(CFLAGS) $(INCL) -c -o $# `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(SRCDIR)/$<'; fi`
I have set the permissions as rwx for /installed/CoinAll/include/coin and for all of its files.
Thanks.
It seems to me as if the Makefile is trying to execute the program /installed/CoinAll/include/coin which instead is a directory. It does not matter how you chmod a directory, it will still not be possible to execute as a program.
The following line:
INCL=-I$(CYGPATH_W)$(COININCDIR)$(ADDINCFLAGS)
in combination with lines like this:
$(CXX) $(CXXFLAGS) $(INCL) -c -o $# `test -f '$<' || echo '$(SRCDIR)/'`$<
... will evaluate to commands like:
g++ (a lot of c++-flags) -I`installed/CoinAll/include/coin` -c -o...
as both $(CYGPATH_W) and $(ADDINCFLAGS) are empty.
When the shell executes a command containing backticks "`"it will replace the text between the backticks with the output from the command between the backticks. Try this:
echo `ls /`
I had this error and it was my anti-virus. Turned on, I get the same error you do. Off, it works just fine. Then turning the anti-virus back on, same error as you get. It was my anti-virus so try turning all it's features off temporarily.
I have to modify an broken project which has errors in Makefile. However, I'm new to libtool and couldn't figure out where I should modify in the Makefile. The error is
../libpsc/.libs/libpsc.a(push_part_1vb_mix.o):(.rodata+0x38): undefined reference to `psc_push_particles_1vb_ps2_ops'
The object file which contains psc_push_particles_1vb_ps2_ops is located in ../libpsc/sse2 folder. How to modify the Makefile to let the linker find this object file? I attached portion of the Makefile. Any suggestions will be appreciated. Thanks in advance!
# Makefile.in generated by automake 1.11.6 from Makefile.am.
# src/Makefile. Generated from Makefile.in by configure.
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
# Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
am__make_dryrun = \
{ \
am__dry=no; \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
echo 'am--echo: ; #echo "AM" OK' | $(MAKE) -f - 2>/dev/null \
| grep '^AM OK$$' >/dev/null || am__dry=yes;; \
*) \
for am__flg in $$MAKEFLAGS; do \
case $$am__flg in \
*=*|--*) ;; \
*n*) am__dry=yes; break;; \
esac; \
done;; \
esac; \
test $$am__dry = yes; \
}
pkgdatadir = $(datadir)/psc
pkgincludedir = $(includedir)/psc
pkglibdir = $(libdir)/psc
pkglibexecdir = $(libexecdir)/psc
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = x86_64-unknown-linux-gnu
host_triplet = x86_64-unknown-linux-gnu
bin_PROGRAMS = psc_es1$(EXEEXT) psc_bohm$(EXEEXT) psc_spitzer$(EXEEXT) \
psc_kelvin_helmholtz$(EXEEXT) \
psc_kelvin_helmholtz_double$(EXEEXT) psc_mirror$(EXEEXT) \
psc_harris$(EXEEXT) psc_bubble$(EXEEXT) psc_bubble_yz$(EXEEXT) \
psc_test_emission$(EXEEXT) psc_test_singlepart$(EXEEXT) \
psc_test_microsphere$(EXEEXT) psc_photon_test$(EXEEXT) \
psc_test_twoparticles$(EXEEXT) psc_test_heating$(EXEEXT) \
psc_test_fdtd$(EXEEXT)
subdir = src
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_compiler_flags.m4 \
$(top_srcdir)/m4/ax_check_hdf5.m4 $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__installdirs = "$(DESTDIR)$(bindir)"
PROGRAMS = $(bin_PROGRAMS)
psc_bohm_SOURCES = psc_bohm.c
psc_bohm_OBJECTS = psc_bohm.$(OBJEXT)
psc_bohm_LDADD = $(LDADD)
psc_bohm_DEPENDENCIES = libpsc/libpsc.la libmrc/src/libmrc.la
AM_V_lt = $(am__v_lt_$(V))
am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
am__v_lt_0 = --silent
psc_bubble_SOURCES = psc_bubble.c
# Skip hundreds of lines...
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
include ./$(DEPDIR)/dummy.Po
include ./$(DEPDIR)/psc_bohm.Po
include ./$(DEPDIR)/psc_bubble.Po
include ./$(DEPDIR)/psc_bubble_yz.Po
include ./$(DEPDIR)/psc_es1.Po
include ./$(DEPDIR)/psc_harris.Po
include ./$(DEPDIR)/psc_kelvin_helmholtz.Po
include ./$(DEPDIR)/psc_kelvin_helmholtz_double.Po
include ./$(DEPDIR)/psc_mirror.Po
include ./$(DEPDIR)/psc_photon_test.Po
include ./$(DEPDIR)/psc_spitzer.Po
include ./$(DEPDIR)/psc_test_emission.Po
include ./$(DEPDIR)/psc_test_fdtd.Po
include ./$(DEPDIR)/psc_test_heating.Po
include ./$(DEPDIR)/psc_test_microsphere.Po
include ./$(DEPDIR)/psc_test_singlepart.Po
include ./$(DEPDIR)/psc_test_twoparticles.Po
.c.o:
$(AM_V_CC)depbase=`echo $# | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
$(COMPILE) -MT $# -MD -MP -MF $$depbase.Tpo -c -o $# $< &&\
$(am__mv) $$depbase.Tpo $$depbase.Po
# $(AM_V_CC)source='$<' object='$#' libtool=no \
# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
# $(AM_V_CC_no)$(COMPILE) -c -o $# $<
.c.obj:
$(AM_V_CC)depbase=`echo $# | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
$(COMPILE) -MT $# -MD -MP -MF $$depbase.Tpo -c -o $# `$(CYGPATH_W) '$<'` &&\
$(am__mv) $$depbase.Tpo $$depbase.Po
# $(AM_V_CC)source='$<' object='$#' libtool=no \
# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
# $(AM_V_CC_no)$(COMPILE) -c -o $# `$(CYGPATH_W) '$<'`
.c.lo:
$(AM_V_CC)depbase=`echo $# | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
$(LTCOMPILE) -MT $# -MD -MP -MF $$depbase.Tpo -c -o $# $< &&\
$(am__mv) $$depbase.Tpo $$depbase.Plo
# $(AM_V_CC)source='$<' object='$#' libtool=yes \
# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
# $(AM_V_CC_no)$(LTCOMPILE) -c -o $# $<
.cxx.o:
$(AM_V_CXX)depbase=`echo $# | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
$(CXXCOMPILE) -MT $# -MD -MP -MF $$depbase.Tpo -c -o $# $< &&\
$(am__mv) $$depbase.Tpo $$depbase.Po
# $(AM_V_CXX)source='$<' object='$#' libtool=no \
# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
# $(AM_V_CXX_no)$(CXXCOMPILE) -c -o $# $<
.cxx.obj:
$(AM_V_CXX)depbase=`echo $# | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
$(CXXCOMPILE) -MT $# -MD -MP -MF $$depbase.Tpo -c -o $# `$(CYGPATH_W) '$<'` &&\
$(am__mv) $$depbase.Tpo $$depbase.Po
# $(AM_V_CXX)source='$<' object='$#' libtool=no \
# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
# $(AM_V_CXX_no)$(CXXCOMPILE) -c -o $# `$(CYGPATH_W) '$<'`
.cxx.lo:
$(AM_V_CXX)depbase=`echo $# | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
$(LTCXXCOMPILE) -MT $# -MD -MP -MF $$depbase.Tpo -c -o $# $< &&\
$(am__mv) $$depbase.Tpo $$depbase.Plo
# $(AM_V_CXX)source='$<' object='$#' libtool=yes \
# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
# $(AM_V_CXX_no)$(LTCXXCOMPILE) -c -o $# $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
# Skipped the lines left
I have some problems converting the attached Makefile to an equivalent CMakeLists.txt .
The build process goes like that :
Generate src/lexer.cpp given src/lexer.l.cpp with flex.
Generate src/parser.cpp given src/parser.y.cpp with bison.
Compile almost anything inside src/ into a .so library.
Recompile them with different flags to generate an executable.
Compile sources inside stdlib/ directories three, output the binaries to build/ so that :
stdlib/std/hashing/md5.cc
Would become
build/std/hashing/md5.so
But i really don't know how to reproduce this process with cmake macros ... any help ?
CXX=g++
WFLAGS= -w
OPTIMIZATION= -O3 -pipe -fomit-frame-pointer -ffast-math
CFLAGS= -Iinclude/ $(WFLAGS) $(OPTIMIZATION)
LFLAGS= -ldl -lpcre -lpthread
LIBXML_CFLAGS= `xml2-config --cflags`
LIBXML_LFLAGS= `xml2-config --libs`
LIBFFI_CFLAGS= `pkg-config libffi --cflags`
LIBFFI_LFLAGS= `pkg-config libffi --libs`
STDLIB_LFLAGS= -ldl -lpcre -lcurl -lpthread $(LIBXML_LFLAGS) $(LIBFFI_LFLAGS)
STDLIB_CFLAGS= $(WFLAGS) -L. -I./include/ $(OPTIMIZATION) -fPIC $(LIBXML_CFLAGS) $(LIBFFI_CFLAGS) -lhybris -lc -shared
PREFIX=/usr
TARGET=hybris
LIBOBJ=src/context.lo \
src/gc.lo \
src/common.lo \
src/engine.lo \
src/node.lo \
src/types.lo \
src/types/binary.lo \
src/types/char.lo \
src/types/float.lo \
src/types/integer.lo \
src/types/map.lo \
src/types/matrix.lo \
src/types/string.lo \
src/types/structure.lo \
src/types/class.lo \
src/types/vector.lo \
src/hashtable.lo \
src/vmem.lo \
src/vcode.lo \
src/parser.lo \
src/lexer.lo
SOURCES=src/common.cpp \
src/gc.cpp \
src/lexer.cpp \
src/context.cpp \
src/hashtable.cpp \
src/vmem.cpp \
src/vcode.cpp \
src/node.cpp \
src/types.cpp \
src/types/binary.cpp \
src/types/char.cpp \
src/types/float.cpp \
src/types/integer.cpp \
src/types/map.cpp \
src/types/matrix.cpp \
src/types/string.cpp \
src/types/structure.cpp \
src/types/class.cpp \
src/types/vector.cpp \
src/engine.cpp \
src/parser.cpp
STDSRC=stdlib/std/hashing/md5.cc \
stdlib/std/hashing/crc32.cc \
stdlib/std/hashing/sha1.cc \
stdlib/std/hashing/sha2.cc \
stdlib/std/io/network/http.cc \
stdlib/std/io/network/tcp.cc \
stdlib/std/io/network/smtp.cc \
stdlib/std/io/file.cc \
stdlib/std/io/console.cc \
stdlib/std/io/xml.cc \
stdlib/std/type/reflection.cc \
stdlib/std/type/string.cc \
stdlib/std/type/matrix.cc \
stdlib/std/type/array.cc \
stdlib/std/type/map.cc \
stdlib/std/type/type.cc \
stdlib/std/type/binary.cc \
stdlib/std/encoding.cc \
stdlib/std/os/dll.cc \
stdlib/std/os/time.cc \
stdlib/std/os/threads.cc \
stdlib/std/os/process.cc \
stdlib/std/gc.cc \
stdlib/std/pcre.cc \
stdlib/std/math.cc
OBJECTS=$(SOURCES:.cpp=.o)
LOBJECTS=$(SOURCES:.cpp=.lo)
STDOBJ=$(patsubst stdlib%.cc,build%.so, $(STDSRC))
all: src/lexer.cpp src/parser.cpp lib hybris stdlib
lib: $(LOBJECTS)
$(CXX) -shared -Wl,-soname,libhybris.so.1 -o lib$(TARGET).so.1.0 $(LIBOBJ)
ln -sf lib$(TARGET).so.1.0 lib$(TARGET).so
ln -sf lib$(TARGET).so.1.0 lib$(TARGET).so.1
hybris: $(OBJECTS)
$(CXX) src/*.o src/types/*.o -o $(TARGET) $(CFLAGS) $(LFLAGS)
stdlib: $(STDOBJ)
.cpp.o:
$(CXX) -c $< -o $# $(CFLAGS)
.cpp.lo:
$(CXX) -c $< -o $# $(CFLAGS) -fPIC
build/%.so: stdlib/%.cc
mkdir -p $(dir $#)
$(CXX) $< -o $# $(STDLIB_CFLAGS) $(STDLIB_LFLAGS)
src/parser.cpp: src/parser.y.cpp
bison -y -d -o $# $?
src/lexer.cpp: src/lexer.l.cpp
flex -o $# $?
For the flex/bison part (warning: untested, I usually have .ypp and .lpp suffixes for parser+lexer files):
cmake_minimum_required(VERSION 2.8)
set(SOURCES src/common.cpp src/gc.cpp src/lexer.cpp ...)
include(FindBISON)
include(FindFLEX)
bison_target(parser src/parser.y.cpp ${CMAKE_CURRENT_BINARY_DIR}/src/parser.cpp)
flex_target(lexer src/module/parametrierung/driverlexer.lpp ${CMAKE_CURRENT_BINARY_DIR}/driverlexer.cpp)
add_flex_bison_dependency(lexer parser)
add_library(libhybris SHARED ${BISON_parser_OUTPUTS} ${FLEX_lexer_OUTPUTS} ${SOURCES})