How can you use autoconf to determine if a symbol is defined in the httpd executable used by apxs? - cross-platform

How can you use autoconf to determine if a symbol is defined in the httpd executable used by apxs?
At some point around apache v2.2 the apr_connect function was replaced with apr_socket_connect. To make a module compatible with multiple versions of apache I will need to use autoconf to create defines based on the availability of apr_connect or apr_socket_connect.
The current sources are at https://github.com/rritoch/PikeVM/blob/master/root/boot/system-1.1/apache/configure.ac
Are there any pre-defined macros for autoconf that can perform this test?

Related

What are the possible values of CMAKE_SYSTEM_PROCESSOR?

In CMake, what are the different possible values of CMAKE_SYSTEM_PROCESSOR? At least, the values for common processor families by AMD, Intel, Apple, Qualcomm and such?
I couldn't find this information in the CMake documentation.
According to the documentation, "when not cross-compiling, this variable has the same value as the CMAKE_HOST_SYSTEM_PROCESSOR variable". In the former scenario, the variable is set by the toolchain file, which I assume is what you're interested in doing.
In the latter case, the documentation says that CMAKE_HOST_SYSTEM_PROCESSOR is determined by inspecting the environment in the following way:
On Windows, the value of the PROCESSOR_ARCHITECTURE environment variable is used.
The options are: AMD64, IA64, ARM64, EM64T, X86. Source: this SuperUser answer.
On macOS, the value of uname -m is used by default. However, since this might vary based on whether you're using x86 or ARM CMake, version 3.19.2+ will use the value of CMAKE_APPLE_SILICON_PROCESSOR (either CMake or environment variable) instead, if it is set. It also normalizes Power Macintosh to powerpc.
As far as I am aware, the possible values here are x86_64, arm64, and powerpc.
On OpenBSD, it uses the arch -s command.
Not sure what the full list is here. Unfortunately, the man page doesn't have anything to say about this.
On Linux and related systems (Cygwin, MSYS, Android, GNU), it uses uname -m
This has many possible values. See: https://stackoverflow.com/a/45125525/2137996
Otherwise, it looks for the uname command and tries uname -p first. If it returns a non-zero exit status, it resorts to uname -m
No telling what this could be.
But what really matters is how CMake will use the value of CMAKE_SYSTEM_PROCESSOR. Here are the functions I'm aware of:
The default value of CPACK_SYSTEM_NAME is ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}.
The language modules Modules/CMake<LANG>Information.cmake all optionally include platform modules suffixed with -${CMAKE_SYSTEM_PROCESSOR}.cmake
In most cases, no such modules exist. On Android, very many platform modules exist with processor-specific variants.
The FindJNI module uses it to guide its search
It is passed to ARMClang via --mcpu (compile) and --cpu (link)

how to use find_package in cmake?

when using
find_package(OpenSSL MODULE REQUIRED)
I got the following output
-- Found OpenSSL: /usr/local/lib/libcrypto.so (found version "2.0.0")
but when i use
find_package(OpenSSL REQUIRED PATHS /usr/local/lib/libcrypto.so)
I am getting an error.
Could not find a package configuration file provided by "OpenSSL" with any of the following names: OpenSSLConfig.cmake openssl-config.cmake
can anyone explain why this is happening and also is it the coorect way of using the find_package in the config mode.
You are essentially using 2 different behaviors.
# This way is using Basic Signature and Module Mode
# https://cmake.org/cmake/help/latest/command/find_package.html?highlight=find_package#basic-signature-and-module-mode
find_package(OpenSSL MODULE REQUIRED)
"
The command has two modes by which it searches for packages: "Module" mode and "Config" mode. The above signature selects Module mode. If no module is found the command falls back to Config mode, described below. This fall back is disabled if the MODULE option is given.
In Module mode, CMake searches for a file called Find.cmake. The file is first searched in the CMAKE_MODULE_PATH, then among the Find Modules provided by the CMake installation. If the file is found, it is read and processed by CMake. It is responsible for finding the package, checking the version, and producing any needed messages. Some find-modules provide limited or no support for versioning; check the module documentation.
"
So essentially in the first one you are using the FindOpenSLL cmake module.
"https://cmake.org/cmake/help/latest/module/FindOpenSSL.html?highlight=openssl"
Where as in the second one you are saying to not use the module CMake has written for you. So of course it is confused as to where to look for.

Recompile with -fPIC Gentoo

