Why is automake prefixing my object files with the package name? - automake

In my src directory, I have source files such as cells.c. When I perform a compilation, the compiler prefixes the object file with the package name, so that it becomes neoleo-cells.o, for example. Why is it doing this, and how can I stop it? I don't think it's standard behaviour.
Here is Makefile.am:
#VPATH = $(srcdir) $(builddir)
GUI_SRCS =
GUI_LINK =
#GUI_DEFINES = -DX_DISPLAY_MISSING
GUI_DEFINES = -DHAVE_X
# Order of linking of libraries for Motif seems to be important
# I have decided to mandate the use of the Xbae library, rather than
# have it optional.
if UseMotif
GUI_SRCS += io-motif.c appres.c fallback.c oleo_icon.xpm
GUI_LINK += -lXm -lXt -lXbae
GUI_DEFINES += -DHAVE_MOTIF
endif
GUI_SRCS += io-x11.c xrdb.c
GUI_LINK += -lX11
YFLAGS = -d
EXTRA_DIST = $(srcdir)/neoleo.i
bin_PROGRAMS = neoleo
BUILT_SOURCES = getdate.c parse.c parse.h posixtm.c posixtm.h
#BUILT_SOURCES += neoleo_wrap.c
CLEANFILES = $(BUILT_SOURCES)
#lib_LTLIBRARIES = libneoleo.la
neoleo_CFLAGS = $(GUI_DEFINES) -Dmain0=main
neoleo_LDADD = -lm -lncurses -lpthread $(GUI_LINK)
#neoleo_LDFLAGS = -e main0
#neoleo_la_LDFLAGS = -module -avoid-version -shared
neoleo_SOURCES = afm.c args.c basic.c busi.c byte-compile.c cells.c cmd.c date.c decompile.c display.c \
epson.c eval.c font.c format.c forminfo.c funcs.c graph.c gsl.c hash.c help.c \
info.c init.c input.c \
io-headless.c io-curses.c io-edit.c io-term.c io-utils.c \
ir.c key.c legend.c line.c list.c lists.c mdi.c oleofile.c pcl.c plot.c \
postscript.c print.c prtext.c ref.c regions.c sc.c sort.c string.c stub.c sylk.c utils.c \
window.c \
defuns.c \
get_date.h getdate.y \
parse.y \
posixtm.y \
neoleo_swig.c \
mysql.c $(GUI_SRCS)
noinst_HEADERS = afm.h appres.h args.h basic.h byte-compile.h cell.h \
cmd.h decompile.h defun.h defuns.h display.h epson.h \
errors.h eval.h font.h format.h forminfo.h funcdef.h \
funcs.h global.h graph.h hash.h help.h info.h init.h \
input.h io-abstract.h io-headless.h io-curses.h io-edit.h \
io-generic.h io-motif.h io-term.h io-utils.h io-x11.h \
ir.h key.h line.h list.h lists.h mdi.h mysql.h node.h \
oleofile.h oleo_plot.h oleosql.h oleo_xb.h parse.h pcl.h \
posixtm.h postscript.h print.h proto.h prtext.h ref.h \
regions.h sc.h sciplot.h sciplotI.h sort.h stub.h stubs.h \
sylk.h sysdef.h userpref.h utils.h window.h \
neoleo_swig.h
# exclude these for now:
# plotter.c xbase.cpp
ref.o : parse.h
#neoleo_wrap.c : $(srcdir)/neoleo.i neoleo_swig.c neoleo_swig.h
# swig -tcl8 -o $# $<

This line causes the rename of the object files:
neoleo_CFLAGS = $(GUI_DEFINES) -Dmain0=main
If you have target-dependent compilation flags, Automake chooses different names for the resulting object files. This approach avoids clashes if there are multiple different targets that use the same sources but different flags.
Now, Automake could in theory notice that this isn't happening and not rename the object files. However, in practice most people don't care what the intermediate files are called, and this approach, I believe, simplified the implementation.
In your case, it sounds like you do care. So, just rename that variable to AM_CFLAGS and everything should work as you expect.

Related

mpif90 not found but it's intsalled

