Consider the following:
SRCS = somefile.c util/someother.c ../src/more.c
%.o : %.c
$(GCC) -MD -c $< -o $# -Wp,-MD,.deps/$*.d
#cp .deps/$*.d .deps/$*.P; \
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
-e '/^$$/ d' -e 's/$$/ :/' < .deps/$*.d >> .deps/$*.P; \
rm -f .deps/$*.d
-include $(SRCS:%.c=.deps/%.P)
How would I change the above so that the .o files end up in ./? Currently they build in the directory the source file exists in and that's bad.
I'd do it this way:
SRCS = somefile.c someother.c more.c
%.o : %.c
[same as before]
-include $(SRCS:%.c=.deps/%.P)
vpath %.c util ../src
Related
I'am starting using Linux and I have some trouble using some stm32f4 libraries for my project gcc-testing.
All the CMSIS programs needed are inside the STM32F4_Discovery_FW_V1.1.0 and the project is arranged like this:
~
|__
| |
| STM32F4XX
| |
src STM32F4_Discovery_FW_V1.1.0
|
ggc-testing
|
makefile
main.c
stm32f4xx_config.h
stm32_flash.ld
system_stm32f4xx.c
The main.c and the system_stm32f4xx.c use the stm32f4xx.h file that is inside the STM32F4_Discovery_FW_V1.1.0/Libraries/CMSIS/ST/STM32F4xx/Include
The error I get from the terminal is:
Make file console error
My make file:
PROJ_NAME=main
STM_DIR=~/STM32F4XX/STM32F4-Discovery_FW_V1.1.0
STM_SRC = $(STM_DIR)/Libraries/STM32F4xx_StdPeriph_Driver/src
vpath %.c $(STM_SRC)
SRCS = main.c
SRCS += system_stm32f4xx.c
SRCS += $(STM_DIR)/Libraries/CMSIS/ST/STM32F4xx/Source/Templates/TrueSTUDIO/startup_stm32f4xx.s
INC_DIRS = $(STM_DIR)/Utilities/STM32F4-Discovery
INC_DIRS += $(STM_DIR)/Libraries/CMSIS/Include
INC_DIRS += $(STM_DIR)/Libraries/CMSIS/ST/STM32F4xx/Include
INC_DIRS += $(STM_DIR)/Libraries/STM32F4xx_StdPeriph_Driver/inc
INC_DIRS += .
TOOLS_DIR = /opt/gcc-arm-embedded/gcc-arm-none-eabi-4_7-2013q1/bin
CC = arm-none-eabi-gcc
OBJCOPY = arm-none-eabi-objcopy
GDB = arm-none-eabi-gdb
INCLUDE = $(addprefix -I,$(INC_DIRS))
DEFS = -DUSE_STDPERIPH_DRIVER
CFLAGS = -ggdb
CFLAGS += -O0
CFLAGS += -Wall -Wextra -Warray-bounds
CFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m4 -mthumb-interwork
CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
LFLAGS = -Tstm32_flash.ld
.PHONY: $(PROJ_NAME)
$(PROJ_NAME): $(PROJ_NAME).elf
$(PROJ_NAME).elf: $(SRCS)
$(CC) $(INCLUDE) $(DEFS) $(CFLAGS) $(LFLAGS) $^ -o $#
$(OBJCOPY) -O ihex $(PROJ_NAME).elf $(PROJ_NAME).hex
$(OBJCOPY) -O binary $(PROJ_NAME).elf $(PROJ_NAME).bin
clean:
rm -f *.o $(PROJ_NAME).elf $(PROJ_NAME).hex $(PROJ_NAME).bin
# Flash the STM32F4
flash:
st-flash write $(PROJ_NAME).bin 0x8000000
.PHONY: debug
debug:
# before you start gdb, you must start st-util
$(GDB) $(PROJ_NAME).elf
Hope enyne can help with this.
After gnu make generates a cmd-line (eg gcc), use of a ~ would rely on make executing a shell and the shell expanding an arg with a leading unquoted ~. Based on your line with $(addprefix, try adding a space between -I and ,$(INC_DIRS)
However, the overhead from executing a shell can be undesirable and the extra exec is often easy to avoid; for this case, replace ~ with $(HOME)
Example Makefile :
SUBDIR := some/incdir
TILDE_SUBDIR := ~/$(SUBDIR)
NOT_DELIM := $(addprefix -I,$(TILDE_SUBDIR))
DELIM_INC := $(addprefix -I ,$(TILDE_SUBDIR))
HOME_SUBDIR := $(HOME)/$(SUBDIR)
PHONY: all
all:
#echo NOT_DELIM $(NOT_DELIM)
#echo DELIM_INC $(DELIM_INC)
#echo HOME_SUBDIR $(HOME_SUBDIR)
Output :
NOT_DELIM -I~/some/incdir
DELIM_INC -I /home/user1/some/incdir
HOME_SUBDIR /home/user1/some/incdir
I have the following makefile:
#.SUFFIXES:
#.SUFFIXES: .F90 .cuf .o
ROOT = /home/ccevallos/finalMIT
SRCDIR := $(ROOT)/external/lib_eigesolve
#F90SRC = $(notdir $(wildcard $(SRCDIR)/*.F90))
#F90OBJS = $(patsubst %.F90,%.o,$(F90SRC))
F90OBJS = eigsolve_vars.o toolbox.o zhegst_gpu.o zhemv_gpu.o zhetd2_gpu.o zhetrd_gpu.o zheevd_gpu.o zhegvdx_gpu.o \
dsygst_gpu.o dsymv_gpu.o dsytd2_gpu.o dsytrd_gpu.o dsyevd_gpu.o dsygvdx_gpu.o
#CUFSRC = $(notdir $(wildcard $(SRCDIR)/*.cuf))
#CUFOBJS = $(patsubst %.cuf,%.o,$(CUFSRC))
CUFOBJS = cusolverDn_m.o
FLAGS = -O3 -mp -pgf90libs -Mcuda=cc60,cuda9.1,ptxinfo -Mlarge_arrays
FLAGS2 = -O3 -mp -pgf90libs -Mcuda=cc60,cuda9.1,ptxinfo,maxregcount:64 -Mlarge_arrays
FLAGS3 = -O3 -mp -pgf90libs -Mcuda=cc60,cuda9.1,ptxinfo,nordc,maxregcount:255 -Mlarge_arrays
.PHONY: all
all: lib_eigsolve.a
zhetd2_gpu.o : zhetd2_gpu.F90
pgf90 -c ${FLAGS2} ${OPTFLAGS} $*.F90 -o $*.o
zhemv_gpu.o : zhemv_gpu.F90
pgf90 -c ${FLAGS3} ${OPTFLAGS} $*.F90 -o $*.o
dsytd2_gpu.o : dsytd2_gpu.F90
pgf90 -c ${FLAGS2} ${OPTFLAGS} $*.F90 -o $*.o
dsymv_gpu.o : dsymv_gpu.F90
pgf90 -c ${FLAGS3} ${OPTFLAGS} $*.F90 -o $*.o
cusolverDn_m.o: cusolverDn_m.cuf
pgf90 -c ${FLAGS} ${OPTFLAGS} $*.cuf -o $*.o
%.o: %.F90
pgf90 -c ${FLAGS} ${OPTFLAGS} $*.F90 -o $*.o
lib_eigsolve.a: $(F90OBJS) $(CUFOBJS)
ar rcs $# $^
PHONY: clean
clean:
rm -f lib_eigsolve.a *.mod *.o
This makefile compiles perfectly well, however I basically want to uncomment the lines with # to make this simpler, but when I do that only
ar rcs lib_eigsolve.a
appears in the terminal, with no object file created, and thus lib_eigsolve.a is empty...
Why is it not compiling the object files?
P.S. You can find this Makefile with some modifications here https://github.com/NVIDIA/Eigensolver_gpu
You have a simple typo in $(SRCDIR): the source directory inside Eigensolver_gpu is called lib_eigsolve not lib_eigesolve.
$ cd ~workarea/playground
$ git clone https://github.com/NVIDIA/Eigensolver_gpu.git
$ ls Eigensolver_gpu/
lib_eigsolve LICENSE README.md test_driver
I then proceeded to create a dummy makefile by copy & pasting the relevant lines from your question:
ROOT := $(HOME)/workarea/playground/Eigensolver_gpu
ifndef FIXED
SRCDIR := $(ROOT)/lib_eigesolve
else
SRCDIR := $(ROOT)/lib_eigsolve
endif
F90SRC = $(notdir $(wildcard $(SRCDIR)/*.F90))
$(info F90SRC '$(F90SRC)')
F90OBJS = $(patsubst %.F90,%.o,$(F90SRC))
$(info F90OBJS '$(F90OBJS)')
CUFSRC = $(notdir $(wildcard $(SRCDIR)/*.cuf))
$(info CUFSRC '$(CUFSRC)')
CUFOBJS = $(patsubst %.cuf,%.o,$(CUFSRC))
$(info CUFOBJS '$(CUFOBJS)')
lib_eigsolve.a: $(F90OBJS) $(CUFOBJS)
echo ar rcs $# $^
Test runs:
$ make
F90SRC ''
F90OBJS ''
CUFSRC ''
CUFOBJS ''
echo ar rcs lib_eigsolve.a
ar rcs lib_eigsolve.a
$ make FIXED=1
F90SRC 'dsyevd_gpu.F90 ... zhemv_gpu.F90'
F90OBJS 'dsyevd_gpu.o ... zhemv_gpu.o'
CUFSRC 'cusolverDn_m.cuf'
CUFOBJS 'cusolverDn_m.o'
make: *** No rule to make target 'dsyevd_gpu.o', needed by 'lib_eigsolve.a'. Stop.
Ensure that $(SRCDIR) has no spaces:
SRCDIR := $(strip ${SRCDIR})
ifneq (1,$(words ${SRCDIR}))
$(error Not without further fiddling, friend)
endif
Specifying the path in the wildcard expression looks strange. When you are executing make directly in the srcdir (make -C lib_eigsolve), you should write
F90SRC = $(notdir $(wildcard *.F90))
or
srcdir = .
F90SRC = $(notdir $(wildcard ${srcdir}/*.F90))
when you want to keep your option for out-of-tree builds.
So in my project I have a src directory and an obj directory. I'm recursively finding the .c and .cpp files in my src directory, and then its corresponding .o file gets put right in the obj directory. So for example if I have a .cpp file: src/dir1/dir2/file.cpp, its corresponding .o file would be obj/file.o. Then I'm generating the rule to get the .o file from the .cpp file using a make foreach function using this code:
rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2)$(filter $(subst *,%,$2),$d))
src = $(call rwildcard,src/,*.cpp *.c)
obj = $(patsubst %,obj/%.o,$(basename $(notdir $(src))))
$(info src: [$(src)])
$(info obj: [$(obj)])
game.exe: $(obj)
g++ $^ -o $#
define objFromSrc
$(1): $(2)
$(info $(1) $(2))
g++ -c $(2) -o $(1)
endef
$(foreach t,$(src),$(call objFromSrc,$(patsubst %,obj/%.o,$(basename $(notdir $(t)))),$(t)))
Here is the output for some example files:
src: [src/dir/main.cpp src/dir/dir2/other3.cpp src/dir/other2.cpp src/other.c]
obj: [obj/main.o obj/other3.o obj/other2.o obj/other.o]
obj/main.o src/dir/main.cpp
obj/other3.o src/dir/dir2/other3.cpp
obj/other2.o src/dir/other2.cpp
obj/other.o src/other.c
makefile:20: *** multiple target patterns. Stop.
You can see the obj variable correctly holds the corresponding .o file names. And the objFromSrc function generates a rule where the target and dependency are correct, but yet I get a multiple target patterns error.
Why am I getting this error and how can I fix it?
You are missing the $(eval) to parse the generated makefile code:
$(eval $(foreach t,$(src),...))
I would also suggest to add an empty line at the end of the multi-line define. Leaving this out is usually calling for trouble when $(eval)uating dynamically generated makefile code.
define objFromSrc
$(1): $(2)
$(info $(1) $(2))
g++ -c $(2) -o $(1)
endef
$(info eval $(foreach t,$(src),...))
BONUS CODE: your recipe is a constant so there is no need to re-generate it for every rule. Use a static pattern rule for $(obj) instead:
.DEFAULT_GOAL := game.exe
obj :=
define objFromSrc
$(1): $(2)
obj += $(1)
endef
$(eval $(foreach t,$(src),...))
$(info obj: [$(obj)])
$(obj): %.o:
g++ -o $# -c $<
game.exe: $(obj)
g++ $^ -o $#
Why am I getting this error and how can I fix it?
All these define and $(call ...) in make produce simple strings. You have to eval it to make the make do what you've ordered (i.e. to create the rule $1 : $2):
$(foreach t,$(src),$(eval $(call objFromSrc,$(patsubst %,obj/%.o,$(basename $(notdir $(t)))),$(t))))
For instance, from variable:
files = dirx/a.cc diry/b.cc dirz/b.cc
I want to effectively have these rules: (without resorting to define/eval)
a_a.o: dirx/a.cc
b_b.o: diry/b.cc
c_c.o: dirz/c.cc
The problem seems unlikely, but this makefile does what you want:
Makefile
VPATH := dirx:diry:dirz
SRCS := a.cc b.cc c.cc
OBJS := $(foreach src,$(SRCS),$(basename $(src))_$(basename $(src)).o)
.PHONY: all clean
.SECONDEXPANSION:
%.o: $$(basename $$(subst _,.,$$*)).cc
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $# $<
all: $(OBJS)
clean:
rm -f $(OBJS)
With directories and files set up as per your example:
$ ls -R
.:
dirx diry dirz Makefile
./dirx:
a.cc
./diry:
b.cc
./dirz:
c.cc
it runs like:
$ make
g++ -c -o a_a.o dirx/a.cc
g++ -c -o b_b.o diry/b.cc
g++ -c -o c_c.o dirz/c.cc
Cribs: -
VPATH
foreach
basename
subst
.SECONDEXPANSION
i have sshd into my OpenShift Drupal install with the intent of changing my Drupal admin password ..however the drush tool does not seem to be installed
[drupal-.rhcloud.com 56f94fb97628e12ab700005f]> drush --help
bash: drush: command not found
[drupal-.rhcloud.com 56f94fb97628e12ab700005f]>
i am using :
Drupal 7
is there something that needs doing to get that drush addition?
it seams openshift drush is not working for every bodies.its happened because of using old PHP version, which is not working by new composer, SO you need to make one DIY app in openshift and install manually drush and new version of php (php >=5.5.0 ).
Drush installing in Openshift RHC
So you could install drush manually by this codes:
mkdir ${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/composer
curl -ss https://getcomposer.org/installer | php -- --install-dir=${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/composer
cd /tmp
rm -rf tt
mkdir tt
cd tt
#wget http://ftp.drupal.org/files/projects/drush-7.x-5.9.tar.gz
wget https://github.com/drush-ops/drush/archive/master.zip && unzip master.zip
rm master.zip
mv * drush
chmod u+x drush/drush
#tar xzf drush-7.x-5.9.tar.gz && rm drush-7.x-5.9.tar.gz && cd drush && mv drush drush_my
mkdir ${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/
mkdir ${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/drush
mv /tmp/tt/drush/* ${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/drush && cd ../..
rm -rf tt
export PATH=${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/drush:$PATH
cd ~/app-root/runtime/repo/.openshift/action_hooks
echo "export PATH=${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/drush:$PATH
#export PATH=${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/composer:$PATH" >> ~/app-root/runtime/repo/.openshift/action_hooks/start
chmod 755 start
echo "export PATH=${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/drush:$PATH
export PATH=${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/composer:$PATH
alias drush='${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/drush/drush'
alias drush='/opt/rh/php54/root/usr/bin/php ${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/drush/drush.php'" >> ~/app-root/data/.bash_profile
cd ${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/drush
php -r "readfile('https://getcomposer.org/installer');" | php
mv composer.phar composer.phar0
php composer.phar0 install
php composer.phar0 update
#composer config --global bin-dir /usr/local/bin
#composer config --global bin-dir /opt/rh/php54/root/usr/bin
composer config --global vendor-dir ${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/composer
php composer install
php ${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/composer/composer.phar --no-interaction --no-ansi --no-scripts --optimize-autoloader --working-dir=${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/drush install
cd ${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/drush
# Drush settings
cp drush.php drush.php0
echo "\$options['uri'] = \$_ENV['OPENSHIFT_APP_DNS'];
\$options['root'] = \$_ENV['OPENSHIFT_REPO_DIR'].'php';" >> drush.php
if [[ -f ${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/drush/drush.php ]]; then
echo "$repo_top = getcwd().'/..';
$options['config'] = $repo_top . '/drush/drushrc.php'; "
else
echo "<?php
$repo_top = getcwd().'/..';
$options['config'] = $repo_top . '/drush/drushrc.php'; " >> drush.php
fi
cat << EOF >>drushrc.php
<?php
ini_set('memory_limit', '256M');
if (array_key_exists('OPENSHIFT_APP_NAME', \$_SERVER)) {
\$src = \$_SERVER;
} else {
\$src = \$_ENV;
}
\$options['uri'] =\$src['OPENSHIFT_APP_DNS'];
\$options['root'] =\$src['OPENSHIFT_REPO_DIR'].'php';
\$options['db-url']=\$src['OPENSHIFT_MYSQL_DB_URL'].\$src['OPENSHIFT_APP_DNS'];
\$options['backup-dir'] = '/tmp';
?>
EOF
echo " \$options['backup-dir'] = '/tmp';">> drushrc.php
#nano drush.php
drush status
#install mysql
: <<'end_long_comment'
#
cd /tmp
wget http://wiki.diahosting.com/down/lnmp/mysql-5.1.46.tar.gz
nohup sh -c "./configure --prefix=${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/mysql --enable-assembler --with-charset=utf8 --enable-thread-safe-client --with-extra-charsets=all --with-big-tables &&
make && make install"> $OPENSHIFT_LOG_DIR/mysql_install.log /dev/null 2>&1 & tail -f $OPENSHIFT_LOG_DIR/mysql_install.log
chown -R mysql:mysql ${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/mysql
cp support-files/my-medium.cnf /etc/my.cnf
sed -i 's#\[mysqld\]#\[mysqld\]\nbasedir=/usr/local/mysql\ndatadir=/var/lib/mysql\n#' /etc/my.cnf
sed -i 's#log-bin=mysql-bin#\#log-bin=mysql-bin#' /etc/my.cnf
sed -i 's#binlog_format=mixed#\#binlog_format=mixed#' /etc/my.cnf
${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/mysql/bin/mysql_install_db --basedir=${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/mysql --datadir=/var/lib/mysql --user=mysql
cp ${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/mysql/share/mysql/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
/etc/init.d/mysqld start
${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/mysql/bin/mysqladmin -u root password $myrootpwd
chkconfig mysqld on
#ln -s ${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/mysql/bin/myisamchk /usr/bin/
#ln -s ${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/mysql/bin/mysql /usr/bin/
#ln -s ${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/mysql/bin/mysqldump /usr/bin/
end_long_comment
cd
export pass=$OPENSHIFT_MYSQL_DB_PASSWORD
export user=$OPENSHIFT_MYSQL_DB_USERNAME
mysql -u $OPENSHIFT_MYSQL_DB_USERNAME
DROP DATABASE drupal2;
CREATE DATABASE drupal2;
#CREATE USER druser#localhost;
#CREATE USER druser2#$OPENSHIFT_MYSQL_DB_HOST;
CREATE USER 'druser'#'$OPENSHIFT_MYSQL_DB_HOST' IDENTIFIED BY 'druser';
#CREATE USER 'juddi'#'$OPENSHIFT_MYSQL_DB_HOST' IDENTIFIED BY 'juddi';
#SET PASSWORD FOR druser#localhost= PASSWORD("password");
SET PASSWORD FOR 'druser'#$OPENSHIFT_MYSQL_DB_HOST= PASSWORD("password");
#GRANT ALL PRIVILEGES ON drupal2.* TO druser#localhost IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON drupal2.* TO $user#$OPENSHIFT_MYSQL_DB_HOST IDENTIFIED BY $pass;
#GRANT ALL PRIVILEGES ON drupal.* TO $OPENSHIFT_MYSQL_DB_USERNAME#$OPENSHIFT_MYSQL_DB_HOST IDENTIFIED BY $OPENSHIFT_MYSQL_DB_PASSWORD;
FLUSH PRIVILEGES;
cd ${OPENSHIFT_HOMEDIR}/app-root/runtime/repo/php
chmod 755 . -R
rm -rf *
if [[ 1=2 ]];then
drush dl openpublic #--drupal-project-rename=folder_name
mv open*/* ./
cd pro*/openpu*
drush make --prepare-install build-openpublic.make openpublic
rm -rf ~/app-root/data/sites/default/settings.php
fi
echo " \$options['backup-dir'] = '/tmp';">> ~/.drush/drushrc.php
cd ${OPENSHIFT_HOMEDIR}/app-root/runtime/repo/php
nohup sh -c "export PATH=${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/drush:$PATH && drush dl openpublic"> $OPENSHIFT_LOG_DIR/drush_site_install_1_1.log /dev/null 2>&1 &
tail -f $OPENSHIFT_LOG_DIR/drush_site_install_1_1.log
cd ${OPENSHIFT_HOMEDIR}/app-root/runtime/repo/php && mv */* './' && cd pro*/openpu*
nohup sh -c "export PATH=${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/drush:$PATH && drush make --prepare-install build-openpublic.make openpublic &&\
cd ${OPENSHIFT_HOMEDIR}/app-root/runtime/repo/php &&\
drush site-install openpublic --db-url=mysql://$OPENSHIFT_MYSQL_DB_USERNAME:$OPENSHIFT_MYSQL_DB_PASSWORD#$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/drupal2 --site-name=${OPENSHIFT_APP_NAME} --account-name='ss' --account-pass='ss' --yes"> $OPENSHIFT_LOG_DIR/drush_site_install_1_2.log /dev/null 2>&1 &
tail -f $OPENSHIFT_LOG_DIR/drush_site_install_1_2.log
#drush site-install weebpal --db-url=mysql://$OPENSHIFT_MYSQL_DB_USERNAME:$OPENSHIFT_MYSQL_DB_PASSWORD#$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/$OPENSHIFT_APP_NAME --site-name=${OPENSHIFT_APP_NAME} --account-name='ss' --account-pass='ss' --account-mail='ss3#elec-lab.tk' --site-mail='ss3#elec-lab.tk' --yes
#nohup sh -c "drush site-install themebrain_profile --db-url=mysql://$OPENSHIFT_MYSQL_DB_USERNAME:$OPENSHIFT_MYSQL_DB_PASSWORD#$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/drupal2 --site-name=${OPENSHIFT_APP_NAME} --account-name='ss' --account-pass='ss' --account-mail='ss3#elec-lab.tk' --site-mail='ss3#elec-lab.tk' --yes ">$OPENSHIFT_LOG_DIR/drush_site_install_1_2.log /dev/null 2>&1 & tail -f $OPENSHIFT_LOG_DIR/drush_site_install_1_2.log
#drush site-install opendeals --db-url=mysql://$OPENSHIFT_MYSQL_DB_USERNAME:$OPENSHIFT_MYSQL_DB_PASSWORD#$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/$OPENSHIFT_APP_NAME --site-name=${OPENSHIFT_APP_NAME} --account-name='ss' --account-pass='ss' --account-mail=ss3#elec-lab.tk --yes
#drush site-install openpublic --db-url=mysql://druser:password#$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/drupal2 --site-name=${OPENSHIFT_APP_NAME} --account-name='ss' --account-pass='ss' --yes
#drush site-install openpublic --site-name=${OPENSHIFT_APP_NAME} --account-pass=$admin_pwd --db-url=mysql://$OPENSHIFT_MYSQL_DB_USERNAME:$OPENSHIFT_MYSQL_DB_PASSWORD#$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/$OPENSHIFT_APP_NAME --yes
#mysql -u $OPENSHIFT_MYSQL_DB_USERNAME -h $OPENSHIFT_MYSQL_DB_HOST drupal <
########DONE ##################
echo " \$options['backup-dir'] = '/tmp';">> ~/.drush/drushrc.php
### drush backup database###
drush sql-dump > /tmp/database-backup.sql
### drush restore database###
mysqldump -u $OPENSHIFT_MYSQL_DB_USERNAME:$OPENSHIFT_MYSQL_DB_PORT $OPENSHIFT_APP_NAME < database-backup.sql
mysqldump -u USERNAME -p'PASSWORD' DATABASENAME > /path/to/backup_dir/database-backup.sql
drush sql-cli < ~/my-sql-dump-file-name.sql
drush bam-backup
####################################
nohup sh -c " wget -P ${OPENSHIFT_HOMEDIR}/app-root/runtime/repo/php --mirror --user=u220290147 --password=ss123456 ftp://93.188.160.83:21/"> $OPENSHIFT_LOG_DIR/python_modules_install_1_1.log /dev/null 2>&1 &
tail -f $OPENSHIFT_LOG_DIR/python_modules_install_1_1.log
cd ${OPENSHIFT_HOMEDIR}/app-root/runtime/repo/php/*
nohup sh -c "zip -r elec-lab.zip . "> $OPENSHIFT_LOG_DIR/zip.log /dev/null 2>&1 &
tail -f $OPENSHIFT_LOG_DIR/zip.log
/tmp/tmp/tb/sites/all/modules
~/app-root/data/sites/all/modules
mkdir ~/app-root/data/sites/all/libraries
mv -n /tmp/tmp/tb/sites/all/libraries/* ~/app-root/data/sites/all/libraries
mkdir ~/app-root/data/sites/all/themes
mv -n /tmp/tmp/tb/sites/all/themes/* ~/app-root/data/sites/all/themes
mv -n /tmp/tmp/tb/sites/all/* ~/app-root/data/sites/all/
mv -n /tmp/tmp/tb/sites/* ~/app-root/data/sites/
mv -n /tmp/tmp/tb/sites/all/modules/* ~/app-root/data/sites/all/modules
mkdir ~/app-root/data/downloads/drupal-7.34/profiles/themebrain_profile
mv -n /tmp/tmp/tb/profiles/themebrain_profile/* ~/app-root/data/downloads/drupal-7.34/profiles/themebrain_profile
mv ~/app-root/runtime/repo/.openshift/install_profiles/standard ~/app-root/runtime/repo/.openshift/install_profiles/standard1
mkdir ~/app-root/runtime/repo/.openshift/install_profiles/standard
mv -n /tmp/op/openpublic-7.x-1.x-dev/profiles/openpublic/* ~/app-root/runtime/repo/.openshift/install_profiles/standard
chmod 755 ~/app-root/data/sites/default/settings.php
rm -rf ~/app-root/data/sites/default/settings.php
chmod 755 ~/app-root/runtime/repo/.openshift/action_hooks/deploy
nohup sh -c "./app-root/runtime/repo/.openshift/action_hooks/deploy "> $OPENSHIFT_LOG_DIR/deploy.log /dev/null 2>&1 & tail -f $OPENSHIFT_LOG_DIR/deploy.log
#tail -f $OPENSHIFT_LOG_DIR/deploy.log
#nohup sh -c "wget http://dl1.sarzamindownload.com/sdlftpuser/92/07/10/Android.Bootcamp_Part2.rar "> $OPENSHIFT_LOG_DIR/zip2.log /dev/null 2>&1 &
#tail -f $OPENSHIFT_LOG_DIR/zip2.log
rm drush_download.py
cat <<'EOF' >> drush_download.py
import subprocess
import ast
st1='"Nodeblock, Follow, Securepages, Addthis, Twitter_pull, Comment_notify, Context_field, Entity_autocomplete, Views_boxes, Delta, Delta_ui, Context_condition_admin_theme, Context_breadcrumb_current_page, Context_bool_field, Nodeconnect, Openpublic_splash, Phase2_profile, Openpublic_breaking_news, Openpublic_comments, Openpublic_base_fields, Openpublic_defaults, Openpublic_home_page_feature, Openpublic_most_popular, Openpublic_person, Openpublic_person_leadership, Openpublic_site_page, Openpublic_webform, Openpublic_editors_choice, Openpublic_captcha, Openpublic_media_room, Openpublic_menu, Openpublic_menu_utility, Openpublic_menu_footer, Openpublic_pages, Openpublic_accessibility, Openpublic_filters, Openpublic_comments_default, Openpublic_webform_defaults"'
st1='"Addthis, Openpublic_splash, Phase2_profile, Openpublic_breaking_news, Openpublic_comments, Openpublic_base_fields, Openpublic_defaults, Openpublic_home_page_feature, Openpublic_most_popular, Openpublic_person, Openpublic_person_leadership, Openpublic_site_page, Openpublic_webform, Openpublic_editors_choice, Openpublic_captcha, Openpublic_media_room, Openpublic_menu, Openpublic_menu_utility, Openpublic_menu_footer, Openpublic_pages, Openpublic_accessibility, Openpublic_filters, Openpublic_comments_default, Openpublic_webform_defaults"'
st1=st1.lower()
st1=st1.replace(',',"','").replace('"',"'")
st2='"['+st1+']"';st2=st2.replace('"','')
ss=ast.literal_eval(st2)
#print ss
print st
for module in ss:
try:
st='drush dl '+module+' -Y ';print st
awk_sort = subprocess.Popen( [st ], stdin= subprocess.PIPE, stdout= subprocess.PIPE,shell=True)
awk_sort.wait()
output = awk_sort.communicate()[0]
print output.rstrip()
except:
print 'module '+module+' could not bin installed !!!'
#print "END"
EOF
#python drush_download.py
drush site-install standard --site-name=${OPENSHIFT_APP_NAME} --account-pass=$admin_pwd --db-url=mysql://$OPENSHIFT_MYSQL_DB_USERNAME:$OPENSHIFT_MYSQL_DB_PASSWORD#$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/$OPENSHIFT_APP_NAME --yes
nohup sh -c "python drush_download.py"> $OPENSHIFT_LOG_DIR/drush_download.log /dev/null 2>&1 &
tail -f $OPENSHIFT_LOG_DIR/drush_download.log
#nohup sh -c "zip -rT9 ferdowsi-elec-labs_tk.zip '${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/tmp/.'"> $OPENSHIFT_LOG_DIR/python_ftp_sync_download.log /dev/null 2>&1 &
#nohup sh -c "cd ${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/tmp/ && zip -rT9 ferdowsi-elec-labs_tk.zip ."> $OPENSHIFT_LOG_DIR/python_ftp_sync_download.log /dev/null 2>&1 &
#tail -f $OPENSHIFT_LOG_DIR/python_ftp_sync_download.log