I'm new to Gentoo and trying to install a 3D modelling program called TexGen (http://texgen.sourceforge.net/index.php/Main_Page) using CMake, and I keep getting the error:
relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
This occurs during the step:
[ 80%] Linking CXX shared module ../_Renderer.so
I've looked all over and tried setting the -fPIC flag in the cmake options file, but there's no change in the result. As I said I'm quite new (in the order of a few weeks) to Linux and Gentoo and any help would be greatly appreciated.
Actually Gentoo has a eclass(es) to build CMake based projects (see /usr/portage/cmake*.eclass). And AFAIK, it replace package options with yours (to be precise, it adds a new configuration type), configured in /etc/portage/make.conf (or /etc/paludis/bashrc if you use paludis). So, I not wondered that "hacking" CMakeLists.txt in the package ebuild do not help.
So, easiest way is to add that option to your Gentoo settings instead. Personaly I use this way to build boost library in my system (yep, I need boost's static libraries to be linked into dynamic one in some of my projects). And yes, I'm using paludis, but emerge probably has similar feature (a way to set per package compiler options).
The other way, instead of "hacking" compiler options directly (via CMAKE_<LANG>_FLAGS), take a look to CMAKE_POSITION_INDEPENDENT_CODE -- it'll add a proper compiler option for you, and probably eclass' manipulations with cache wouldn't affect this setting.
I got it to work (for installing ffmpeg) by simply reinstalling the whole thing from the beginning with all instances of $ ./configure replaced by $ ./configure --enable-shared (first make sure to delete all the folders and files including the .so files from the previous attempt).
Apparently this works because https://stackoverflow.com/a/13812368/10593190.

What does 'module' in cmake 'pkg_check_modules' stand for?

I am building a certain module in GNU Radio. (Let's call it my-module.)
GNU Radio uses cmake to build and intall a my-module.
In the project, I need to use a module that was made by others. This can be it++ and other gnuradio-modules. And I will be using a gnuradio module. (Let's call it other-module.)
To use other modules in my gr-module, I need to use find_package, pkg_check_modules and find_library to tell 'I will be using pre-built modules'
And pkg_check_modules(PC_ITPP itpp) can successfully detect it++.
But I am having difficulties in finding other-module. As I put pkg_check_modules(PC_OTHER_MODULE other_module), it can't detect the module.
What I am curious is, what does module in pkg_check_modules(<PREFIX> <MODULE>) stand for and how and where does cmake find a given module?
Of course, I don't think it's a kernel module since I don't see it++ in the list of kernel modules. Then, are they cmake-modules? I don't think so, neither, becausecmake --help-module-list doesn't show it++.
Is there a special file that contains a list of modules that can be referred by cmake? If then, should it++and other library, modules be registered in that file at the build and installation steps in order to be recognized as modules by cmake?
pkg_check_modules(<PREFIX> <MODULE>) invokes pkg-config, queries for <MODULE> and returns the result in variables which have names beginning with <PREFIX>_. Thus module is the name of the software you / pkg-config are looking for.
If your other_module is not found, try directly with pkg-config, whether pkg-config knows about other_module, use pkg-config --modversion other_module to do so.
With pkg-config --list-all you get a list of all modules known by pkg-config.
If your 3rd party software is not part of pkg-config and there is no FindOTHER_MODULE.cmake provided by CMake, you can google for it. Maybe someone else wrote exactly that test and you can use it. Or you have to write your own test using find_includs, find_library et al.

Repeatability and the Random module across different versions of OCaml

I've been setting up a test-suite along with advancing the application my team is writing and today I came across a problem in how I was going to test scripts that get run through our application. We allow the user to set a seed for the Random module to allow repeatability in results (this is very important in a scientific application), I use this in our test suite to compare the stdout/stderr from a set of scripts with 'approved' runs.
In updating those scripts I noticed that all the scripts failed on certain machines. I soon discovered this was due to the Random module from version 3.12.0 changing the core function for generating random bits. Currently we run a number of versions of OCaml (including 3.13) across a number of environments (win32, osx, linux) and we would prefer to test against different versions of OCaml.
I would like to replace the Random module from 3.12.1 into our distribution to allow for consistency regardless of the version of OCaml the user is compiling against. But, the naive approach to drop the Random module in the source directory reports that the compiler found two files that define a module named Random.
Any suggestions on solving this issue? I realize I can rename Random to XRandom and then use that module to define what I need or include the standard library random module, but that would require changing every function call and allows developers to continue to (accidentally) use Random instead of the overloaded version. Is there a way to select a specific random module during compilation? Or maybe some other option I'm unaware of.
EDIT:
I just took the Random module from OCaml 3.12.1 and dropped it into my project, on compilation via OCamlbuild I got the following error message during linking (this the same error with OCaml 3.13.0+dev8, and pretty much what I expected when I did it),
Error: Files random.cmx and /opt/ocaml-3.12.1/lib/ocaml/stdlib.cmxa
both define a module named Random
And the linking line is,
/opt/ocaml-3.12.1/bin/ocamlopt.opt dynlink.cmxa unix.cmxa str.cmxa bigarray.cmxa -I +camlp4 camlp4fulllib.cmxa -cclib -lcside -cclib -L. -ccopt -I -ccopt /usr/lib -cclib -L. -cclib -Wl,--no-as-needed -cc gcc -cclib -llapack -cclib -lblas -cclib -lgfortran -cclib -lz -cclib -lreadline -cclib -lm -cclib '' compileFlags.cmx all_sets.cmx random.cmx status.cmx timer.cmx sexpr.cmx xml.cmx bitSet.cmx lz.cmx fileStream.cmx methods.cmx utl.cmx cost_matrix.cmx alphabet.cmx primes.cmx fileContents.cmx numerical.cmx version.cmx scripting.cmx libgrappa.a libgzcaml.a libzlibstubs.a libcside.a -o scripting.native
You can indeed use your own XRandom module, and add module Random = XRandom at the top of your test files.
Unfortunately, I'm afraid there is no good and clean solution to your problem ...