I'm trying to run a makefile and came across two errors. When I run make I get this:
$ make
mpif90 -xHost -ip -fpp -O3 -align -I/include/intel64/lp64 -I/include/fftw -c integ-Coul.F
make: mpif90: Command not found
make: *** [makefile:181: integ-Coul.o] Error 127
So, I already have installed openmpi-devel and the file mpif90 it's in the /usr/lib64/openmpi/bin folder, but the error keeps reocurring.
This is the makefile
#
.SUFFIXES:
.SUFFIXES: .f .F .for .cpp .F90 .cu .o
#FC=ifort -xHost -ip -fpp
FC = mpif90 -xHost -ip -fpp
FREE = -free
# use this flag for debugging and coding up
SAFE = #-g -traceback -check all #-fstack-protector -assume protect_parens -implicitnone -warn all
FFLAGS1 = -O3 -align
FFLAGS2 = -O2 -align -qopenmp -parallel $(FREE) $(SAFE)
LDFLAGS = -static-intel
CXX = icpc -std=c++11
SAFE_CXX = #-g -traceback
CFLAGS = -O2 -align -xHost -ip -qopenmp -fno-exceptions -restrict $(SAFE_CXX)
# MKLROOT = If MKLROOT is not defined in your environment, edit and uncomment this line
LIB_BLAS = -lmkl_blas95_lp64
LIB_LAPACK = -lmkl_lapack95_lp64 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core
LIB_OMP = -liomp5 -lpthread
INCS_MKL = -I$(MKLROOT)/include/intel64/lp64 -I$(MKLROOT)/include/fftw
# Uncomment the lines below when compiling for GPUs
# GPU_DEFS options:
# -DGPU_TIMING : Print timings (CPU/GPU)
# -DUSE_GPU : Compile with GPU support
# -DGPU_DEBUG : Print some debug messages
# -DGPU_SYGVDM_VER : Use multi-gpu version of SYGVD (faster than single-gpu even with 1 gpu)
# -DGPU_SYGVD2S_VER : Use two stage version of SYGVD (faster, but needs more memory)
# -DGPU_DONT_PIN_MEM : Don't use pinned memory for faster transfers (in Fortran code)
# -DGPU_PIN_MEM_WORK : Use pinned memory for work spaces (in C code)
#GPU_DEFS = -DUSE_GPU
#
ifneq (,$(findstring USE_GPU,$(GPU_DEFS)))
# CUDA compiler
NVCC = nvcc
# compute capality (depends on your GPU, check!)
SM = 35
#SAFE_NVCC = -g -lineinfo
NVCCFLAGS = -O3 -gencode arch=compute_${SM},code=sm_${SM} -Xcompiler "-fno-strict-aliasing -march=native -fno-exceptions" $(SAFE_NVCC)
# -fno-strict-aliasing
#
# CUDA and MAGMA paths:
CUDADIR = /usr/local/cuda
MAGMADIR = /opt/magma
#
# CUDA and MAGMA libs:
# dynamic linking:
#LIB_CUDA = -L$(CUDADIR)/lib64 -lcublas -lcusparse -lcudart
# static linking:
LIB_CUDA = -L$(CUDADIR)/lib64 -lcublas_static -lcusparse_static -lculibos -lcudart_static -ldl
LIB_MAGMA = $(MAGMADIR)/lib/libmagma.a
#
LIB_GPU = $(LIB_MAGMA) $(LIB_CUDA) -lstdc++
INCS_GPU = -I$(CUDADIR)/include -I$(MAGMADIR)/include
endif
LIB = $(LIB_GPU) $(LIB_BLAS) $(LIB_LAPACK) $(LIB_OMP) -lrt
INCS = $(INCS_MKL)
#-----------------------------------------------------------------------
# general rules
#-----------------------------------------------------------------------
#INCS1 = comun.inc integcoul.inc m2cdat.inc $(INCS)
SOURCE1 = integ-Coul.o \
Coul0sim.o \
m2caux3-Coul.o \
abcpes-Coul.o \
ckplm-Coul.o \
util-Coul.o
SOURCE2 = constants_m.o \
Matrix_math.o \
exec_time.o \
types_EHT.o \
types_MM.o \
parameters.o \
MPI_defs.o \
OPT_parent.o \
parameters_MM.o \
checklist.o \
allocation_m.o \
util.o \
EHT_input.o \
tuning.o \
IdentifyNonBonded.o \
babel_routines.o \
babel.o \
gmx2mdflex.o \
namd2mdflex.o \
structure.o \
md_read.o \
md_setup.o \
f_intra.o \
f_inter.o \
md_output.o \
pbc.o \
overlap_D.o \
STO.o \
multip_routines.o \
LCMO_Builder.o \
Coulomb.o \
DP_main.o \
td_dp.o \
DP_FMO.o \
dipole_phi.o \
EnvField.o \
polarizability.o \
hamiltonians.o \
QCModel_Huckel.o \
diabatic-Ehren.o \
HuckelForces.o \
Ehrenfest.o \
CoulInt_QMMM.o \
FMO.o \
electron_hole_DP.o \
AlphaPolar.o \
data_output.o \
backup_MM.o \
Berendsen.o \
NoseHoover.o \
NoseHoover_Reversible.o \
NVE.o \
VDOS_m.o \
MM_dynamics.o \
MM_driver.o \
film_STO.o \
DOS_m.o \
oscillator.o \
ga_QCModel.o \
cost_tuning_EH.o \
cost_tuning_MM.o \
nonlinearCG.o \
CG_class.o \
MM_ERG_class.o \
nonlinear-sidekick.o \
FF_OPT_class.o \
CG_EH_driver.o \
ga_routines.o \
CG_MM_driver.o \
vibes_driver.o \
solvated_M.o \
DOS_tool.o \
backup.o \
auto_correlation.o \
ElHl_schroedinger.o \
diagnostic.o \
qdynamics.o \
Taylor.o \
ElHl_Chebyshev.o \
ElHl_Chebyshev_GPU.o \
AO_adiabatic.o \
Chebyshev_driver.o \
eigen_driver.o \
ga_driver.o \
avrg_confgs.o \
main.o
SOURCE_GPU = GPU_Interface.o \
Taylor_gpu.o
# Chebyshev_gpu.o
ifneq (,$(findstring USE_GPU,$(GPU_DEFS)))
SOURCE_CUDA= Chebyshev_gpu_kernels.o \
dzgemv_kernels.o
endif
a: $(SOURCE1) $(SOURCE2) $(SOURCE_GPU) $(SOURCE_CUDA)
rm -f a
$(FC) $(INCS) $(LDFLAGS) -o a $(SOURCE1) $(SOURCE2) $(SOURCE_GPU) $(SOURCE_CUDA) $(LIB)
.F.o:
$(FC) $(FFLAGS1) $(INCS) -c $<
.f.o:
$(FC) $(FFLAGS2) $(INCS) $(GPU_DEFS) -c $<
.F90.o:
$(FC) $(FFLAGS1) $(INCS) $(GPU_DEFS) -c $<
.cpp.o:
$(CXX) $(CFLAGS) $(INCS_GPU) $(GPU_DEFS) -c $<
.cu.o:
$(NVCC) $(NVCCFLAGS) $(INCS_GPU) $(GPU_DEFS) -c $<
clean:
-rm -f a *.o *.mod; touch *.f
depend:
#echo -en "Searching module dependencies..."
#chmod +x ./makedepend.bsh
#./makedepend.bsh > dependencies.txt
#echo -en " done.\n"
## Dependency list:
-include dependencies.txt
I don't have much experience so I would really appreciate some help with this. Thank you all.
Ps.: my SO is Fedora 32

