Makefile.am - how to add rule for windres? - automake

I have makefile.am used with automake for crossplatrom project , where I also need to build resource file, so I add it like this:
program_la_SOURCES = \
manifest.rc \
context.cpp \
forks.cpp \
....
But this is ignored by the compiler.
I then tried to add something like:
%.rc : %.o
but this did not help either. I see other source files builded as .o, but nothing for resource file.

Related

What's the difference between these 2 pieces of Makefile.am code?

I am completely new to using autotools so it might be a dumb question but I'll try anyway. I have two pieces of Makefile.am. Except one is working fine and the other is not.
This works fine.
sbin_PROGRAMS = kernel
kernel_SOURCES = \
src/arch/$(host_cpu)/arch_sysdefs.h \
src/arch/$(host_cpu)/boot.asm \
src/arch/$(host_cpu)/cpu.asm \
src/arch/$(host_cpu)/isr.asm \
src/kmain.cpp
But this doesn't. .asm files are completely ignored by generated Makefile.
if HOST_CPU_X86
ASM_EXT = .asm
else
ASM_EXT = .S
endif
sbin_PROGRAMS = kernel
kernel_SOURCES = \
src/arch/$(host_cpu)/arch_sysdefs.h \
src/arch/$(host_cpu)/boot$(ASM_EXT) \
src/arch/$(host_cpu)/cpu$(ASM_EXT) \
src/arch/$(host_cpu)/isr$(ASM_EXT) \
src/kmain.cpp
What I am trying to do is that I want to use different suffixes for assembly files for some CPUs my project is going to support.
I've also added necessary rule to transform .asm to object files.
.asm.o:
yasm -f $(YASM_OUT_FMT) $< -o $#
EDIT: Temporarily overriding .cpp.o rule with echo $(kernel_SOURCES) reveals that $(ASM_EXT) in kernel_SOURCES is substituted correctly. For example src/arch/$(host_cpu)/boot$(ASM_EXT) becomes src/arch/x86_64/boot.asm for x86-64 CPU and src/arch/arm/boot.S for ARM, etc. Also, setting ASM_EXT variable from autoconf.ac doesn't make any difference.

How do you configure Makefile.am to put all objects in the current directory

I am building pbs_mom for Torque. The latest autotools complain about subdir-ojbects option being disabled. I have enabled subdir-obects using AM_INIT_AUTOMAKE which allows me to get everything set up and configured. But when I do a make a conflict occurs because pbs_mom uses sources files for pbs_server but compiles them differently.
The pbs_mom_SOURCES line looks like the following
pbs_mom_SOURCES = catch_child.c mom_comm.c mom_inter.c mom_main.c \
mom_server.c prolog.c requests.c start_exec.c \
start_exec.h checkpoint.c tmsock_recov.c \
mom_req_quejob.c mom_job_func.c \
mom_process_request.c alps_reservations.c \
release_reservation.c generate_alps_status.c \
../server/attr_recov.c ../server/dis_read.c \
../server/job_attr_def.c ../server/job_recov.c \
../server/reply_send.c ../server/resc_def_all.c \
../server/job_qs_upgrade.c
Before enabling subdir-ojbects the .o files from the ../server source files would be put in the current directory (src/resmom). But with subdir-objects enabled it keeps them in the same directory as the source which is src/server.
How can I direct the Makefile.am to move the .o files to the src/resmom directory?

How to compile package with sub-directory includes in SCons?

scons output (split for readability), relevant commit:
scons: Building targets ...
g++ -o build/XMP/XMPCore/source/ExpatAdapter.o -c -O2 -iquote- -DUNIX_ENV=1 \
-D_FILE_OFFSET_BITS=64 -Ifixes/XMP-Toolkit -IXMP-Toolkit-SDK-CC201306/build \
-IXMP-Toolkit-SDK-CC201306/source/common -IXMP-Toolkit-SDK-CC201306/XMPCore/source \
-IXMP-Toolkit-SDK-CC201306/source/XMPFiles \
-IXMP-Toolkit-SDK-CC201306/source/XMPFiles/FileHandlers \
-IXMP-Toolkit-SDK-CC201306/source/XMPFiles/FormatSupport \
-IXMP-Toolkit-SDK-CC201306/third-party/MD5 \
-IXMP-Toolkit-SDK-CC201306/public/include \
XMP-Toolkit-SDK-CC201306/XMPCore/source/ExpatAdapter.cpp
XMP-Toolkit-SDK-CC201306/XMPCore/source/ExpatAdapter.cpp:9:77: fatal error:
public/include/XMP_Environment.h: No such file or directory
#include "public/include/XMP_Environment.h" // ! Must be the first #include!
^
It seems XMP started using relative includes in files rather than relying on compiler options. How do I handle this new include style in SCons?
(Background: When trying to compile dcp2icc (using a Makefile based on the original ReadMe.txt) I got a bunch of errors like 'strlen' is not a member of 'std', which seems to be because of an include clean-up in GCC. Rather than patch a bunch of third party libraries I decided to try a newer version of XMP.)
You should try to solve this include fail pretty much the same as you would on the command-line: by adding the missing include path, which in your case seems to be "-IXMP-Toolkit-SDK-CC201306". So, add your origXMP to the CPPPATH as well...

