How to determine where 'ar' is being called in Makefile? - macos

I'm trying to build Git on OS X. Git depends on libidn2. libidn2 2.0.0 fails:
make all-am
make[3]: Entering directory '/Users/jwalton/Build-Scripts/libidn2-2.0.0/lib'
CC idna.lo
CC lookup.lo
CC decode.lo
CC register.lo
CC bidi.lo
CC version.lo
CC error.lo
CC punycode.lo
CC free.lo
CC data.lo
CC tr46map.lo
CC tables.lo
CC context.lo
CCLD libidn2.la
warning: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm: no name list
warning: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm: no name list
copying selected object files to avoid basename conflicts...
ar: temporary file: No such file or directory
Makefile:1027: recipe for target 'libidn2.la' failed
make[3]: *** [libidn2.la] Error 1
make[3]: Leaving directory '/Users/jwalton/Build-Scripts/libidn2-2.0.0/lib'
Makefile:955: recipe for target 'all' failed
make[2]: *** [all] Error 2
make[2]: Leaving directory '/Users/jwalton/Build-Scripts/libidn2-2.0.0/lib'
Makefile:1065: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/Users/jwalton/Build-Scripts/libidn2-2.0.0'
Makefile:974: recipe for target 'all' failed
make: *** [all] Error 2
My recipe to build libidn2 finds all Makefiles and it fixes AR and ARFLAGS:
if [[ "$IS_DARWIN" -ne "0" ]]; then
for mfile in $(find "$PWD" -name 'Makefile'); do
echo "Fixing Makefile $mfile"
sed -i "" 's|AR = ar|AR = /usr/bin/libtool|g' "$mfile"
sed -i "" 's|ARFLAGS = cr|ARFLAGS = -static -o|g' "$mfile"
done
fi
I've confirmed it fixes all the Makefiles:
$ find $PWD -name Makefile -exec grep 'AR =' {} \; | egrep -iv 'amtar|char'
AR = /usr/bin/libtool
ac_ct_AR = /usr/bin/libtool
AR = /usr/bin/libtool
ac_ct_AR = /usr/bin/libtool
AR = /usr/bin/libtool
ac_ct_AR = /usr/bin/libtool
AR = /usr/bin/libtool
ac_ct_AR = /usr/bin/libtool
AR = /usr/bin/libtool
ac_ct_AR = /usr/bin/libtool
AR = /usr/bin/libtool
ac_ct_AR = /usr/bin/libtool
AR = /usr/bin/libtool
ac_ct_AR = /usr/bin/libtool
AR = /usr/bin/libtool
ac_ct_AR = /usr/bin/libtool
AR = /usr/bin/libtool
ac_ct_AR = /usr/bin/libtool
I also tried AR="/usr/bin/libtool" ARFLAGS="-static -o" ./configure and make AR="/usr/bin/libtool" ARFLAGS="-static -o", but the choices are not honored. It produces additional failed builds.
Makefile debugging support is fairly crappy, so I'm not sure how to proceed. make -d fails even the simplest tasks, like providing a filename and line number. remake -d produces the same unhelpful results. The large project written by someone else aggravates the situation.
$ make -d
...
Putting child 0x7f9bf0c45cf0 (libidn2.la) PID 75531 on the chain.
Live child 0x7f9bf0c45cf0 (libidn2.la) PID 75531
CCLD libidn2.la
warning: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm: no name list
warning: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm: no name list
copying selected object files to avoid basename conflicts...
ar: temporary file: No such file or directory
Reaping losing child 0x7f9bf0c45cf0 PID 75531
Makefile:1027: recipe for target 'libidn2.la' failed
Here's line 1027, which is not the call to ar:
libidn2.la: $(libidn2_la_OBJECTS) $(libidn2_la_DEPENDENCIES) $(EXTRA_libidn2_la\
_DEPENDENCIES)
$(AM_V_CCLD)$(libidn2_la_LINK) -rpath $(libdir) $(libidn2_la_OBJECTS) $\
(libidn2_la_LIBADD) $(LIBS)
How can I locate where ar is being called in the collection of Makefiles?

To a simple understanding of a failing recipe you can:
echo the rule (i.e. echo $(AM_V_CCLD)$(libidn2_la_LINK) ...)
add a second command which fails to stop the make
If you need additional help please reports here the make output after these changes.
In your case the use of makefile option --debug=m can help

Related

Building kernel module: `.ko` not built

