Skip to content

Commit 6ca4c57

Browse files
committed
Initial commit of the files to transition the build process to using the CMake tool
1 parent ca5adc2 commit 6ca4c57

11 files changed

Lines changed: 521 additions & 102 deletions

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,10 @@
88
*.rnapoly
99
*.rnasubopt
1010

11+
build/
12+
build/*
13+
14+
include/pmfe_build_config.h
15+
wrapper-runner-script/PMFECommandRunner.sh
16+
wrapper-runner-script/PMFEDeveloperCommandRunner.sh
17+

Makefile

Lines changed: 0 additions & 78 deletions
This file was deleted.

Makefile.generic_unix

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# source files
2+
SRC := $(wildcard src/*.cc)
3+
OBJ := $(SRC:.cc=.o)
4+
5+
BINSRC := $(wildcard src/bin-*.cc)
6+
BINOBJ := $(BINSRC:.cc=.o)
7+
8+
TESTSRC := $(wildcard src/test-*.cc)
9+
TESTOBJ := $(TESTSRC:.cc=.o)
10+
11+
LIBOBJ := $(OBJ)
12+
LIBOBJ := $(filter-out $(BINOBJ),$(LIBOBJ))
13+
LIBOBJ := $(filter-out $(TESTOBJ),$(LIBOBJ))
14+
15+
DEP := $(SRC:.cc=.P)
16+
HDR := $(wildcard src/*.h)
17+
18+
# include directories
19+
INCLUDES += -IiB4e
20+
INCLUDES += -I/usr/local/include # For Homebrew
21+
22+
# C++ compiler flags
23+
CXXFLAGS += -Wall -fvisibility=hidden -fvisibility-inlines-hidden -frounding-math -DABI=0
24+
CXXFLAGS += -fPIC
25+
CXXFLAGS += -fopenmp
26+
CXXFLAGS += -Wall
27+
CXXFLAGS += -g
28+
CXXFLAGS += -O3
29+
CXXFLAGS += -Iinclude $(INCLUDES) -I$(shell readlink -f ../cgal/*/include | tr "\n" " " | sed -e 's/ / -I/g') \
30+
-DBOOST_FILESYSTEM_NO_DEPRECATED \
31+
-I$(shell readlink -f ../BoostLocalInstall/include) \
32+
-DCGAL_HEADER_ONLY -UBOOST_DISABLE_THREADS -DBOOST_LOG_DYN_LINK -BOOST_ALL_DYN_LINK \
33+
$(shell pkg-config gmp --cflags) $(shell pkg-config gmpxx --cflags)
34+
CXXFLAGS_BASE := $(CXXFLAGS)
35+
36+
CXX_STDV11= -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=1
37+
CXX_STDV0X= -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0
38+
39+
# library paths
40+
LIBS += -L/usr/local/lib # For Homebrew
41+
LIBS += -L/opt/rh/devtoolset-9/root/usr/lib/gcc/x86_64-redhat-linux/9 -lstdc++
42+
LIBS += $(shell pkg-config gmp --libs) $(shell pkg-config gmpxx --libs)
43+
LIBS += -L$(shell readlink -f ../BoostLocalInstall/lib)
44+
LIBS += -lm
45+
LIBS += -lboost_filesystem
46+
LIBS += -lboost_program_options
47+
LIBS += -lboost_system
48+
LIBS += -lboost_log
49+
LIBS += -frounding-math -lboost_log_setup -lboost_thread -lboost_atomic -lboost_regex -lboost_chrono
50+
LIBS += -Wl,-Bdynamic -lpthread
51+
#LIBS += -Wl,--no-undefined -Wl,--no-allow-shlib-undefined
52+
53+
BIN = pmfe-findmfe pmfe-scorer pmfe-parametrizer pmfe-subopt pmfe-tests
54+
all: $(OBJ) bin_prereqs $(BIN)
55+
56+
-include $(DEP)
57+
58+
debug: CXXFLAGS += -Og
59+
debug: all
60+
61+
bin_prereqs:
62+
@mkdir -p bin
63+
64+
## Note we are having to (re)set the C++ standard to get compatibility in the
65+
## broken, non-cohesive feature sets on the local compiler. This is not an
66+
## exact science, but rather success by trial and error (Sigh.)
67+
pmfe-findmfe: CXXFLAGS:= $(CXX_STDV0X) $(CXXFLAGS_BASE)
68+
pmfe-findmfe: $(LIBOBJ) src/bin-findmfe.o
69+
$(CXX) $(CXXFLAGS) $^ $(LIBS) -o bin/$@
70+
71+
pmfe-scorer: CXXFLAGS:= $(CXX_STDV0X) $(CXXFLAGS_BASE)
72+
pmfe-scorer: $(LIBOBJ) src/bin-scorer.o
73+
$(CXX) $(CXXFLAGS) $^ $(LIBS) -o bin/$@
74+
75+
pmfe-parametrizer: CXXFLAGS:= $(CXX_STDV0X) $(CXXFLAGS_BASE)
76+
pmfe-parametrizer: $(LIBOBJ) src/bin-parametrizer.o
77+
$(CXX) $(CXXFLAGS) $^ $(LIBS) -o bin/$@
78+
79+
pmfe-subopt: CXXFLAGS:= $(CXX_STDV0X) $(CXXFLAGS_BASE)
80+
pmfe-subopt: $(LIBOBJ) src/bin-subopt.o
81+
$(CXX) $(CXXFLAGS) $^ $(LIBS) -o bin/$@
82+
83+
pmfe-tests: CXXFLAGS:= $(CXX_STDV0X) $(CXXFLAGS_BASE)
84+
pmfe-tests: $(LIBOBJ) $(TESTOBJ) src/bin-tests.o
85+
$(CXX) $(CXXFLAGS) $^ $(LIBS) -o bin/$@
86+
87+
%.o: %.cc
88+
$(CXX) -MD $(CXX_STDV0X) $(CXXFLAGS) $(INCLUDES) -o $@ -c $<
89+
@cp $*.d $*.P; \
90+
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
91+
-e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $*.P; \
92+
rm -f $*.d
93+
94+
clean:
95+
-rm -vf $(EXEC) $(OBJ) $(DEP) $(BIN)
96+
97+
install:
98+
99+
uninstall:
100+
101+
.PHONY: clean
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#### AutogenBuildConfigHeader.cmake : Create the PMFE build config header.
2+
#### Author: Maxie D. Schmidt (github.com/maxieds)
3+
#### Created: 2020.11.02
4+
5+
## Set the absolute location of the path to the PMFE sources:
6+
if(APPLE)
7+
execute_process (
8+
COMMAND bash -c "greadlink -f ."
9+
OUTPUT_VARIABLE BuildAbsPath
10+
)
11+
elseif(UNIX AND NOT APPLE)
12+
execute_process (
13+
COMMAND bash -c "readlink -f ."
14+
OUTPUT_VARIABLE BuildAbsPath
15+
)
16+
endif()
17+
18+
## Set the build time datestamp for reference:
19+
execute_process (
20+
COMMAND bash -c "date +'%F @ %T%p (%Y.%m.%d-%H%M%S)'"
21+
OUTPUT_VARIABLE BuildTimeStamp
22+
)
23+
24+
## Create a record of which GitHub commit or tag the PMFE sources reference:
25+
execute_process (
26+
COMMAND bash -c "git --no-pager log -1 --format='%H [-- %h --]'"
27+
OUTPUT_VARIABLE BuildGitCommitHash
28+
)
29+
execute_process (
30+
COMMAND bash -c "git --no-pager log -1 --format='%ai'"
31+
OUTPUT_VARIABLE BuildGitCommitDate
32+
)
33+
34+
## Define all of the file placeholders we will substitute the live configuration data into:
35+
## Syntax: "[SUBST_PLACEHOLDER_NAME]->ActualValue" denotes that we will replace the string
36+
## '${SUBST_PLACEHOLDER_NAME}' with 'ActualValue' below.
37+
list(APPEND PMFEConfigHeaderSubstsList "[CMAKE_VERSION]->${CMAKE_VERSION}")
38+
list(APPEND PMFEConfigHeaderSubstsList "[CMAKE_SYSTEM_VERSION]->${CMAKE_SYSTEM_VERSION}")
39+
list(APPEND PMFEConfigHeaderSubstsList "[CMAKE_SYSTEM_PROCESSOR]->${CMAKE_SYSTEM_PROCESSOR}")
40+
list(APPEND PMFEConfigHeaderSubstsList "[CMAKE_HOST_SYSTEM_NAME]->${CMAKE_HOST_SYSTEM_NAME}")
41+
list(APPEND PMFEConfigHeaderSubstsList "[CMAKE_C_FLAGS]->${CMAKE_C_FLAGS}")
42+
list(APPEND PMFEConfigHeaderSubstsList "[CMAKE_CXX_FLAGS]->${CMAKE_CXX_FLAGS}")
43+
list(APPEND PMFEConfigHeaderSubstsList "[CMAKE_BUILD_TYPE]->${CMAKE_BUILD_TYPE}")
44+
list(APPEND PMFEConfigHeaderSubstsList "[CMAKE_EXE_LINKER_FLAGS]->${CMAKE_EXE_LINKER_FLAGS}")
45+
list(APPEND PMFEConfigHeaderSubstsList "[CMAKE_SHARED_LINKER_FLAGS]->${CMAKE_SHARED_LINKER_FLAGS}")
46+
list(APPEND PMFEConfigHeaderSubstsList "[PMFE_PACKAGE_NAME]->${PMFE_PACKAGE_NAME}")
47+
list(APPEND PMFEConfigHeaderSubstsList "[PMFE_PACKAGE_VERSION]->${PMFE_PACKAGE_VERSION}")
48+
list(APPEND PMFEConfigHeaderSubstsList "[PMFE_PACKAGE_STRING]->${PMFE_PACKAGE_STRING}")
49+
list(APPEND PMFEConfigHeaderSubstsList "[PMFE_BUILD_GIT_COMMIT_HASH]->${BuildGitCommitHash}")
50+
list(APPEND PMFEConfigHeaderSubstsList "[PMFE_BUILD_GIT_COMMIT_DATE]->${BuildGitCommitDate}")
51+
list(APPEND PMFEConfigHeaderSubstsList "[PMFE_BUILD_DATESTAMP]->${BuildTimeStamp}")
52+
list(APPEND PMFEConfigHeaderSubstsList "[PMFE_BUILD_ABS_WORKING_DIR]->${BuildAbsPath}")
53+
54+
## Copy the stub header file to the build-time location:
55+
set(PMFEBuildConfigHeaderStubPath "${buildAbsPath}/include/pmfe_build_config.h.in")
56+
set(PMFEBuildConfigNewHeaderPath "${buildAbsPath}/include/pmfe_build_config.h")
57+
file(
58+
COPY ${PMFEBuildConfigHeaderStubPath}
59+
DESTINATION ${PMFEBuildConfigNewHeaderPath}
60+
)
61+
62+
## Substitute the placeholders in that file with the live build config information:
63+
function(Func_substPMFEConfigHeaderParam "${SUBST_VAR_NAME}" "${SUBST_VAR_VALUE}")
64+
message(DEBUG "Substituting ${SUBST_VAR_NAME} -> ${SUBST_VAR_VALUE} in ${PMFEBuildConfigNewHeaderPath} ...")
65+
execute_process (
66+
COMMAND bash -c "sed -i 's/\$\{${SUBST_VAR_NAME}\}/${SUBST_VAR_VALUE}/' ${PMFEBuildConfigNewHeaderPath}"
67+
)
68+
endfunction(Func_substPMFEConfigHeaderParam)
69+
70+
function(Func_substPMFEConfigHeaderParamFromSpec "${FULL_CONFIG_SUBST_SPEC}")
71+
string(REGEX "(\[[^\ ]+\])->" funcInput_localParamName "${FULL_CONFIG_SUBST_SPEC}")
72+
string(REGEX "->[^\ ]+$" funcInput_localParamValue "${FULL_CONFIG_SUBST_SPEC}")
73+
Func_substPMFEConfigHeaderParam("${funcInput_localParamName}" "${funcInput_localParamValue}")
74+
endfunction(Func_substPMFEConfigHeaderParamFromSpec)
75+
76+
foreach(PMFE_CONFIG_HEADER_SUBST_SPEC ${PMFEConfigHeaderSubstsList})
77+
Func_substPMFEConfigHeaderParamFromSpec("${PMFE_CONFIG_HEADER_SUBST_SPEC}")
78+
endforeach()
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#### PostBuildAutogenWrapperScript.cmake : Create the post-build wrapper / runner script source
2+
#### to run the PMFE utilities with the correct
3+
#### absolute paths local to this build.
4+
#### Author: Maxie D. Schmidt (github.com/maxieds)
5+
#### Created: 2020.11.02
6+
7+
## Set the absolute location of the path to the PMFE sources:
8+
if(APPLE)
9+
execute_process (
10+
COMMAND bash -c "greadlink -f ."
11+
OUTPUT_VARIABLE BuildAbsPath
12+
)
13+
elseif(UNIX AND NOT APPLE)
14+
execute_process (
15+
COMMAND bash -c "readlink -f ."
16+
OUTPUT_VARIABLE BuildAbsPath
17+
)
18+
endif()
19+
20+
## Set the build time datestamp for reference:
21+
execute_process (
22+
COMMAND bash -c "date +'%F @ %T%p (%Y.%m.%d-%H%M%S)'"
23+
OUTPUT_VARIABLE BuildTimeStamp
24+
)
25+
26+
## Create a record of which GitHub commit or tag the PMFE sources reference:
27+
execute_process (
28+
COMMAND bash -c "git --no-pager log -1 --format='%H [-- %h --]'"
29+
OUTPUT_VARIABLE BuildGitCommitHash
30+
)
31+
execute_process (
32+
COMMAND bash -c "git --no-pager log -1 --format='%ai'"
33+
OUTPUT_VARIABLE BuildGitCommitDate
34+
)
35+
36+
## Define all of the file placeholders we will substitute the live configuration data into:
37+
## Syntax: "[SUBST_PLACEHOLDER_NAME]->ActualValue" denotes that we will replace the string
38+
## '${SUBST_PLACEHOLDER_NAME}' with 'ActualValue' below.
39+
list(APPEND PMFEWrapperRunnerScriptSubstsList "[PMFE_BUILD_TIMESTAMP]->${BuildTimeStamp}")
40+
list(APPEND PMFEWrapperRunnerScriptSubstsList "[PMFE_BUILD_GIT_COMMIT_HASH]->${BuildGitCommitHash}")
41+
list(APPEND PMFEWrapperRunnerScriptSubstsList "[PMFE_BUILD_GIT_COMMIT_DATE]->${BuildGitCommitDate}")
42+
list(APPEND PMFEWrapperRunnerScriptSubstsList "[PMFE_BUILD_ABS_BINARY_DIR_PATH]->${BuildAbsPath}")
43+
44+
## Copy the stub header file to the build-time location:
45+
set(PMFEWrapperRunnerScriptStubPath "${buildAbsPath}/wrapper-runner-script/PMFECommandRunner.sh.in")
46+
set(PMFEWrapperRunnerScriptNewPath "${buildAbsPath}/wrapper-runner-script/PMFECommandRunner.sh")
47+
file(
48+
COPY ${PMFEWrapperRunnerScriptStubPath}
49+
DESTINATION ${PMFEWrapperRunnerScriptNewPath}
50+
)
51+
set(PMFEWrapperDevRunnerScriptStubPath "${buildAbsPath}/wrapper-runner-script/PMFEDeveloperCommandRunner.sh.in")
52+
set(PMFEWrapperDevRunnerScriptNewPath "${buildAbsPath}/wrapper-runner-script/PMFEDeveloperCommandRunner.sh")
53+
file(
54+
COPY ${PMFEWrapperDevRunnerScriptStubPath}
55+
DESTINATION ${PMFEWrapperDevRunnerScriptNewPath}
56+
)
57+
58+
## Substitute the placeholders in that file with the live build config information:
59+
function(Func_substPMFEWrapperRunnerScriptParam "${SUBST_VAR_NAME}" "${SUBST_VAR_VALUE}" "${OUTFILE_PATH}")
60+
message(DEBUG "Substituting ${SUBST_VAR_NAME} -> ${SUBST_VAR_VALUE} in ${OUTFILE_PATH} ...")
61+
execute_process (
62+
COMMAND bash -c "sed -i 's/\$\{${SUBST_VAR_NAME}\}/${SUBST_VAR_VALUE}/' ${OUTFILE_PATHh}"
63+
)
64+
endfunction(Func_substPMFEConfigHeaderParam)
65+
66+
function(Func_substPMFEWrapperRunnerScriptParamFromSpec "${FULL_CONFIG_SUBST_SPEC}" "${OUTFILE_PATH}")
67+
string(REGEX "(\[[^\ ]+\])->" FuncInput_localParamName "${FULL_CONFIG_SUBST_SPEC}")
68+
string(REGEX "->[^\ ]+$" FuncInput_localParamValue "${FULL_CONFIG_SUBST_SPEC}")
69+
Func_substPMFEWrapperRunnerScriptParam(
70+
"${FuncInput_localParamName}"
71+
"${FuncInput_localParamValue}"
72+
"${OUTFILE_PATH}"
73+
)
74+
endfunction(Func_substPMFEConfigHeaderParamFromSpec)
75+
76+
foreach(PMFE_RUNNER_SCRIPT_SUBST_SPEC ${PMFEWrapperRunnerScriptSubstsList} "${OUTFILE_PATH}")
77+
Func_substPMFEWrapperRunnerScriptParamFromSpec(
78+
"${PMFE_RUNNER_SCRIPT_SUBST_SPEC}"
79+
"${PMFEWrapperRunnerScriptNewPath}"
80+
)
81+
Func_substPMFEWrapperRunnerScriptParamFromSpec(
82+
"${PMFE_RUNNER_SCRIPT_SUBST_SPEC}"
83+
"${PMFEWrapperDevRunnerScriptNewPath}"
84+
)
85+
endforeach()
86+
87+
message(STATUS "Installed the autogenerated wrapper (binary runner) scripts into: ")
88+
message(STATUS " >> \"${PMFEWrapperRunnerScriptNewPath}\" [user runner script]")
89+
message(STATUS " >> \"${PMFEWrapperRunnerDevScriptNewPath}\" [developer script]\n")

include/nndb_constants.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#ifndef _NNDB_CONSTANTS_H
2323
#define _NNDB_CONSTANTS_H
2424

25+
#include "pmfe_build_config.h"
2526
#include "pmfe_types.h"
2627
#include "rational.h"
2728

@@ -82,7 +83,7 @@ namespace pmfe {
8283

8384
class Turner99: public NNDBConstants {
8485
public:
85-
Turner99(const ParameterVector& params = ParameterVector(), const fs::path& param_dir = "Turner99");
86+
Turner99(const ParameterVector& params = ParameterVector(), const fs::path& param_dir = PMFEBuild::TURNER99_DATA_DIR);
8687

8788
protected:
8889
void initMiscValues(const fs::path& param_dir);

0 commit comments

Comments
 (0)