Bug 267181 - audio/portaudio: Add missing example headers preventing compilation
Summary: audio/portaudio: Add missing example headers preventing compilation
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Hans Petter Selasky
URL: https://www.freshports.org/audio/port...
Keywords: needs-patch
Depends on:
Blocks: 259255
  Show dependency treegraph
 
Reported: 2022-10-18 18:57 UTC by Alex Bylund
Modified: 2022-12-06 17:02 UTC (History)
4 users (show)

See Also:
riggs: maintainer-feedback+
koobs: merge-quarterly?


Attachments
Does this patch work for you? (1.01 KB, patch)
2022-10-19 11:18 UTC, Hans Petter Selasky
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Bylund 2022-10-18 18:57:14 UTC
Missing pa_ringbuffer.h and pa_util.h are preventing the paex_ocean_shore.c and paex_record_file.c examples from compiling.
Comment 1 Hans Petter Selasky freebsd_committer freebsd_triage 2022-10-18 20:17:19 UTC
Do you have a patch?
Comment 2 Tatsuki Makino 2022-10-19 05:47:43 UTC
(In reply to Hans Petter Selasky from comment #1)

The following modifications may be necessary to handle paex_* files here.

* Use CMake instead of GNU configure.
* Build with PA_BUILD_EXAMPLES turned on.
* Add additional files to be installed to pkg-plist.

such as.
Some files/patch-* are applied to GNU configure files, so the modification will be relatively extensive.
Comment 3 Hans Petter Selasky freebsd_committer freebsd_triage 2022-10-19 11:18:42 UTC
Created attachment 237454 [details]
Does this patch work for you?

cd /usr/local/share/examples/portaudio

clang -L/usr/local/lib -lm -lpthread -lportaudio -I/usr/local/include pa_unix*.c pa_allocation.c pa_ringbuffer.c pa_debugprint.c pa_front.c paex_ocean_shore.c

--HPS
Comment 4 Tatsuki Makino 2022-10-20 05:31:37 UTC
(In reply to Hans Petter Selasky from comment #3)

Why is example source code and not pre-built binaries? 🤣

I think the reason you need so many copies of files like that patch is because there are limitations on the functions that can be used in libportaudio.
The part that seems to do it is in PA_LDFLAGS of ${WRKSRC}/Makefile.in.
The first thing that is no good is that PaUtil is not included in the -export-symbols-regex there. Probably :)

Note that switching to CMake is not a solution, since it is no longer possible to create libportaudiocpp.
Comment 5 Tatsuki Makino 2022-10-20 06:18:31 UTC
(In reply to Hans Petter Selasky from comment #3)

Add a few more.

> clang -L/usr/local/lib -lm -lpthread -lportaudio -I/usr/local/include pa_unix*.c pa_allocation.c pa_ringbuffer.c pa_debugprint.c pa_front.c paex_ocean_shore.c

It seems a little better to link with libportaudio.a instead of -lportaudio.

cc -I/usr/local/include -I /tmp/directory_for_pa_ringbuffer.h_and_pa_util.h -lm -pthread /usr/local/lib/libportaudio.a /usr/local/share/examples/portaudio/paex_ocean_shore.c

However, libportaudio.a does not contain anything that can resolve the PaUtil_*RingBuffer* symbol.

The reason for this is that libportaudio links COMMON_OBJS and OTHER_OBJS in ${WRKSRC}/Makefile.in, but OTHER_OBJS is a variable provided from ${WRKSRC}/configure.in.
In configure.in, OTHER_OBJS is added by the add_objects function, and pa_ringbuffer.o is also added here.
In order for ringbuffer to be included on FreeBSD ports, JACK option must be set.
Comment 6 Hans Petter Selasky freebsd_committer freebsd_triage 2022-10-20 08:33:14 UTC
Examples are supposed to be source code and not binaries?

Is the solution I propose OK?

--HPS
Comment 7 Tatsuki Makino 2022-10-20 10:05:31 UTC
(In reply to Hans Petter Selasky from comment #6)
> Examples are supposed to be source code and not binaries?

It was just strange because the source files were installed without the Makefile, options to pass to the compiler, or any other hints to build... :)

attachment 237454 [details] would have to be asked of the person who actually builds the sample.
libportaudio made with the default option will need to be built and linked with pa_ringbuffer.c at the same time, and libportaudio made with the JACK option turned on will not need pa_ringbuffer.c...

To only install a few additional header files, it would be better to apply the patch to PA_LDFLAGS and OTHER_OBJS...
Comment 8 Hans Petter Selasky freebsd_committer freebsd_triage 2022-10-20 10:22:07 UTC
May I ask why you need the example utilities in binary form?
Comment 9 Tatsuki Makino 2022-10-21 00:16:00 UTC
(In reply to Hans Petter Selasky from comment #8)

I'm sorry, comment #4 was a statement that contained my bias that graphic image audio video examples are almost always provided in executable binary form, sorry.


However, I have the slightest hope that the installation of the source files of the part contained in libportaudio will be avoided, since they are not directly related to the example.
Since OPTIONS_SUB=yes is already used, it would be possible to prepare a pkg-message like the following and add it to SUB_FILES.

-- begin pkg-message.in --
[
{ type: install
  message: <<EOM
Notes on building examples
%%JACK%%  None.
%%EXAMPLES%%%%JACK%%  They should be built as cc -I/usr/local/include ..../pa_devs.c
%%NO_JACK%%  Support for some features is missing from libportaudio.
%%NO_JACK%%  Therefore, some examples cannot be built.
EOM
}
]
-- end pkg-message.in --
Comment 10 Thomas Zander freebsd_committer freebsd_triage 2022-12-05 07:48:36 UTC
HPS, feel free to commit your patch and close this out.
Comment 11 Hans Petter Selasky freebsd_committer freebsd_triage 2022-12-05 10:07:48 UTC
I will look at this again. 

:-)

--HPS
Comment 12 Hans Petter Selasky freebsd_committer freebsd_triage 2022-12-06 16:39:52 UTC
(In reply to Tatsuki Makino from comment #9)

Yes, that is possible.
Comment 13 commit-hook freebsd_committer freebsd_triage 2022-12-06 17:01:49 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=a6e4e0d324d2c661b2e6434faefd492d11af2fb8

commit a6e4e0d324d2c661b2e6434faefd492d11af2fb8
Author:     Hans Petter Selasky <hselasky@FreeBSD.org>
AuthorDate: 2022-10-19 11:18:11 +0000
Commit:     Hans Petter Selasky <hselasky@FreeBSD.org>
CommitDate: 2022-12-06 17:00:45 +0000

    audio/portaudio: Install missing source files to build examples.

    PR: 267181
    Approved by: pi (implicit)

 audio/portaudio/Makefile                   |  6 +++++-
 audio/portaudio/files/pkg-message.in (new) | 14 ++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)
Comment 14 Hans Petter Selasky freebsd_committer freebsd_triage 2022-12-06 17:02:30 UTC
Let me know if you need more changes.