I'm trying to package a driver. However, when I compile the driver I don't get the output file CorXtiumCLMX4k.ko as expected, while the Makefile does contain the lines:
obj-m := CorXtiumCLMX4k.o
CorXtiumCLMX4k-objs := $(GDRV_OBJS) $(TARGETLIB)
(Btw any idea what this -objs is for? In the kernel documentation they mention the prefix -y… but I also tried it without success)
The compilation does not give any error at that step… just no .ko file is produced:
salsera_xtium> make: Entering directory '/build/va8hwnknyg6cgzqydl3gm64j8z0vyq2i-source/DALSA/src/xtium/xtium_cl_mx4/driver/kernel/linux'
salsera_xtium> make -C /nix/store/n862ppa5sy8bmnhs801cskcisd6z7fd0-linux-5.4.225-dev/lib/modules/5.4.225/build M=/build/va8hwnknyg6cgzqydl3gm64j8z0vyq2i-source/DALSA/src/xtium/xtium_cl_mx4/driver/kernel/linux IROOT=/build/va8hwnknyg6cgzqydl3gm64j8z0vyq2i-source/DALSA/src/xtium/xtium_cl_mx4/driver/kernel/linux/../../../../.. modules
salsera_xtium> make[1]: Entering directory '/nix/store/n862ppa5sy8bmnhs801cskcisd6z7fd0-linux-5.4.225-dev/lib/modules/5.4.225/build'
salsera_xtium> CC [M] /build/va8hwnknyg6cgzqydl3gm64j8z0vyq2i-source/DALSA/src/xtium/xtium_cl_mx4/driver/kernel/linux/GDrv_Linux.o
salsera_xtium> CC [M] /build/va8hwnknyg6cgzqydl3gm64j8z0vyq2i-source/DALSA/src/xtium/xtium_cl_mx4/driver/kernel/linux/GDrv_LinuxUtil.o
salsera_xtium> CC [M] /build/va8hwnknyg6cgzqydl3gm64j8z0vyq2i-source/DALSA/src/xtium/xtium_cl_mx4/driver/kernel/linux/GDrv_Util.o
salsera_xtium> CC [M] /build/va8hwnknyg6cgzqydl3gm64j8z0vyq2i-source/DALSA/src/xtium/xtium_cl_mx4/driver/kernel/linux/memmanag.o
salsera_xtium> make[1]: Leaving directory '/nix/store/n862ppa5sy8bmnhs801cskcisd6z7fd0-linux-5.4.225-dev/lib/modules/5.4.225/build'
salsera_xtium> make: Leaving directory '/build/va8hwnknyg6cgzqydl3gm64j8z0vyq2i-source/DALSA/src/xtium/xtium_cl_mx4/driver/kernel/linux'
salsera_xtium> cp: cannot stat '/build/va8hwnknyg6cgzqydl3gm64j8z0vyq2i-source/DALSA/src/xtium/xtium_cl_mx4/driver/kernel/linux/CorXtiumCLMX4k.ko': No such file or directory
(note that make takes /nix/…/lib instead of /lib because I'm using Nix so I patched the path accordingly… also I do compile before other libraries that are not shown in this log, see below)
Any idea what could go wrong? I tried to compile with kernel 5.4 (supposed to be supported according to the doc…) and a more recent kernel, none of them work.
Debug informations
If it can be of any help, here is the list of files in the current folder before the compilation starts:
copysources corenv.h CorXtiumCLMX4k26_x86_64_a gdrv.h GDrv_kernel.h GDrv_KernelThread.h GDrv_Linux.c GDrv_LinuxUtil.c GDrv_LinuxUtil.h GDrv_OS.h GDrv_Util.c Makefile sdrv.h sources
At the end, I have:
copysources cormgrlibk.c gdrv.h GDrv_KernelThread.h GDrv_LinuxUtil.c GDrv_OS.h Makefile Module.symvers serialk.c
corenv.h CorXtiumCLMX4k26_x86_64_a GDrv_kernel.h GDrv_Linux.c GDrv_LinuxUtil.h GDrv_Util.c memmanag.c sdrv.h sources
The file CorXtiumCLMX4k26_x86_64_a seems to be some sort of static binary blob:
$ file CorXtiumCLMX4k26_x86_64_a
CorXtiumCLMX4k26_x86_64_a: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), with debug_info, not stripped
$ ldd CorXtiumCLMX4k26_x86_64_a
ldd: warning: you do not have execution permission for `./CorXtiumCLMX4k26_x86_64_a'
not a dynamic executable
(note that I also tried to rename it as CorXtiumCLMX4k.o_shipped with 'TARGETLIB = CorXtiumCLMX4k.o' without success)
Note that latter in the build process (yeah, it continues even after errors), I also get an error:
salsera_xtium> /nix/store/039g378vc3pc3dvi9dzdlrd0i4q93qwf-binutils-2.39/bin/ld: warning: /build/va8hwnknyg6cgzqydl3gm64j8z0vyq2i-source/DALSA/Xtium-CL_MX4/lib/libXtiumCLMX4L_1_0_a has a section extending past end of file
salsera_xtium> /nix/store/039g378vc3pc3dvi9dzdlrd0i4q93qwf-binutils-2.39/bin/ld: error: /build/va8hwnknyg6cgzqydl3gm64j8z0vyq2i-source/DALSA/Xtium-CL_MX4/lib/libXtiumCLMX4L_1_0_a: ELF section name out of range
but I'm not sure if this error is because I'm missing some compilation flags like pic, if the file is just bad, or if it's just that I first need to compile the .ko file properly…
the Makefile looks like:
#-----------------------------------------------------------------------------
# MAKEFILE
# Copyright(C) Teledyne DALSA Inc 2015
# All rights reserved.
#
# Description:
# Makefile for distributed version of the CorXtiumCLMX4 kernel module for Linux
#
#-----------------------------------------------------------------------------
#
# Determine the kernel version being compiled for.
CORKERNEL_MAJOR:=$(shell uname -r | cut -d '.' -f 1)
CORKERNEL_MINOR:=$(shell uname -r | cut -d '.' -f 2)
#
# Kernel version-specific dependencies
# (mainly needed for 2.4 kernel support).
#
ifeq ($(CORKERNEL_MAJOR), 2)
ifeq ($(CORKERNEL_MINOR), 6)
# 2.6 kernel
TARGET_OPTIONS = -DHOSTPC -DPOSIX_HOSTPC -DNEW_CXM_INTERFACE -DEXPORT_SYMTAB
#TARGET_OPTIONS = -DHOSTPC -DPOSIX_HOSTPC -DNEW_CXM_INTERFACE -DEXPORT_SYMTAB -DDEBUG_PRINT
SAPSRCROOT := $(IROOT)/sapera
else
# Not 2.6 kernel - not supported (PCIe hardware).
$(error $(shell echo "Kernel version must be 2.6 or higher to support PCIe hardware"))
endif
else ifeq ($(CORKERNEL_MAJOR), 3)
# 2.6 (or higher kernel)
TARGET_OPTIONS = -DHOSTPC -DPOSIX_HOSTPC -DNEW_CXM_INTERFACE -DEXPORT_SYMTAB
#TARGET_OPTIONS = -DHOSTPC -DPOSIX_HOSTPC -DNEW_CXM_INTERFACE -DEXPORT_SYMTAB -DDEBUG_PRINT
SAPSRCROOT := $(IROOT)/sapera
endif
#
# API Version control information to be embedded.
#
ifndef CORARCH
CORARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/x86_64/x86_64/ )
endif
TARGETNAME = CorXtiumCLMX4k
TARGET = $(TARGETNAME).ko
ifeq ($(CORARCH), x86_64)
TARGETLIB = $(TARGETNAME)26_x86_64_a
CORARCH_OPTIONS= -Dx86_64
else
TARGETLIB = $(TARGETNAME)26_i386_a
CORARCH_OPTIONS= -D__i386__
endif
#
# Include Path for the kernel module.
#
I_CORSERIALCOMMON= $(SAPSRCROOT)/driver/corserial/linux/common
CORSERIALDEV= $(SAPSRCROOT)/driver/corserial/linux/kernel
CORMGRK= $(SAPSRCROOT)/driver/cormanager/kernel
XCELERA_HS_PX8_INC= $(IROOT)/xtium/xtium_cl_mx4/include
CURDIR = $(IROOT)/xtium/xtium_cl_mx4/driver/kernel/linux
INC_COMMON_PATH = -I$(CURDIR) -I$(KERNEL_INCLUDEDIR) -I$(CURDIR) -I$(SAPSRCROOT)/include \
-I$(XCELERA_HS_PX8_INC) -I$(CORMGRK) -I$(I_CORSERIALCOMMON) -I$(CORSERIALDEV)
DISTINSTALLDIR=$(IROOT)/../Xtium-CL_MX4/bin
RUNNINGKERNEL=$(shell uname -r)
INSTALLDIR= /lib/modules/$(RUNNINGKERNEL)/misc
#
# Source Path for the kernel module.
#
#
# Object definitions: Specific files for this library.
# GDrv objects.
GDRV_OBJS = GDrv_Linux.o \
GDrv_LinuxUtil.o \
GDrv_Util.o \
memmanag.o \
cormgrlibk.o \
serialk.o
#
# 2.6 kernel build section
#
INC_PATH = -I$(CURDIR) $(INC_COMMON_PATH)
CFLAGS_MODULE += $(INC_PATH) $(TARGET_OPTIONS) $(CORKERNEL_CONFIG_OPTIONS) \
$(CORARCH_OPTIONS)
EXTRA_CFLAGS += -Wno-parentheses -Wno-missing-braces -Wno-unknown-pragmas \
-Wno-cast-qual -Wno-unused-function -Wno-unused-label
#
# As of kernel 2.6.28 (and later) - versioned module symbol dependencies need to be specified
# explicitly - using absolute paths - to the Module.symvers files for the modules whose
# symbols we depend on.
# (Actually broken in an early 2.6.28 but later fixed).
#
# Prior to 2.6.28 - the kernel build system and module loader would resolve all symbols automatically
#
CORKVER := $(shell uname -r | cut -d '.' -f 3)
CORKTEMP := 28
COMPAREKVER := $(shell echo ${CORKVER}\>=${CORKTEMP} | bc )
ifeq ($(COMPAREKVER),1)
KBUILD_EXTRA_SYMBOLS= $(CORMGRK)/Module.symvers $(CORSERIALDEV)/Module.symvers
else
$(shell cat $(CORMGRK)/Module.symvers > $(CURDIR)/Module.symvers)
$(shell cat $(CORSERIALDEV)/Module.symvers >> $(CURDIR)/Module.symvers)
endif
#
# 2.6 kernel build section
#
ifneq ($(KERNELRELEASE),)
obj-m := CorXtiumCLMX4k.o
CorXtiumCLMX4k-objs := $(GDRV_OBJS) $(TARGETLIB)
#
# Perform any specific kernel configuration difference checks.
#
CORKERNEL_INCLUDEDIR = /lib/modules/$(shell uname -r)/build/include
ifeq ($(shell $(SAPSRCROOT)/corcfgtest.sh remap_pfn_range $(CORKERNEL_INCLUDEDIR)),1)
CORKERNEL_CONFIG_OPTIONS += -DUSE_REMAP_PFN_RANGE
endif
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
RES := $(shell ./copysources)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) IROOT=$(PWD)/../../../../.. modules
endif
all: $(TARGET)
clean:
-$(RM) $(OBJS) $(GDRV_OBJS) $(TARGET)
distclean:
-$(RM) $(OBJS) $(GDRV_OBJS)
install: all
cp $(TARGET) $(INSTALLDIR)
distinstall: all
cp $(TARGET) $(DISTINSTALLDIR)
(note that I also tried to turn else ifeq ($(CORKERNEL_MAJOR), 3) in else since kernel 5 is bigger than kernel 3… still no success).
If you want the full compilation log (including the sub libraries), see here.

kernel programming: No rule to make target 'kernel'

I am trying to build a kernel object for my usb ethernet 2.5 gbit lan interface.
I get the error:
paolo#debian:~/temp/Linux kernel 5.x4.x3.x2.6.x Driver/AX88179_178A_Linux_Driver_v1.20.0_source$ make
make -C /lib/modules/5.10.0-19-amd64/build M=/home/paolo/temp/Linux kernel 5.x4.x3.x2.6.x Driver/AX88179_178A_Linux_Driver_v1.20.0_source modules
make[1]: Entering directory '/usr/src/linux-headers-5.10.0-19-amd64'
make[2]: *** No rule to make target 'kernel'. Stop.
make[1]: *** [/usr/src/linux-headers-5.10.0-19-common/Makefile:185: __sub-make] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.10.0-19-amd64'
make: *** [Makefile:31: default] Error 2
the relevant part of the Makefile:
CURRENT = $(shell uname -r)
TARGET = ax88179_178a
OBJS = ax88179_178a.o
MDIR = drivers/net/usb
KDIR = /lib/modules/5.10.0-19-amd64/build
SUBLEVEL= $(shell uname -r | cut -d '.' -f 3 | cut -d '.' -f 1 | cut -d '-' -f 1 | cut -d '_' -f 1)
USBNET = $(shell find $(KDIR)/include/linux/usb/* -name usbnet.h)
ifneq (,$(filter $(SUBLEVEL),14 15 16 17 18 19 20 21))
MDIR = drivers/usb/net
endif
EXTRA_CFLAGS = -DEXPORT_SYMTAB
PWD = $(shell pwd)
DEST = /lib/modules/$(CURRENT)/kernel/$(MDIR)
obj-m := $(TARGET).o
default:
make -C $(KDIR) M=$(PWD) modules
I have installed the kernel sources from the package repository and the corresponding package linux-headers for my uname -r kernel version
Thanks a lot for your help

Vasp 6.2.1 not compiling

I am trying to compile vasp 6.2.1 in my ubuntu 19.10 on VirtualBox. I have intel openApi (which has ifortran compiler) and fftw3 installed. I am trying to compile the serial version using ifort. But it's giving me an error as follows.
if [ ! -d build ] ; then mkdir build ; fi
if [ ! -d build/std ] ; then mkdir build/std ; fi
cp src/makefile src/.objects src/makedeps.awk makefile.include build/std
make -C build/std VERSION=std cleandependencies -j1
make[1]: Entering directory '/home/mdazharul/vasp/vasp6.2.1/vasp6.2.1/vasp6.2.1/vasp.6.2.1/build/std'
rm -f .depend
make[1]: Leaving directory '/home/mdazharul/vasp/vasp6.2.1/vasp6.2.1/vasp6.2.1/vasp.6.2.1/build/std'
make -C build/std VERSION=std all
make[1]: Entering directory '/home/mdazharul/vasp/vasp6.2.1/vasp6.2.1/vasp6.2.1/vasp.6.2.1/build/std'
rsync -ru ../../src/lib .
cp makefile.include lib
make -C lib -j1
make[2]: Entering directory '/home/mdazharul/vasp/vasp6.2.1/vasp6.2.1/vasp6.2.1/vasp.6.2.1/build/std/lib'
make libdmy.a
make[3]: Entering directory '/home/mdazharul/vasp/vasp6.2.1/vasp6.2.1/vasp6.2.1/vasp.6.2.1/build/std/lib'
make[3]: 'libdmy.a' is up to date.
make[3]: Leaving directory '/home/mdazharul/vasp/vasp6.2.1/vasp6.2.1/vasp6.2.1/vasp.6.2.1/build/std/lib'
make[2]: Leaving directory '/home/mdazharul/vasp/vasp6.2.1/vasp6.2.1/vasp6.2.1/vasp.6.2.1/build/std/lib'
rsync -ru ../../src/parser .
cp makefile.include parser
make -C parser -j1
make[2]: Entering directory '/home/mdazharul/vasp/vasp6.2.1/vasp6.2.1/vasp6.2.1/vasp.6.2.1/build/std/parser'
make libparser.a
make[3]: Entering directory '/home/mdazharul/vasp/vasp6.2.1/vasp6.2.1/vasp6.2.1/vasp.6.2.1/build/std/parser'
make[3]: 'libparser.a' is up to date.
make[3]: Leaving directory '/home/mdazharul/vasp/vasp6.2.1/vasp6.2.1/vasp6.2.1/vasp.6.2.1/build/std/parser'
make[2]: Leaving directory '/home/mdazharul/vasp/vasp6.2.1/vasp6.2.1/vasp6.2.1/vasp.6.2.1/build/std/parser'
rsync -u ../../src/*.F ../../src/*.inc .
rm -f vasp ; make vasp ; cp vasp ../../bin/vasp_std
make[2]: Entering directory '/home/mdazharul/vasp/vasp6.2.1/vasp6.2.1/vasp6.2.1/vasp.6.2.1/build/std'
mpiifort -qmkl=cluster -lstdc++ -o vasp c2f_interface.o nccl2for.o simd.o base.o profiling.o string.o tutor.o version.o vhdf5_base.o incar_reader.o reader_base.o openmp.o openacc_struct.o mpi.o mpi_shmem.o mathtools.o hamil_struct.o radial_struct.o pseudo_struct.o mgrid_struct.o wave_struct.o nl_struct.o mkpoints_struct.o poscar_struct.o afqmc_struct.o phonon_struct.o fock_glb.o chi_glb.o smart_allocate.o xml.o extpot_glb.o constant.o vdwforcefield_glb.o jacobi.o main_mpi.o openacc.o scala.o asa.o lattice.o poscar.o ini.o mgrid.o setex_struct.o xclib.o vdw_nl.o xclib_grad.o setex.o radial.o pseudo.o gridq.o ebs.o symlib.o mkpoints.o random.o wave.o wave_mpi.o wave_high.o bext.o spinsym.o symmetry.o lattlib.o nonl.o nonlr.o nonl_high.o dfast.o choleski2.o mix.o hamil.o xcgrad.o xcspin.o potex1.o potex2.o constrmag.o cl_shift.o relativistic.o LDApU.o paw_base.o metagga.o egrad.o pawsym.o pawfock.o pawlhf.o diis.o rhfatm.o hyperfine.o fock_ace.o paw.o mkpoints_full.o charge.o Lebedev-Laikov.o stockholder.o dipol.o solvation.o scpc.o pot.o tet.o dos.o elf.o hamil_rot.o chain.o dyna.o fileio.o vhdf5.o sphpro.o us.o core_rel.o aedens.o wavpre.o wavpre_noio.o broyden.o dynbr.o reader.o writer.o xml_writer.o brent.o stufak.o opergrid.o stepver.o chgloc.o fast_aug.o fock_multipole.o fock.o fock_dbl.o fock_frc.o mkpoints_change.o subrot_cluster.o sym_grad.o mymath.o npt_dynamics.o subdftd3.o subdftd4.o internals.o dynconstr.o dimer_heyden.o dvvtrajectory.o vdwforcefield.o nmr.o pead.o k-proj.o subrot.o subrot_scf.o paircorrection.o rpa_force.o ml_interface.o force.o pwlhf.o gw_model.o optreal.o steep.o rmm-diis.o davidson.o david_inner.o root_find.o lcao_bare.o locproj.o electron_common.o electron.o rot.o electron_all.o shm.o pardens.o optics.o constr_cell_relax.o stm.o finite_diff.o elpol.o hamil_lr.o rmm-diis_lr.o subrot_lr.o lr_helper.o hamil_lrf.o elinear_response.o ilinear_response.o linear_optics.o setlocalpp.o wannier.o electron_OEP.o electron_lhf.o twoelectron4o.o gauss_quad.o m_unirnk.o minimax_ini.o minimax_dependence.o minimax_functions1D.o minimax_functions2D.o minimax_struct.o minimax_varpro.o minimax.o mlwf.o ratpol.o pade_fit.o screened_2e.o wave_cacher.o crpa.o chi_base.o wpot.o local_field.o ump2.o ump2kpar.o fcidump.o ump2no.o bse_te.o bse.o time_propagation.o acfdt.o afqmc.o rpax.o chi.o acfdt_GG.o dmft.o GG_base.o greens_orbital.o lt_mp2.o rnd_orb_mp2.o greens_real_space.o chi_GG.o chi_super.o sydmat.o rmm-diis_mlr.o linear_response_NMR.o wannier_interpol.o wave_interpolate.o linear_response.o auger.o dmatrix.o phonon.o wannier_mats.o elphon.o core_con_mat.o embed.o extpot.o fft3dfurth.o fft3dlib.o main.o -Llib -ldmy -Lparser -lparser -Lparser -lparser -lstdc++
ipo: warning #11021: unresolved fftext_mu_
Referenced in /tmp/ipo_ifortQlEAwA.o
ipo: warning #11021: unresolved fftext_useinv_mu_
Referenced in /tmp/ipo_ifortQlEAwA.o
ipo: warning #11021: unresolved fftwav_mu_
Referenced in /tmp/ipo_ifortQlEAwA.o
ipo: warning #11021: unresolved fftwav_useinv_mu_
Referenced in /tmp/ipo_ifortQlEAwA.o
ld: /tmp/ipo_ifortQlEAwA2.o: in function `wave_high_mp_fftext_wa_':
ipo_out2.f:(.text.hot00012+0x2d442): undefined reference to `fftext_useinv_mu_'
ld: ipo_out2.f:(.text.hot00012+0x2d597): undefined reference to `fftext_mu_'
ld: /tmp/ipo_ifortQlEAwA2.o: in function `wave_high_mp_fftwav_wa_':
ipo_out2.f:(.text.hot00012+0x2d865): undefined reference to `fftwav_useinv_mu_'
ld: ipo_out2.f:(.text.hot00012+0x2d99f): undefined reference to `fftwav_mu_'
make[2]: *** [makefile:149: vasp] Error 1
make[2]: Leaving directory '/home/mdazharul/vasp/vasp6.2.1/vasp6.2.1/vasp6.2.1/vasp.6.2.1/build/std'
cp: cannot stat 'vasp': No such file or directory
make[1]: *** [makefile:146: all] Error 1
make[1]: Leaving directory '/home/mdazharul/vasp/vasp6.2.1/vasp6.2.1/vasp6.2.1/vasp.6.2.1/build/std'
make: *** [makefile:17: std] Error 2
I am Also including the makefile.include.
>
# Precompiler options
CPP_OPTIONS= -DHOST=\"LinuxIFC\"\
-DCACHE_SIZE=16000 \
-Davoidalloc \
-Duse_bse_te \
-Dtbdyn \
-Dfock_dblbuf
CPP = fpp -f_com=no -free -w0 $*$(FUFFIX) $*$(SUFFIX) $(CPP_OPTIONS)
FC = mpiifort
FCL = mpiifort -qmkl=cluster -lstdc++
FREE = -free -names lowercase
FFLAGS = -assume byterecl -w -xHOST
OFLAG = -O2
OFLAG_IN = $(OFLAG)
DEBUG = -O0
MKL_PATH = $(MKLROOT)/lib/intel64
BLAS =
LAPACK =
BLACS =
SCALAPACK =
OBJECTS = fft3dfurth.o fft3dlib.o
INCS =-I$(MKLROOT)/include/fftw
LLIBS = $(SCALAPACK) $(LAPACK) $(BLAS)
OBJECTS_O1 += fft3dfurth.o fftw3d.o fftmpi.o fftmpiw.o
OBJECTS_O2 += fft3dlib.o
# For what used to be vasp.5.lib
CPP_LIB = $(CPP)
FC_LIB = $(FC)
CC_LIB = icc
CFLAGS_LIB = -O
FFLAGS_LIB = -O1
FREE_LIB = $(FREE)
OBJECTS_LIB= linpack_double.o
# For the parser library
CXX_PARS = icpc
LLIBS += -Lparser -lparser -lstdc++
# Normally no need to change this
SRCDIR = ../../src
BINDIR = ../../bin
I can not seem to locate the problem. Please help me regarding this matter. Thank you.
`
You can try compiling your application using mpiifort instead of doing it with ifort compiler. You are getting the undefined reference to `MPI_Comm_rank errors because your application did not get linked with the MPI libraries. mpiifort compiler uses intel ifort compiler along with MPI wrappers.

Dynamically generating a list of targets

If a file exists, I want to add a target to build. If the file does not exist, I want the target to be skipped.
an example:
FILENAME = f
TARGETS := normal
ifneq($(shell stat test_$(FILENAME).c), "")
TARGETS += test
endif
all: $(TARGETS)
normal:
#echo normal
test:
#echo test
I'm not sure the $(shell stat ...) part even works, but the bigger problem is that make with any file test_f.c in the current folder gives:
Makefile:4: *** multiple target patterns. Stop.
Removing the ifneq ... endif block makes the target normal. How can I only run the target test if test_f.c exists?
What you can do is generate a string variable (let's call it OPTIONAL) such that when 'test_f.c' exists, OPTIONAL=test; otherwise, OPTIONAL=_nothing_. And then add OPTIONAL as a prerequisite of all. e.g.:
FILENAME = f
TARGETS = normal
OPTIONAL = $(if $(wildcard test_f.c), test, )
all: $(TARGETS) $(OPTIONAL)
normal:
#echo normal
test:
#echo test
You can also iterate over targets with for loop
.PHONY: all
RECIPES = one
all: RECIPES += $(if $(wildcard test_f.c), two, )
all:
for RECIPE in ${RECIPES} ; do \
$(MAKE) $${RECIPE} ; \
done
one:
$(warning "One")
two:
$(warning "Two")
> make
for RECIPE in one ; do \
/Applications/Xcode.app/Contents/Developer/usr/bin/make ${RECIPE} ; \
done
makefile:11: "One"
make[1]: `one' is up to date.
> touch test_f.c
> make
for RECIPE in one two ; do \
/Applications/Xcode.app/Contents/Developer/usr/bin/make ${RECIPE} ; \
done
makefile:11: "One"
make[1]: `one' is up to date.
makefile:14: "Two"
make[1]: `two' is up to date.

