Skip to content

Commit a9fab63

Browse files
author
abacus_fixer
committed
Fix Makefile build: register new sources and resolve VPATH conflicts
Makefile.Objects: - Register the new .cpp files split in this PR in their object groups - Fix dangling entries: xc_funct_hcth.o -> xc_hcth.o, remove onsite_proj_pw.o, memory.o -> memory_recorder.o, dftu.o -> dftu_lcao.o and other renamed leftovers - Update VPATH for renamed directories (source_lcao/module_hcontainer and module_gint moved to source_hamilt, add source_io subdirectories) - Add an explicit symm_rho_charge.o rule target for source_estate/module_charge/symm_rho.cpp: two symm_rho.cpp files share the name and VPATH resolves to the source_cell one, leaving Symmetry_rho undefined (pre-existing on develop) - Remove the duplicate setup_dftu_pw.o from OBJS_DFTU and drop the orphan dmr_complex.o, which no CMakeLists.txt compiles and which duplicates a DensityMatrix::cal_DMR specialization Makefile: - Set .DEFAULT_GOAL to abacus and pass -f to the sub-make so the default target actually builds instead of stopping after the first rule (the Intel Makefile CI job has been a 0-second no-op because the first rule only generated build_info.h) generate_build_info.sh: - Locate build_info.h.in relative to the script directory so the header is generated regardless of the caller's cwd Verified: full GNU Make build with mpicxx links successfully; ABACUS.mpi --version reports v3.11.0-beta8; tests/01_PW/101_PW_W90 runs to completion with results matching result.ref; CMake xc_ target still compiles on both libxc paths.
1 parent f1528c3 commit a9fab63

3 files changed

Lines changed: 148 additions & 58 deletions

File tree

generate_build_info.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,8 @@ if [ "${USE_CUDA}" == "ON" ]; then
257257
fi
258258
# --- Final File Generation ---
259259

260-
INPUT_FILE="source_io/build_info.h.in"
260+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
261+
INPUT_FILE="${SCRIPT_DIR}/source/source_io/build_info.h.in"
261262

262263
# Use sed to replace all placeholders with detected values
263264
# Note the use of different delimiters (#) for paths to avoid conflicts with /

source/Makefile

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ OBJ_DIR = $(BUILD_DIR)/obj
66
BIN_DIR = $(BUILD_DIR)/bin
77
BUILD_INFO_DIR = $(BUILD_DIR)/source_io
88

9+
# The first rule in this file only generates build_info.h, so make would
10+
# stop after generating that header unless the default goal is set here.
11+
.DEFAULT_GOAL := abacus
12+
913
include $(ABACUS_ROOT)Makefile.vars
1014

1115
#==========================
@@ -252,18 +256,25 @@ ${OBJ_DIR}/parse_args.o: $(ABACUS_ROOT)source_io/parse_args.cpp $(BUILD_INFO_DIR
252256
@mkdir -p $(dir $@)
253257
${CXX} ${OPTS} ${OPTS_MPI} -c ${HONG} $< -o $@
254258

259+
# Explicit rule: source_cell/module_symmetry and source_estate/module_charge
260+
# both contain a symm_rho.cpp. VPATH resolves symm_rho.o to the source_cell
261+
# one (listed first), so the Symmetry_rho implementation needs an explicit
262+
# object name to be compiled from the correct source.
263+
${OBJ_DIR}/symm_rho_charge.o: $(ABACUS_ROOT)source_estate/module_charge/symm_rho.cpp
264+
@mkdir -p $(dir $@)
265+
${CXX} ${OPTS} ${OPTS_MPI} -c ${HONG} $< -o $@
266+
255267
###### END of ABACUS INFO PART ######
256268

257269
#==========================
258270
# MAKING OPTIONS
259271
#==========================
260272
abacus:
261-
@ if [ ! -d $(OBJ_DIR) ]; then mkdir $(OBJ_DIR); fi
262-
@ if [ ! -d $(BIN_DIR) ]; then mkdir $(BIN_DIR); fi
263-
@ $(MAKE) $(BIN_DIR)/${VERSION}.$(suffix)
273+
@ mkdir -p $(OBJ_DIR) $(BIN_DIR)
274+
@ $(MAKE) -f $(firstword $(MAKEFILE_LIST)) $(BIN_DIR)/${VERSION}.$(suffix)
264275

265276
test:
266-
@ $(MAKE) abacus
277+
@ $(MAKE) -f $(firstword $(MAKEFILE_LIST)) abacus
267278
@ cd $(ABACUS_ROOT)../tests/integrate/;sh Autotest.sh -a $(realpath $(BIN_DIR))/ABACUS.mpi -n $(TESTNP)
268279

269280
pw $(BIN_DIR)/${VERSION}-PW.x:
@@ -280,7 +291,8 @@ $(BIN_DIR)/${VERSION}.$(suffix) : ${FP_OBJS} ${PDIAG_OBJS} ${HEADERS}
280291
#==========================
281292
# Note: The specific rule for parse_args.o above is more precise.
282293
# This generic rule will apply to all other .cpp files.
283-
${OBJ_DIR}/%.o:$(realpath $(BIN_DIR))%.cpp
294+
${OBJ_DIR}/%.o:%.cpp
295+
@ mkdir -p $(dir $@)
284296
${CXX} ${OPTS} ${OPTS_MPI} -c ${HONG} $< -o $@
285297

286298
.PHONY:clean test

0 commit comments

Comments
 (0)