How to solve this 'Error Refreshing Makefiles'?

When I click on Run on my VeinsTutorial (the one that Christoph Sommer made and you might be familiar with it), I get error shown below. Do you have any idea? I really need to get over this error.
Error refreshing Makefiles
Reason:
you have both .cc and .cpp files -- specify -e cc or -e cpp option to select which set of files to use
make MODE=release all
make: *** No rule to make target 'all'. Stop.
"make MODE=release all" terminated with exit code 2. Build might be incomplete.
'
'Simulation terminated with exit code: 1
<!> Error: NED type 'veinstutorial.src.TutorialAppl' could not be fully resolved due to a missing base type or interface, at C:\Users\konra\git\repository\carlogicapi-master\carlogicapi-master\tutorials\VeinsTutorial\src\TutorialAppl.ned:19
End.
This is the MAKEFILES FILE where I should change something, but I cannot see where it should be changed.
#
# OMNeT++/OMNEST Makefile for $(LIB_PREFIX)veins
#
# This file was generated with the command:
# opp_makemake --make-so -f --deep -o veins -O out -pVEINS -I. -I.
#
# Name of target to be created (-o option)
TARGET = $(LIB_PREFIX)veins$(D)$(SHARED_LIB_SUFFIX)
TARGET_DIR = .
# C++ include paths (with -I)
INCLUDE_PATH = -I. -I.
# Additional object and library files to link with
EXTRA_OBJS =
# Additional libraries (-L, -l options)
LIBS =
# Output directory
PROJECT_OUTPUT_DIR = ../out
PROJECTRELATIVE_PATH = src
O = $(PROJECT_OUTPUT_DIR)/$(CONFIGNAME)/$(PROJECTRELATIVE_PATH)
# Object files for local .cc, .msg and .sm files
OBJS = \
$O/veins/base/connectionManager/BaseConnectionManager.o \
$O/veins/base/connectionManager/ChannelAccess.o \
$O/veins/base/connectionManager/ConnectionManager.o \
$O/veins/base/connectionManager/NicEntryDebug.o \
$O/veins/base/connectionManager/NicEntryDirect.o \
$O/veins/base/modules/BaseApplLayer.o \
$O/veins/base/modules/BaseBattery.o \
$O/veins/base/modules/BaseLayer.o \
$O/veins/base/modules/BaseMacLayer.o \
$O/veins/base/modules/BaseMobility.o \
$O/veins/base/modules/BaseModule.o \
$O/veins/base/modules/BaseWorldUtility.o \
$O/veins/base/modules/BatteryAccess.o \
$O/veins/base/phyLayer/Antenna.o \
$O/veins/base/phyLayer/BaseDecider.o \
$O/veins/base/phyLayer/BasePhyLayer.o \
$O/veins/base/phyLayer/ChannelInfo.o \
$O/veins/base/phyLayer/Decider.o \
$O/veins/base/phyLayer/PhyUtils.o \
$O/veins/base/toolbox/Signal.o \
$O/veins/base/toolbox/SignalUtils.o \
$O/veins/base/toolbox/Spectrum.o \
$O/veins/base/utils/Coord.o \
$O/veins/base/utils/Heading.o \
$O/veins/base/utils/NetwToMacControlInfo.o \
$O/veins/base/utils/SimpleAddress.o \
$O/veins/base/utils/winsupport.o \
$O/veins/modules/analogueModel/BreakpointPathlossModel.o \
$O/veins/modules/analogueModel/NakagamiFading.o \
$O/veins/modules/analogueModel/PERModel.o \
$O/veins/modules/analogueModel/SimpleObstacleShadowing.o \
$O/veins/modules/analogueModel/SimplePathlossModel.o \
$O/veins/modules/analogueModel/TwoRayInterferenceModel.o \
$O/veins/modules/analogueModel/VehicleObstacleShadowing.o \
$O/veins/modules/application/ieee80211p/DemoBaseApplLayer.o \
$O/veins/modules/application/traci/MyVeinsApp.o \
$O/veins/modules/application/traci/TraCIDemo11p.o \
$O/veins/modules/application/traci/TraCIDemoRSU11p.o \
$O/veins/modules/mac/ieee80211p/Mac1609_4.o \
$O/veins/modules/mobility/LinearMobility.o \
$O/veins/modules/mobility/traci/TraCIBuffer.o \
$O/veins/modules/mobility/traci/TraCIColor.o \
$O/veins/modules/mobility/traci/TraCICommandInterface.o \
$O/veins/modules/mobility/traci/TraCIConnection.o \
$O/veins/modules/mobility/traci/TraCICoordinateTransformation.o \
$O/veins/modules/mobility/traci/TraCILauncher.o \
$O/veins/modules/mobility/traci/TraCIMobility.o \
$O/veins/modules/mobility/traci/TraCIRegionOfInterest.o \
$O/veins/modules/mobility/traci/TraCIScenarioManager.o \
$O/veins/modules/mobility/traci/TraCIScenarioManagerForker.o \
$O/veins/modules/mobility/traci/TraCIScenarioManagerLaunchd.o \
$O/veins/modules/mobility/traci/TraCIScreenRecorder.o \
$O/veins/modules/mobility/traci/TraCIVehicleInserter.o \
$O/veins/modules/obstacle/MobileHostObstacle.o \
$O/veins/modules/obstacle/Obstacle.o \
$O/veins/modules/obstacle/ObstacleControl.o \
$O/veins/modules/obstacle/VehicleObstacleControl.o \
$O/veins/modules/phy/Decider80211p.o \
$O/veins/modules/phy/NistErrorRate.o \
$O/veins/modules/phy/PhyLayer80211p.o \
$O/veins/modules/phy/SampledAntenna1D.o \
$O/veins/modules/utility/BBoxLookup.o \
$O/veins/modules/utility/HasLogProxy.o \
$O/veins/modules/utility/TimerManager.o \
$O/veins/modules/world/annotations/AnnotationDummy.o \
$O/veins/modules/world/annotations/AnnotationManager.o \
$O/veins/modules/world/traci/trafficLight/TraCITrafficLightInterface.o \
$O/veins/modules/world/traci/trafficLight/TraCITrafficLightProgram.o \
$O/veins/modules/world/traci/trafficLight/logics/TraCITrafficLightAbstractLogic.o \
$O/veins/modules/world/traci/trafficLight/logics/TraCITrafficLightSimpleLogic.o \
$O/veins/base/messages/AirFrame_m.o \
$O/veins/base/messages/BorderMsg_m.o \
$O/veins/base/messages/MacPkt_m.o \
$O/veins/modules/application/traci/TraCIDemo11pMessage_m.o \
$O/veins/modules/messages/AckTimeOutMessage_m.o \
$O/veins/modules/messages/AirFrame11p_m.o \
$O/veins/modules/messages/BaseFrame1609_4_m.o \
$O/veins/modules/messages/DemoSafetyMessage_m.o \
$O/veins/modules/messages/DemoServiceAdvertisement_m.o \
$O/veins/modules/messages/Mac80211Ack_m.o \
$O/veins/modules/messages/Mac80211Pkt_m.o \
$O/veins/modules/messages/PhyControlMessage_m.o \
$O/veins/modules/messages/TraCITrafficLightMessage_m.o \
$O/veins/modules/messages/WaveShortMessage_m.o
# Message files
MSGFILES = \
veins/base/messages/AirFrame.msg \
veins/base/messages/BorderMsg.msg \
veins/base/messages/MacPkt.msg \
veins/modules/application/traci/TraCIDemo11pMessage.msg \
veins/modules/messages/AckTimeOutMessage.msg \
veins/modules/messages/AirFrame11p.msg \
veins/modules/messages/BaseFrame1609_4.msg \
veins/modules/messages/DemoSafetyMessage.msg \
veins/modules/messages/DemoServiceAdvertisement.msg \
veins/modules/messages/Mac80211Ack.msg \
veins/modules/messages/Mac80211Pkt.msg \
veins/modules/messages/PhyControlMessage.msg \
veins/modules/messages/TraCITrafficLightMessage.msg \
veins/modules/messages/WaveShortMessage.msg
# SM files
SMFILES =
#------------------------------------------------------------------------------
# Pull in OMNeT++ configuration (Makefile.inc)
ifneq ("$(OMNETPP_CONFIGFILE)","")
CONFIGFILE = $(OMNETPP_CONFIGFILE)
else
ifneq ("$(OMNETPP_ROOT)","")
CONFIGFILE = $(OMNETPP_ROOT)/Makefile.inc
else
CONFIGFILE = $(shell opp_configfilepath)
endif
endif
ifeq ("$(wildcard $(CONFIGFILE))","")
$(error Config file '$(CONFIGFILE)' does not exist -- add the OMNeT++ bin directory to the path so that opp_configfilepath can be found, or set the OMNETPP_CONFIGFILE variable to point to Makefile.inc)
endif
include $(CONFIGFILE)
# Simulation kernel and user interface libraries
OMNETPP_LIBS = -loppenvir$D $(KERNEL_LIBS) $(SYS_LIBS)
COPTS = $(CFLAGS) $(IMPORT_DEFINES) -DVEINS_EXPORT $(INCLUDE_PATH) -I$(OMNETPP_INCL_DIR)
MSGCOPTS = $(INCLUDE_PATH) -PVEINS_API
SMCOPTS =
# we want to recompile everything if COPTS changes,
# so we store COPTS into $COPTS_FILE and have object
# files depend on it (except when "make depend" was called)
COPTS_FILE = $O/.last-copts
ifneq ("$(COPTS)","$(shell cat $(COPTS_FILE) 2>/dev/null || echo '')")
$(shell $(MKPATH) "$O" && echo "$(COPTS)" >$(COPTS_FILE))
endif
#------------------------------------------------------------------------------
# User-supplied makefile fragment(s)
# >>>
# inserted from file 'makefrag':
#
# Copyright (C) 2017 Rudolf Hornig <rudi#omnetpp.org>
#
# Documentation for these modules is at http://veins.car2x.org/
#
# SPDX-License-Identifier: GPL-2.0-or-later
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#
# on windows we have to link with the ws2_32 (winsock2) library as it is no longer added to the omnetpp system libraries by default (as of OMNeT++ 5.1)
# copied from INET Framework (inet-3.6.0) makefrag
#
ifeq ($(PLATFORM),win32.x86_64)
LIBS += -lws2_32
DEFINES += -DVEINS_EXPORT
ENABLE_AUTO_IMPORT=-Wl,--enable-auto-import
LDFLAGS := $(filter-out $(ENABLE_AUTO_IMPORT), $(LDFLAGS))
endif
# <<<
#------------------------------------------------------------------------------
# Main target
all: $(TARGET_DIR)/$(TARGET)
$(TARGET_DIR)/% :: $O/%
#mkdir -p $(TARGET_DIR)
$(Q)$(LN) $< $#
ifeq ($(TOOLCHAIN_NAME),clangc2)
$(Q)-$(LN) $(<:%.dll=%.lib) $(#:%.dll=%.lib)
endif
$O/$(TARGET): $(OBJS) $(wildcard $(EXTRA_OBJS)) Makefile $(CONFIGFILE)
#$(MKPATH) $O
#echo Creating shared library: $#
$(Q)echo >.tmp$$$$ $(OBJS) $(EXTRA_OBJS) && $(AR) .tmplib$$$$ #.tmp$$$$ && $(SHLIB_LD) -o $O/$(TARGET) $(AS_NEEDED_OFF) $(WHOLE_ARCHIVE_ON) .tmplib$$$$ $(LIBS) $(WHOLE_ARCHIVE_OFF) $(OMNETPP_LIBS) $(LDFLAGS) && rm .tmp$$$$ && rm .tmplib$$$$
$(Q)$(SHLIB_POSTPROCESS) $O/$(TARGET)
.PHONY: all clean cleanall depend msgheaders smheaders
.SUFFIXES: .cc
$O/%.o: %.cc $(COPTS_FILE) | msgheaders smheaders
#$(MKPATH) $(dir $#)
$(qecho) "$<"
$(Q)$(CXX) -c $(CXXFLAGS) $(COPTS) -o $# $<
%_m.cc %_m.h: %.msg
$(qecho) MSGC: $<
$(Q)$(MSGC) -s _m.cc -MD -MP -MF $O/$(basename $<)_m.h.d $(MSGCOPTS) $?
%_sm.cc %_sm.h: %.sm
$(qecho) SMC: $<
$(Q)$(SMC) -c++ -suffix cc $(SMCOPTS) $?
msgheaders: $(MSGFILES:.msg=_m.h)
smheaders: $(SMFILES:.sm=_sm.h)
clean:
$(qecho) Cleaning $(TARGET)
$(Q)-rm -rf $O
$(Q)-rm -f $(TARGET_DIR)/$(TARGET)
$(Q)-rm -f $(TARGET_DIR)/$(TARGET:%.dll=%.lib)
$(Q)-rm -f $(call opp_rwildcard, . , *_m.cc *_m.h *_sm.cc *_sm.h)
cleanall:
$(Q)$(MAKE) -s clean MODE=release
$(Q)$(MAKE) -s clean MODE=debug
$(Q)-rm -rf $(PROJECT_OUTPUT_DIR)
# include all dependencies
-include $(OBJS:%=%.d) $(MSGFILES:%.msg=$O/%_m.h.d) ```
I just had to change the extension of the TutorialAppl.cpp to CC.
I guess sometimes we look for the difficult way to solve problems and it is actually the easy way you have to take :)
Thanks for your attention.

How should I link libraries in automake normally linked with pkg-config?

I'm trying to get my project buildable with automake. Specifically while using Allegro5.
I can build my code using the following command just fine
g++ -std=c++0x *.cpp -o mygame $(pkg-config --libs allegro-5.0 \
allegro_acodec-5.0 allegro_audio-5.0 allegro_color-5.0 allegro_dialog-5.0 \
allegro_font-5.0 allegro_image-5.0 allegro_main-5.0 allegro_memfile-5.0 \
allegro_physfs-5.0 allegro_primitives-5.0 allegro_ttf-5.0)
But my Makefile will not work.
Here is my src/Makefile.am
bin_PROGRAMS = mygame
AM_CXXFLAGS = "-std=c++0x"
mygame_SOURCES = Animation.cpp Body.cpp GameObject.cpp Menu.cpp Vector3.cpp \
Arena.cpp Button.cpp Keyboard.cpp Mesh.cpp Assets.cpp Character.cpp \
main.cpp Mouse.cpp Barrier.cpp Environment.cpp Manager.cpp TitleMenu.cpp
mygame_LDADD = allegro-5.0 allegro_acodec-5.0 allegro_audio-5.0 \
allegro_color-5.0 allegro_dialog-5.0 allegro_font-5.0 allegro_image-5.0 \
allegro_main-5.0 allegro_memfile-5.0 allegro_physfs-5.0 \
allegro_primitives-5.0 allegro_ttf-5.0
CLEANFILES = mygame *.o
And here is my configure.ac
AC_INIT(bayou, 0.1.0)
AM_INIT_AUTOMAKE
AC_LANG_CPLUSPLUS
AC_PROG_CXX
LT_INIT
AC_OUTPUT(
Makefile \
src/Makefile\
)
Running my first command works just fine. Running make gives me
make: *** No rule to make target `allegro-5.0', needed by 'mygame'. Stop.
So how should I set up my configure.ac and Makefile.am's so I can use libraries I normally link with pkg-config?
pkg-config is there to tell you dynamically which paths/flags to use.
It is meant to be used dynamically, rather than to run it on your development machine and then copy'n'paste it into the makefile and then expect it to run on any deployment machine.
Here's an updated Makefile.am, based on your own answer:
bin_PROGRAMS = mygame
AM_CXXFLAGS = "-std=c++0x"
PKGLIBS=allegro-5.0 \
allegro_acodec-5.0 allegro_audio-5.0 allegro_color-5.0 allegro_dialog-5.0 \
allegro_font-5.0 allegro_image-5.0 allegro_main-5.0 allegro_memfile-5.0 \
allegro_physfs-5.0 allegro_primitives-5.0 allegro_ttf-5.0
mygame_CXXFLAGS = $(shell pkg-config --cflags $(PKGLIBS)) $(AM_CXXFLAGS)
mygame_LDADD = $(shell pkg-config --libs $(PKGLIBS))
mygame_SOURCES = Animation.cpp Body.cpp GameObject.cpp Menu.cpp Vector3.cpp \
Arena.cpp Button.cpp Keyboard.cpp Mesh.cpp Assets.cpp Character.cpp \
main.cpp Mouse.cpp Barrier.cpp Environment.cpp Manager.cpp TitleMenu.cpp
it might be that in your setup, the entire allegro-foo doesn't need any special compiler-flags, but it might as well need some. therefore my example also sets the compiler-flags for your program (mygame_CXXFLAGS).
finally, it get's rid of the unneeded CLEANFILES.
Also, you could go the autotools route, and use the PKG_CHECK_MODULES macro in your configure.ac
My lead in the suggestion worked. I did not have to modify my configure.ac (though I probably should so I can verify expected packages are installed)
Anyway, I ran pkg-config <insert libs from comment here> in a terminal window, which gave the following output
-L/usr/local/lib -lallegro_acodec -lallegro_audio -lallegro_color
-lallegro_dialog -lallegro_image -lallegro_main -lallegro_memfile
-lallegro_physfs -lallegro_primitives -lallegro_ttf -lallegro_font
-lallegro
So my new Makefile.am looks like
bin_PROGRAMS = mygame
AM_CXXFLAGS = "-std=c++0x"
mygame_SOURCES = Animation.cpp Body.cpp GameObject.cpp Menu.cpp Vector3.cpp \
Arena.cpp Button.cpp Keyboard.cpp Mesh.cpp Assets.cpp Character.cpp \
main.cpp Mouse.cpp Barrier.cpp Environment.cpp Manager.cpp TitleMenu.cpp
mygame_LDADD = -Lusr/local/lib -lallegro_acodec \
-lallegro_audio -lallegro_color -lallegro_dialog -lallegro_image \
-lallegro_main -lallegro_memfile -lallegro_physfs -lallegro_primitives \
-lallegro_ttf -lallegro_font -lallegro
CLEANFILES = mygame *.o
I'd like to thank the academy and my parents for seeing me through this trying time. They've meant so much to me! *blows kisses

Makefile loops endless

My makefile loops endless but can't figure out why? Here is it further informations at sf.net/p/ags
AUTOMAKE_OPTIONS = foreign
top_srcdir = $(shell pwd)/src/ags
SUBDIRS = src/ags \
doc
-include ./src/ags/Makefile.am \
$(top_srcdir)/util/Makefile.am \
$(top_srcdir)/lib/Makefile.am \
$(top_srcdir)/object/Makefile.am \
$(top_srcdir)/widget/Makefile.am \
$(top_srcdir)/audio/Makefile.am \
$(top_srcdir)/audio/task/Makefile.am \
$(top_srcdir)/audio/file/Makefile.am \
$(top_srcdir)/audio/recall/Makefile.am \
$(top_srcdir)/audio/task/recall/Makefile.am \
$(top_srcdir)/file/Makefile.am \
$(top_srcdir)/X/Makefile.am \
$(top_srcdir)/X/editor/Makefile.am \
$(top_srcdir)/X/machine/Makefile.am \
$(top_srcdir)/file/Makefile.am \
$(top_srcdir)/server/Makefile.am \
./doc/Makefile.am
CC = gcc
# what flags you want to pass to the C compiler & linker
CFLAGS = -g --pedantic -Wall -O -I./src -I/usr/include
LDFLAGS = -L/lib -L/usr/lib -L/usr/X11/lib -lm -pthread -lrt -lgmp
# this lists the binaries to produce, the (non-PHONY, binary) targets in
# the previous manual Makefile
noinst_LIBRARIES = libags.a libags-thread.a libags-audio.a
bin_PROGRAMS = gsequencer
# library
libags_a_CFLAGS=
libags_a_LDFLAGS =
# application
gsequencer_CFLAGS=
gsequencer_LDFLAGS=
gsequencer_LDADD=libags.a libags-thread.a libags-audio.a
#
libags_audio_h_sources = $(ags_recall_audio_h_sources) $(ags_audio_task_h_sources) $(ags_xorg_task_h_sources) $(ags_audio_file_h_sources) $(ags_audio_recall_task_h_sources)
libags_audio_c_sources = $(ags_recall_audio_c_sources) $(ags_audio_task_c_sources) $(ags_xorg_task_c_sources) $(ags_audio_file_c_sources) $(ags_audio_recall_task_c_sources)
gsequencer_h_sources = $(ags_xorg_h_sources) $(ags_machine_h_sources) $(ags_editor_h_sources)
gsequencer_c_sources = $(ags_xorg_c_sources) $(ags_machine_c_sources) $(ags_editor_c_sources)
libags_a_SOURCES = $(ags_lib_c_sources) $(ags_object_c_sources) $(ags_util_c_sources)
libags_thread_a_SOURCES = $(ags_thread_c_sources)
libags_audio_a_SOURCES = $(ags_audio_c_sources)
libags_gui_a_SOURCES = $(ags_widget_c_sources)
gsequencer_SOURCES = $(gsequencer_c_sources) $(ags_server_c_sources) $(ags_file_c_sources)
Wiping all build scripts
rm *
Touching all files
find . -type f | xargs touch
Running the following to rebuild build scripts did it finally
aclocal
autoheader
libtoolize --force --copy
automake --add-missing --copy --foreign
autoconf
./configure
make
PROBLEM: empty Makefile.am caused infinite loop
SOLUTION: add an empty variable to it

Including a static library in makefile

I have a directory structure
trunk
--lib--libParser.a
--objs
--src
--Makefile
I have the following makefile
CRYPTOLIB_TARGET = cryptolib.a
LOCALLIBS = ./objs
LOCALLIBS_IMAGE = ./cryptolib.a
CC = gcc
AR = ar
DEBUG_FLAGS =
LDEFSECOM_LOG_VERSION = -DSECOM_LOG_VERSION
CMPL_TIME_MACROS = -DENBL_DEBUG_PRINTF $(LDEFSECOM_LOG_VERSION)
ALLWARN =
ALL_INCS = -I./src/INCLUDE
LIBS = -lrt -laio -lrt -lpthread -lm -lpq -ldl
LINK = $(CC) $(DEBUG_FLAGS) $(CMPL_TIME_MACROS) $(ALLWARN) $(ALL_INCS) $(LIBS) -c
default = CRYPTOLIB_TARGET
CRYPTOLIB_OBJ = \
$(LOCALLIBS)/AES_crypt.o \
$(LOCALLIBS)/bigdigits.o \
$(LOCALLIBS)/DataEncryption.o \
$(LOCALLIBS)/SiaEncryption.o
$(CRYPTOLIB_TARGET): $(CRYPTOLIB_OBJ)
$(AR) r $(CRYPTOLIB_TARGET) $(CRYPTOLIB_OBJ)
$(LOCALLIBS)/AES_crypt.o : \
src/AES_crypt.c
mkdir -p ./objs
$(LINK) src/AES_crypt.c -o $(LOCALLIBS)/AES_crypt.o
$(LOCALLIBS)/bigdigits.o : \
src/bigdigits.c
$(LINK) src/bigdigits.c -o $(LOCALLIBS)/bigdigits.o
$(LOCALLIBS)/DataEncryption.o : \
src/DataEncryption.c
$(LINK) src/DataEncryption.c -o $(LOCALLIBS)/DataEncryption.o
$(LOCALLIBS)/SiaEncryption.o : \
src/SiaEncryption.c
$(LINK) src/SiaEncryption.c -o $(LOCALLIBS)/SiaEncryption.o
clean:
rm -rf objs
rm -rf cryptolib.a
I want to include the libParser.a in the output library which I am creating but I am not sure how to do that. Can you please give me the pointers to so that I can include the library(libParser.a) and create cryptolib.a as a final output library.
from gcc online docs:
-llibrary
-l library
...(text removed)...
Normally the files found this way are library files—archive files
whose members are object files. The linker handles an archive file by
scanning through it for members which define symbols that have so far
been referenced but not defined. But if the file that is found is an
ordinary object file, it is linked in the usual fashion. The only
difference between using an -l option and specifying a file name is
that -l surrounds library with ‘lib’ and ‘.a’ and searches several
directories.
So... you could specify the library include folder:
-L./lib
and put the libParser.a in the list of libraries (subracting 'lib' and '.a'):
-lParser -lrt -laio ...

Resources