makefile-compiling-back-and-forth - follow up

In continuation with my earlier question
Makefile - compiling back and forth
I made an attempt in creating a single Makefile. The two subdirectories are HAM-src and GFS-src. However, I am still unable to build it. I paste my Makefile below:
export
SHELL = /bin/sh
top_srcdir=./Temp
objdir=$(top_srcdir)/obj
bindir=${exec_prefix}/bin
cfssrcdir=${top_srcdir}/GFS-src
hamsrcdir=${top_srcdir}/HAM-src
incdir=${top_srcdir}/include
exec=${bindir}/esm_gfs-ham_v0
PROG=$(exec)
LDR = mpxlf90_r -qsmp=noauto
FFLAG90 = $(OPTS90) $(FINCS) -qfree=f90 -NS2048 -qmoddir=$(objdir) -I$(objdir)
FFLAGM = -NS2048 -qfixed -qmoddir=$(objdir) -I$(objdir)
F77 = mpxlf95
F90 = mpxlf95
F90_x = xlf90_r
F90_r = mpxlf95_r
SRCHAM = $(hamsrcdir)/ham_control.f90 $(hamsrcdir)/mo_filename.f90 \
$(hamsrcdir)/ham_namelist.f90 $(hamsrcdir)/ham_submodel.f90 \
$(hamsrcdir)/ham_submodel_diag.f90 $(hamsrcdir)/ham_ham.f90
SRCGFS_MOD=$(cfssrcdir)/machine.f $(cfssrcdir)/resol_def.f \
$(cfssrcdir)/omegas.f $(cfssrcdir)/cnvcld_v.f
OBJGFS_MOD = $(patsubst $(cfssrcdir)/%.f,$(objdir)/%.o,$(SRCGFS_MOD))
OBJHAM = $(patsubst $(hamsrcdir)/%.f90,$(objdir)/%.o,$(SRCHAM))
.SUFFIXES: $(SUFFIXES) .f90 .f .o
all: $(PROG)
$(PROG): $(OBJHAM) $(OBJGFS_MOD)
$(LDR) $(CFS_LDFLAGS) -o $# $(OBJGFS_MOD) $(OBJHAM) $(CFS_LIBS) -L$(LDFLAGS)
$(objdir)/%.o: $(cfssrcdir)/%.f
$(F77) $(FFLAGS) -c $< -o $#
$(objdir)/%.o: $(hamsrcdir)/%.f90
$(F90_r) $(F90FLAGS) -c $< -o $#
########## dependencies for $(hamsrcdir) ###########
ham_filename.o: ham_control.o
ham_namelist.o: ham_control.o ham_filename.o
ham_submodel.o: ham_control.o ham_namelist.o $(objdir)/resol_def.o
ham_submodel_diag.o: ham_submodel.o
########## dependencies for $(cfssrcdir) ###########
$(objdir)/omegas.o: $(cfssrcdir)/omegas.f
$(F77) $(FFLAGM) -c $(cfssrcdir)/omegas.f -o $#
$(objdir)/cnvcld_v.o: $(cfssrcdir)/cnvcld_v.f
$(F77) $(FFLAGM) -c $(cfssrcdir)/cnvcld_v.f -o $#
The error:
mpxlf95_r -q64 -O3 -qstrict -qMAXMEM=-1 -qarch=auto -qtune=auto -qcache=auto -qfloat=fltint -qsuffix=cpp=f90 -lessl_r -lmass -lmassv -I./Temp/include -I./Temp/HAM-src -qmoddir=./Temp/obj -I./Temp/obj -c ./Temp/HAM-src/ham_namelist.f90 -o ./Temp/obj/ham_namelist.o
** ham_namelist === End of Compilation 1 ===
1501-510 Compilation successful for file ham_namelist.f90.
mpxlf95_r -q64 -O3 -qstrict -qMAXMEM=-1 -qarch=auto -qtune=auto -qcache=auto -qfloat=fltint -qsuffix=cpp=f90 -lessl_r -lmass -lmassv -I./Temp/include -./Temp/HAM-src -qmoddir=./Temp/obj -I./Temp/obj -c ./Temp/HAM-src/ham_submodel.f90 -o ./Temp/obj/ham_submodel.o
"./Temp/HAM-src/ham_submodel.f90", line 425.7: 1514-219 (S) Unable to access module symbol file for module resol_def. Check path and file permissions of file. Use association not done for this module.
1501-511 Compilation failed for file ham_submodel.f90.
gmake: *** [/gpfs1/home/cccrmod/ham_expt_dec11/regrid_test/CFS-HAM/SORC_CFS-HAM/Temp/obj/ham_submodel.o] Error 1
Why makefile does not compile the resol_def.f module on encountering the dependency?
Another issue - my makefile is not working properly. It goes in a sequence in which the sources are defined.
This is difficult to untangle (a minimal, complete example really would help), but I'd suggest you change this
ham_submodel.o: ham_control.o ham_namelist.o $(objdir)/resol_def.o
to this
$(objdir)/ham_submodel.o: ham_control.o ham_namelist.o $(objdir)/resol_def.o
and see if that solves the first problem. I don't understand the last line of your question ("Another issue...").

Resources