How to remove subdirectories from path

I don't really know anything about make or makefile scripts, so I'm hoping someone can tell me what I need to change. There is a common makefile script included in all of the others, and this specific piece of the code seems to be responsible for processing the list of source files (DLL_OBJS) and setting up the target to compile them:
ifdef DLL_TARGET
DLL_REAL_OBJS=$(addprefix $(OBJDIR)/, $(DLL_OBJS:=.$(OBJ))) $(DLL_VERSION_OBJS)
DLL_OUTPUT_FILE=$(OBJDIR)/$(LIBPREFIX)$(DLL_TARGET).$(DYNAMIC_LIB_SUFFIX)
$(DLL_OUTPUT_FILE): $(DLL_REAL_OBJS) $(DLL_NONPARSED_OBJS)
$(CC) $(CC_SHARED_LIB_FLAGS) $(LD_DYNAMIC) \
\
$(LD_DASH_O)$(DLL_OUTPUT_FILE) \
\
$(DLL_REAL_OBJS) $(DLL_NONPARSED_OBJS) \
$(DLL_EXTRA) $(PRELIB) $(LD_FLAGS) \
$(DLL_REAL_LIBS) $(DLL_NONPARSED_LIBS) $(LD_LIBS) $(DLL_OPTION)
ifdef EMBED_MANIFEST
ifndef SUPPRESS_MANIFEST_DLL
$(PREMANIFEST) $(MT) \
\
$(MANIFESTFLAGS) /outputresource:"$(DLL_OUTPUT_FILE);#2" /manifest $(DLL_OUTPUT_FILE).manifest
endif
endif
endif # DLL_TARGET
The problem is if I do this:
DLL_OBJS=subdir/main
Then it will try to write the main.obj file to WINNT5.0_DBG.OBJ/subdir/main.obj, whereas I want it to go to WINNT5.0_DBG.OBJ/main.obj. How can I modify the code above to exclude the subdirectory portion of the source file from the object file output path? I suspect the changes will need to happen to the DLL_REAL_OBJS variable.
Note that DLL_OBJS could be a list of items, like:
DLL_OBJS=\
subdir/main\
subdir/foo\
bar\
another_source
Let me know if any important information is missing and I will do my best to update my question with it.
If you're using GNUMake, just modify the second line:
DLL_REAL_OBJS=$(addprefix $(OBJDIR)/, $(notdir $(DLL_OBJS:=.$(OBJ)))) $(DLL_VERSION_OBJS)

How to substitute a pattern in Makefile.am

I have an application with several subdirectories, which I want to compile non-recursive. For this I have seperated all sorucefiles from the subdirectories into several variables, which I then use in the final collection of sources. Something like this:
GUI_SOURCEFILES = Gui/MainWindow.cc \
Gui/StatusBar.cc
...
foo_SOURCES = $(GUI_SOURCEFILES) \
$(DATABASE_SOURCEFILES) \
main.cc
Now however this forces me to write Gui/ for all gui sourcefiles and Db\ in front of all database files. I think it should be possible to create this prefix automaticall, but I cannot find a way to do this correctly. I tried the usual make way:
GUI_SOURCEFILES = MainWindow.cc \
StatusBar.cc
...
foo_SOURCES = $(GUI_SOURCEFILES) \
$(patsubst %,Gui/%,$(DATABASE_SOURCEFILES)) \
main.cc
But autotools will not compile this Makefile.am at all.
Is there a way to get autotools to do this for me?
There is no way here, all filenames must be available at automake time, and that precludes certain make-time like functions (non-portable at that).

Resources