mirror of
https://github.com/LCPQ/quantum_package
synced 2025-04-16 13:39:32 +02:00
Simplified Makefiles
This commit is contained in:
parent
20ed8c923a
commit
ef42d6ebc4
@ -2,51 +2,27 @@
|
|||||||
#
|
#
|
||||||
# usage:
|
# usage:
|
||||||
# create_Makefile.sh MOs AOs Electrons
|
# create_Makefile.sh MOs AOs Electrons
|
||||||
# Creates the Makefile with the dependencies on other modules given
|
# Creates the Makefile . This command is supposed to be run in a
|
||||||
# in the command line. This command is supposed to be run in a module
|
# module directory.
|
||||||
# directory and searches the dependencies in ../
|
|
||||||
# Thu Apr 3 01:44:41 CEST 2014
|
# Thu Apr 3 01:44:41 CEST 2014
|
||||||
|
|
||||||
DEPS_LONG=""
|
MODULE=$(basename $PWD)
|
||||||
for i in $@
|
|
||||||
do
|
|
||||||
DEPS_LONG+=" $i "
|
|
||||||
DEPS_LONG+=$(cat ${QPACKAGE_ROOT}/src/${i}/NEEDED_MODULES)
|
|
||||||
done
|
|
||||||
|
|
||||||
DEPS=($(
|
if [[ $MODULE == "src" ]]
|
||||||
for d in $DEPS_LONG
|
then
|
||||||
do
|
echo "Error: This script should not be run in the src directory."
|
||||||
echo $d
|
exit 1
|
||||||
done | sort | uniq
|
fi
|
||||||
))
|
|
||||||
|
|
||||||
# Create the NEEDED_MODULES file
|
|
||||||
cat << EOF > NEEDED_MODULES
|
|
||||||
${DEPS[@]}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Create the Makefile
|
|
||||||
cat << EOF > Makefile
|
cat << EOF > Makefile
|
||||||
default: all
|
default: all
|
||||||
|
|
||||||
NEEDED_MODULES=\$(shell cat NEEDED_MODULES)
|
|
||||||
|
|
||||||
# Define here all new external source files and objects.Don't forget to prefix the
|
# Define here all new external source files and objects.Don't forget to prefix the
|
||||||
# object files with IRPF90_temp/
|
# object files with IRPF90_temp/
|
||||||
SRC=
|
SRC=
|
||||||
OBJ=
|
OBJ=
|
||||||
|
|
||||||
include Makefile.depend
|
|
||||||
include \$(QPACKAGE_ROOT)/src/Makefile.config
|
|
||||||
include \$(QPACKAGE_ROOT)/src/Makefile.common
|
include \$(QPACKAGE_ROOT)/src/Makefile.common
|
||||||
include irpf90.make
|
|
||||||
|
|
||||||
irpf90.make: \$(filter-out IRPF90_temp/%, \$(wildcard */*.irp.f)) \$(wildcard *.irp.f) \$(wildcard *.inc.f) Makefile \$(EZFIO) NEEDED_MODULES
|
|
||||||
\$(IRPF90)
|
|
||||||
|
|
||||||
Makefile.depend: NEEDED_MODULES
|
|
||||||
\$(QPACKAGE_ROOT)/scripts/create_Makefile_depend.sh
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
18
scripts/create_Needed_modules.sh
Executable file
18
scripts/create_Needed_modules.sh
Executable file
@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Creates the initial NEEDED_MODULES file.
|
||||||
|
# This script is supposed to run in a module directory.
|
||||||
|
# Thu Apr 3 13:38:38 CEST 2014
|
||||||
|
|
||||||
|
MODULE=$(basename $PWD)
|
||||||
|
|
||||||
|
if [[ $MODULE == "src" ]]
|
||||||
|
then
|
||||||
|
echo "Error: This script should not be run in the src directory."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
OUTPUT=$(${QPACKAGE_ROOT}/scripts/check_dependencies.sh $@)
|
||||||
|
echo ${OUTPUT} > NEEDED_MODULES
|
||||||
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
|||||||
# All remaining aruments are dependencies.
|
# All remaining aruments are dependencies.
|
||||||
# Thu Apr 3 01:44:58 CEST 2014
|
# Thu Apr 3 01:44:58 CEST 2014
|
||||||
|
|
||||||
DEBUG=0
|
DEBUG=1
|
||||||
|
|
||||||
# If DEBUG=1, the print debug info.
|
# If DEBUG=1, the print debug info.
|
||||||
function debug()
|
function debug()
|
||||||
@ -21,18 +21,32 @@ function debug()
|
|||||||
else
|
else
|
||||||
function debug()
|
function debug()
|
||||||
{
|
{
|
||||||
|
:
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
debug $@
|
debug $@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fail()
|
||||||
|
{
|
||||||
|
echo "Error: " $@
|
||||||
|
cd ${QPACKAGE_ROOT}/src
|
||||||
|
rm -rf ${MODULE}
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MODULE=$1
|
MODULE=$1
|
||||||
shift
|
|
||||||
DEPS=$@
|
|
||||||
|
|
||||||
|
# Check command line
|
||||||
|
if [[ -z $MODULE ]]
|
||||||
|
then
|
||||||
|
echo "usage: $(basename $0) <NewModuleName>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
shift
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -48,52 +62,75 @@ debug "Module does not already exist: OK"
|
|||||||
|
|
||||||
# Set up dependencies
|
# Set up dependencies
|
||||||
ALL_MODULES=$(cat NEEDED_MODULES)
|
ALL_MODULES=$(cat NEEDED_MODULES)
|
||||||
|
echo "Select which modules you are sure you will need: (press q to quit)"
|
||||||
|
NEEDED_MODULES=""
|
||||||
|
select M in ${ALL_MODULES}
|
||||||
|
do
|
||||||
|
if [[ -z $M ]]
|
||||||
|
then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
NEEDED_MODULES+=" $M"
|
||||||
|
echo $NEEDED_MODULES
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if [[ 1 -eq 0 ]] ; then # TODO
|
|
||||||
|
|
||||||
# Create module directory and go into it
|
# Create module directory and go into it
|
||||||
if [[ ! mkdir ${QPACKAGE_ROOT}/src/${MODULE} ]]
|
mkdir ${QPACKAGE_ROOT}/src/${MODULE}
|
||||||
|
if [[ $? != 0 ]]
|
||||||
then
|
then
|
||||||
print "Unable to create module directory."
|
echo "Error: Unable to create module directory."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -d ${QPACKAGE_ROOT}/src/${MODULE} ]]
|
if [[ ! -d ${QPACKAGE_ROOT}/src/${MODULE} ]]
|
||||||
then
|
then
|
||||||
print "Something strange happened: the"
|
echo "Something strange happened: the"
|
||||||
print ${QPACKAGE_ROOT}/src/${MODULE}
|
echo ${QPACKAGE_ROOT}/src/${MODULE}
|
||||||
print "directory was not created."
|
echo "directory was not created."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd ${QPACKAGE_ROOT}/src/${MODULE}
|
cd ${QPACKAGE_ROOT}/src/${MODULE}
|
||||||
if [[ ${PWD} != ${QPACKAGE_ROOT}/src/${MODULE} ]]
|
if [[ ${PWD} != ${QPACKAGE_ROOT}/src/${MODULE} ]]
|
||||||
then
|
then
|
||||||
print "Something strange happened: we should be in"
|
echo "Something strange happened: we should be in"
|
||||||
print ${QPACKAGE_ROOT}/src/${MODULE}
|
echo ${QPACKAGE_ROOT}/src/${MODULE}
|
||||||
print "but we are in"
|
echo "but we are in"
|
||||||
print ${PWD}
|
echo ${PWD}
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
debug "Module directory is created."
|
debug "Module directory is created."
|
||||||
|
|
||||||
|
|
||||||
fi # TODO
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Create the Makefile
|
# Create the Makefile
|
||||||
${QPACKAGE_ROOT}/create_Makefile.sh
|
${QPACKAGE_ROOT}/scripts/create_Makefile.sh || fail "Unable to create Makefile"
|
||||||
|
if [[ ! -f Makefile ]]
|
||||||
|
then
|
||||||
|
fail "Makefile was not created"
|
||||||
|
fi
|
||||||
|
debug "Makefile created"
|
||||||
|
|
||||||
|
# Create the NEEDED_MODULES file
|
||||||
|
${QPACKAGE_ROOT}/scripts/create_Needed_modules.sh ${NEEDED_MODULES} || fail "Unable to create the NEEDED_MODULES file"
|
||||||
|
if [[ ! -f NEEDED_MODULES ]]
|
||||||
|
then
|
||||||
|
fail "NEEDED_MODULES was not created"
|
||||||
|
fi
|
||||||
|
|
||||||
|
debug "NEEDED_MODULES created"
|
||||||
|
|
||||||
|
|
||||||
|
# Create rst templates
|
||||||
|
${QPACKAGE_ROOT}/scripts/create_rst_templates.sh || fail "Unable to create rst templates"
|
||||||
|
|
||||||
|
|
||||||
# Update module list in main NEEDED_MODULES
|
# Update module list in main NEEDED_MODULES
|
||||||
ALL_MODULES+=" ${MODULE}"
|
ALL_MODULES+=" ${MODULE}"
|
||||||
cd ${QPACKAGE_ROOT}/src
|
echo ${ALL_MODULES} > ${QPACKAGE_ROOT}/src/NEEDED_MODULES
|
||||||
echo ${ALL_MODULES} > NEEDED_MODULES
|
|
||||||
debug "Updated NEEDED_MODULES"
|
debug "Updated NEEDED_MODULES"
|
||||||
|
|
||||||
|
|
||||||
|
58
scripts/create_rst_templates.sh
Executable file
58
scripts/create_rst_templates.sh
Executable file
@ -0,0 +1,58 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Creates the rst files when creating a new module.
|
||||||
|
# Thu Apr 3 11:54:16 CEST 2014
|
||||||
|
|
||||||
|
MODULE=$(basename $PWD)
|
||||||
|
|
||||||
|
if [[ $MODULE == "src" ]]
|
||||||
|
then
|
||||||
|
echo "Error: This script should not be run in the src directory."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
function asksure() {
|
||||||
|
echo -n $@ "(Y/N) "
|
||||||
|
while read -r -n 1 -s answer; do
|
||||||
|
if [[ $answer = [YyNn] ]]; then
|
||||||
|
[[ $answer = [Yy] ]] && retval=0
|
||||||
|
[[ $answer = [Nn] ]] && retval=1
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
return $retval
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ -f README.rst ]]
|
||||||
|
then
|
||||||
|
asksure "Overwrite existing README.rst file?" || exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
UNDERLINE="======="
|
||||||
|
declare -i i=0
|
||||||
|
while [[ i -lt ${#MODULE} ]]
|
||||||
|
do
|
||||||
|
UNDERLINE+="="
|
||||||
|
i+=1
|
||||||
|
done
|
||||||
|
|
||||||
|
cat << EOF > README.rst
|
||||||
|
$UNDERLINE
|
||||||
|
$MODULE Module
|
||||||
|
$UNDERLINE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Assumptions
|
||||||
|
-----------
|
||||||
|
|
||||||
|
.. include:: ./ASSUMPTIONS.rst
|
||||||
|
|
||||||
|
|
||||||
|
Needed Modules
|
||||||
|
--------------
|
||||||
|
|
||||||
|
.. include:: ./NEEDED_MODULES
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
@ -11,7 +11,7 @@ NEEDED_MODULES_OK=$(shell X=`$(QPACKAGE_ROOT)/scripts/check_dependencies.sh $(NE
|
|||||||
ifneq ($(NEEDED_MODULES_OK),OK)
|
ifneq ($(NEEDED_MODULES_OK),OK)
|
||||||
$(info ---------------------)
|
$(info ---------------------)
|
||||||
$(info Your NEEDED_MODULES file is inconsistent. It should be:)
|
$(info Your NEEDED_MODULES file is inconsistent. It should be:)
|
||||||
$(info $(NEEDED_MODULES))
|
$(info $(NEEDED_MODULES_OK))
|
||||||
$(info ---------------------)
|
$(info ---------------------)
|
||||||
$(error )
|
$(error )
|
||||||
endif
|
endif
|
||||||
@ -21,6 +21,8 @@ ifeq ($(IRP_VERSION_OK),False)
|
|||||||
$(error 'IRPF90 version >= 1.3 is required')
|
$(error 'IRPF90 version >= 1.3 is required')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
README_RST_OK=$(shell ls README.rst || echo Failed)
|
||||||
|
ASSUMPTIONS_RST_OK=$(shell ls ASSUMPTIONS.rst || echo Failed)
|
||||||
|
|
||||||
MAKEFILE_OK=$(shell ls $(QPACKAGE_ROOT)/src/Makefile.config 2> /dev/null && echo True || echo False)
|
MAKEFILE_OK=$(shell ls $(QPACKAGE_ROOT)/src/Makefile.config 2> /dev/null && echo True || echo False)
|
||||||
ifeq ($(MAKEFILE_OK),False)
|
ifeq ($(MAKEFILE_OK),False)
|
||||||
|
@ -1 +1 @@
|
|||||||
AOs Bitmask Electrons Ezfio_files MOs Nuclei Output Utils
|
AOs Bitmask Electrons Ezfio_files MOs Nuclei Output Utils Mimi
|
||||||
|
@ -26,7 +26,7 @@ ReStructured Text format to enable the automatic generation of the Sphinx
|
|||||||
documentation.
|
documentation.
|
||||||
|
|
||||||
When the current module depends on other modules, the list of modules should
|
When the current module depends on other modules, the list of modules should
|
||||||
be added in the Makefile in the ``INCLUDE_DIRS`` variable.
|
be added in the ``NEEDED_MODULES`` file.
|
||||||
|
|
||||||
|
|
||||||
Creating a new module
|
Creating a new module
|
||||||
|
Loading…
x
Reference in New Issue
Block a user