how can i build luasocket on msys2 - msys2

Am new to lua/luajit. I was looking for a socket api for lua, and luasocket came up in searches, pacman -Ss luasocket doesnt exist so I have to compile it from source. Have not been successful, I was wondering if anyone can provide a makefile to build luasocket on msys2? Thanks in advance

I made a fork to to this using mingw64 and lua 5.3.
It's not as clean I wish it could be but it works : https://github.com/pmalhaire/luasocket
build and install :
$ git clone git#github.com:pmalhaire/luasocket.git
[...]
$ cd luasocket
[...]
$ make LUAV=5.3 PLAT=msys2
[...]
$ make LUAV=5.3 PLAT=msys2 install
[...]
$ make test
lua test/hello.lua
Hello from LuaSocket 3.0-rc1 and MIME 1.0.3!

Related

CMake incremental compilation through toolchain upgrade

I am trying to find a way to enable incremental compilation with CMake through a toolchain upgrade. Here is the problematic scenario :
Branch main uses g++-9 (using CMAKE_CXX_COMPILER=g++-9)
A new branch uses g++-10 (using CMAKE_CXX_COMPILER=g++-10)
Commits are happening on both branches
Incremental builds on one branch work fine
Switching to the other branch and explicitly invoking CMake fails
My question is the following : I'm looking for the proper way to make the invocation of CMake succeed and rebuild all the project from scratch when a toolchain change happens.
Here is a script that will make it quick and easy to reproduce the problem. This script requires Docker. It will create folders Sources and Build at the location where it is executed to avoid littering your filesystem. It then creates Dockerfiles to build docker containers with both g++ and cmake. It then creates a dummy Hello World C++ CMake project. Finally, it creates a folder for build artifacts and then executes the build with g++-9 and then g++-10. The second build fails because CMake generates an error.
#!/bin/bash
set -e
mkdir -p Sources
mkdir -p Build
# Creates a script that will be executed inside the docker container to perform builds
cat << EOF > Sources/Compile.sh
cd /Build \
&& cmake /Sources \
&& make \
&& ./IncrementalBuild
EOF
# Creates a Dockerfile that will be used to have both gcc-9 and cmake
cat << EOF > Sources/Dockerfile-gcc9
FROM gcc:9
RUN apt-get update && apt-get install -y cmake
RUN ln -s /usr/local/bin/g++ /usr/local/bin/g++-9
ADD Compile.sh /Compile.sh
RUN chmod +x /Compile.sh
ENTRYPOINT /Compile.sh
EOF
# Creates a Dockerfile that will be used to have both gcc-10 and cmake
cat << EOF > Sources/Dockerfile-gcc10
FROM gcc:10
RUN apt-get update && apt-get install -y cmake
RUN ln -s /usr/local/bin/g++ /usr/local/bin/g++-10
ADD Compile.sh /Compile.sh
RUN chmod +x /Compile.sh
ENTRYPOINT /Compile.sh
EOF
# Creates a dummy C++ program that will be compiled
cat << EOF > Sources/main.cpp
#include <iostream>
int main()
{
std::cout << "Hello World!\n";
}
EOF
# Creates CMakeLists.txt that will be used to compile the dummy C++ program
cat << EOF > Sources/CMakeLists.txt
cmake_minimum_required(VERSION 3.9)
project(IncrementalBuild CXX)
add_executable(IncrementalBuild main.cpp)
set_target_properties(IncrementalBuild PROPERTIES CXX_STANDARD 17)
EOF
# Build the docker images with both Dockerfiles created earlier
docker build -t cmake-gcc:9 -f Sources/Dockerfile-gcc9 Sources
docker build -t cmake-gcc:10 -f Sources/Dockerfile-gcc10 Sources
# Run a build with g++-9
echo ""
echo "### Compiling with g++-9 and then running the result..."
docker run --rm --user $(id -u):$(id -g) -v $(pwd)/Sources:/Sources -v $(pwd)/Build:/Build -e CXX=g++-9 cmake-gcc:9
echo ""
# Run a build with g++-10
echo "### Compiling with g++-10 and then running the result..."
docker run --rm --user $(id -u):$(id -g) -v $(pwd)/Sources:/Sources -v $(pwd)/Build:/Build -e CXX=g++-10 cmake-gcc:10
echo ""
# Print success if we reach this point
echo "SUCCESS!"
I'm looking for the proper way to make the invocation of CMake succeed and rebuild all the project from scratch when a toolchain change happens.
The proper way is to use a fresh binary directory. Either remove the binary directory when changing and let it recreate or just use a separate different directory for each toolchain.
Use Build/gcc10 binary directory for gcc10 build and Build/gcc9 for gcc9 builds.
No need to cd Build and mkdir with nowadays cmake - use cmake -S. -BBuild. Also do not use make - prefer cmake --build Build to let you switch generator later.
"If you change the toolchain, you should start with a fresh build. There are too many things that assume the toolchain doesn’t change and while you may be able to find workarounds which appear to work, I recommend you always use a fresh build tree for a different toolchain. This same logic also applies if you update the existing toolchain in-place (e.g. you update to a newer version of GCC on Linux, a newer version of Xcode on macOS, etc.). CMake queries compiler capabilities and caches the results. If you change the toolchain in a way that CMake can’t catch, then you end up with stale cached capabilities being used for the new/updated toolchain. Please don’t do that." - Craig Scott
So essentially I don't think it's possible. You just need to blow away your build. The best thing you can do is alert users if CMake isn't doing it for you.
Perhaps reply on this also:
https://discourse.cmake.org/t/how-to-change-toolchain-without-breaking-developer-workflows/1166
Or start another discourse.

How to use btgatt-client Command Line Tool

