Syntax problem with porting an autoconf makefile to the meson build system

13 views
Skip to first unread message

Dave Griffin

unread,
Feb 17, 2024, 8:34:18 AMFeb 17
to The Meson Build System

I am in the process of creating a meson build system for an open source project that currently uses autoconf. One of the target executables has additional configuration if dtrace is found in the host operating system. The snippet of relevant code from the makefile.am is:

if WITH_DTRACE
DTRACE_OBJ = afpd-afp_dsi.o afpd-fork.o afpd-appl.o afpd-catsearch.o afpd-directory.o afpd-enumerate.o afpd-file.o afpd-filedir.o
afp_dtrace.o: $(top_srcdir)/include/atalk/afp_dtrace.d $(DTRACE_OBJ)
if test -f afp_dtrace.o ; then rm -f afp_dtrace.o ; fi
    CC=$(CC) $(LIBTOOL) --mode=execute dtrace -G -s $(top_srcdir)/include/atalk/afp_dtrace.d -o afp_dtrace.o $(DTRACE_OBJ)
afpd_LDADD += afp_dtrace.o @DTRACE_LIBS@
CLEANFILES += afp_dtrace.o
endif

So if dtrace is found libtool is used on some of the already compiled object files (DTRACE_OBJ) to create the afp_dtrace.o object using a dtrace command. This object then becomes an additional linker item for the executable :

afpd_LDADD += afp_dtrace.o @DTRACE_LIBS@

Can anyone who is familiar with meson point me in the right direction for the syntax required to achieve the same result?

I have tried using the extract_objects() function within a custom_target to no avail so far:

afpd = executable(
     'afpd', afpd_sources,
    include_directories: root_includes,
    link_with: [afpd_internal_deps, libatalk],
    dependencies: [ afpd_external_deps, gssapi, kerberos, libgcrypt, mysqlclient, threads, ]
    c_args: [ '-DAPPLCNAME', confdir, dversion, messagedir, statedir, uamdir, ],
    export_dynamic: true,
    install: true,
    install_dir: sbindir,
)
if have_dtrace
    afp_dtrace_object = custom_target(
         'afp_dtrace_object',
        input: afpd.extract_objects( 'afp_dsi.c', 'fork.c', 'appl.c', 'catsearch.c', 'directory.c', 'enumerate.c', 'file.c', 'filedir.c', ),
        output: 'afp_dtrace.o',
        command: [ dtrace, '-G', '-s', meson.project_source_root() / 'include/atalk/afp_dtrace.d', '-o', '@OUTPUT@', '@INPUT@', ], )

    dtrace_deps += declare_dependency(sources: afp_dtrace_object)
    afpd_external_deps += dtrace_deps
endif

Volker Weißmann

unread,
Feb 18, 2024, 9:43:17 AMFeb 18
to meson...@googlegroups.com

I'm not familiar with dtrace, but can you make dtrace output a .a file instead of a .o file? I've attached a working example that substitutes dtrace with cp.

I also found this unit test:

test cases/common/216 link custom/meson.build

Does that solve your issue?

--
You received this message because you are subscribed to the Google Groups "The Meson Build System" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mesonbuild+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/mesonbuild/e79b6cbf-9b1f-407b-ad3b-367a430f199fn%40googlegroups.com.
example.tar
Reply all
Reply to author
Forward
0 new messages