How do I use btgatt-client command line tool? Am I missing something very simple here?
As of Bluez 5.50, it is under in the tools folder (https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/tools/btgatt-client.c)
But when I try inputting the command, nothing seems to work.
pi#raspberrypi:~ $ btgatt-client
-bash: btgatt-client: command not found
pi#raspberrypi:~ $ sudo btgatt-client
sudo: btgatt-client: command not found
pi#raspberrypi:~ $ btgatt
-bash: btgatt: command not found
pi#raspberrypi:~ $ sudo btgatt
sudo: btgatt: command not found
Bluez sources needs to be compiled with tools support (by default it is enabled), but may be disabled in your raspberry PI build.
You can configure the source using
./configure --enable-tools
If want to cross compile, you may also need to use, "--host"
Or you can directly install the package "bluz-utils" from the package manager repository. For debian,
sudo apt-get install bluez-utils

Installing GDAL with ECW support

Most (all?) information online is outdated since ECW (Hexagon Geospatial/Intergraph) has recently released new versions with breaking changes (5.0, 5.1 and 5.2).
Most instructions result in errors like:
checking for libNCSEcw.so or libecwj2... configure: error: not found in /usr/local/lib or /usr/local/bin
This works for GDAL 1.11.2, but it should work back to 1.10.0.
Download the latest version of the ECW library from here (currently 5.5):
https://download.hexagongeospatial.com
Instructions for v5.2.1, but should be similar for the latest version:
$ unzip erdas-ecwjp2sdk-v5.2.1-linux.zip
$ chmod +x ERDAS_ECWJP2_SDK-5.2.1.bin
$ ./ERDAS_ECWJP2_SDK-5.2.1.bin
Choose Desktop Read-Only and accept the license. A directory named hexagon is extracted. Copy that to /usr/local.
$ sudo cp -r hexagon/ERDAS-ECW_JPEG_2000_SDK-5.2.1/Desktop_Read-Only /usr/local/hexagon
Link the .so library for the correct architecture:
$ sudo ln -s /usr/local/hexagon/lib/(x64|x86)/release/libNCSEcw.so /usr/local/lib/libNCSEcw.so
Then configure GDAL with this command:
$ ./configure --with-ecw=/usr/local/hexagon
Before I could see ECW support in gdalinfo --formats | grep -i ecw
I also had to run sudo ldconfig.
That was in Ubuntu 14.04 Linux.

automake-1.13: command not found

I was try to install Apache 2.4.
This requires apr, apr-util and pcre.
I was trying to configure pcre. I use the below command inside pcre directory :
$ ./configure --prefix=/usr/httpd*/srclib/pcre/
after this,
$ make
Output is like this :
cd . && /bin/sh /usr/httpd-2.4.9/srclib/pcre-8.33/missing automake-1.13 --gnu Makefile
/usr/httpd-2.4.9/srclib/pcre-8.33/missing: line 81: automake-1.13: command not found
WARNING: 'automake-1.13' is missing on your system.
You should only need it if you modified 'Makefile.am' or
'configure.ac' or m4 files included by 'configure.ac'.
The 'automake' program is part of the GNU Automake package:
http://www.gnu.org/software/automake
make: * [Makefile.in] Error 127
I tried configuring automake 1.13, but it didn't worked for me and I do not have permission to do something in root directory.
Please help !
Thank you in advance.
I found a workaround here: https://github.com/hyperrealm/libconfig/issues/22
Run these so to keep the executables that are being issues from running:
make AUTOCONF=: AUTOHEADER=: AUTOMAKE=: ACLOCAL=:
make install AUTOCONF=: AUTOHEADER=: AUTOMAKE=: ACLOCAL=:
I'm still having issues with the pcre-config but I'm pretty sure that's network time issue for me.

Autoconf macros for Apache and conf.d install process?

I have a package that is using the autotools to build and install.
Part of the package is a website that can be run on the local machine.
So in the package there is a .conf file that is meant to be either
copied or linked to the /etc/apache2/conf.d directory. What's the
standard way that packages would do this? If possible, I'd like for
the user not to have an extra step to make the website work. I'd like
to have them install the package and then be able to browse to
http://localhost/newpackage to get up and running.
Also, is there a way that autoconf knows about the apache install or a
standard way through then environment some how? If someone could
point me in the right direction that would be great.
Steve
The first thing you should do is to locate the apache extension tool apxs or apxs2 (depends on apache version and/or platform you are building for). After you know where your tool is located you can run queries to get certain apache config params. For example to get system config dir you can run:
apxs2 -q SYSCONFDIR
Here is a snippet of how you can locate apache extension tool: (be careful it may contain syntax errors)
dnl Note: AC_DEFUN goes here plus other stuff
AC_MSG_CHECKING(for apache APXS)
AC_ARG_WITH(apxs,
[AS_HELP_STRING([[--with-apxs[=FILE]]],
[path to the apxs, defaults to "apxs".])],
[
if test "$withval" = "yes"; then
APXS=apxs
else
APXS="$withval"
fi
])
if test -z "$APXS"; then
for i in /usr/sbin /usr/local/apache/bin /usr/bin ; do
if test -f "$i/apxs2"; then
APXS="$i/apxs2"
break
fi
if test -f "$i/apxs"; then
APXS="$i/apxs"
break
fi
done
fi
AC_SUBST(APXS)
The way to use APXS in your automake Makefile.am would look something like this:
## Find apache sys config dir
APACHE2_SYSCONFDIR = `#APXS# -q SYSCONFDIR`
## Misc automake stuff goes here
install: install-am
cp my.conf $(DESTDIR)${APACHE2_SYSCONFDIR}/conf.d/my.conf
I assume you are familiar with automake and autoconf tools.