davidmoreno / rtpmidid

RTP MIDI (AppleMIDI) daemon for Linux
Other
183 stars 41 forks source link

new Makefile paths need work #121

Closed sadguitarius closed 1 month ago

sadguitarius commented 2 months ago

The Makefile paths could still use a little massaging. I understand the reasoning behind the change, but now if the prefix variable is empty, the binary installs to /bin which is a no-go for Arch and breaks the unofficial PKGBUILD, and adding to the prefix puts things like the systemd service in a weird place. Do we need to split the prefix into a couple of different variables or something? I'll mess around and see what I come up with.

sadguitarius commented 2 months ago

If PREFIX and DESTDIR are split so that PREFIX points to the actual installation prefix and DESTDIR can be used as a staging variable in the PKGBUILD, this works for me. I have no idea if this is the most sensible way to do it, but here's what I've got so far:

ifeq ($(PREFIX),)
    PREFIX := /usr/local
endif
.PHONY: install

install: install-rtpmidid install-librtpmidid0 install-librtpmidid0-dev

install-rtpmidid: build man
    mkdir -p $(DESTDIR)/$(PREFIX)/bin/
    cp build/src/rtpmidid $(DESTDIR)/$(PREFIX)/bin/
    cd cli && make compile
    cp build/rtpmidid-cli $(DESTDIR)/$(PREFIX)/bin/rtpmidid-cli
    mkdir -p $(DESTDIR)/etc/systemd/system/
    cp debian/rtpmidid.service $(DESTDIR)/etc/systemd/system/
    mkdir -p $(DESTDIR)/etc/rtpmidid/
    cp default.ini $(DESTDIR)/etc/rtpmidid/
    mkdir -p $(DESTDIR)/$(PREFIX)/share/doc/rtpmidid/
    cp README.md $(DESTDIR)/$(PREFIX)/share/doc/rtpmidid/
    cp LICENSE-daemon.txt $(DESTDIR)/$(PREFIX)/share/doc/rtpmidid/LICENSE.txt
    mkdir -p $(DESTDIR)/$(PREFIX)/share/man/man1/
    cp build/man/rtpmidid.1 $(DESTDIR)/$(PREFIX)/share/man/man1/
    cp build/man/rtpmidid-cli.1 $(DESTDIR)/$(PREFIX)/share/man/man1/

install-librtpmidid0: build
    mkdir -p $(DESTDIR)/$(PREFIX)/lib/
    cp -a build/lib/lib*so* $(DESTDIR)/$(PREFIX)/lib/
    mkdir -p $(DESTDIR)/$(PREFIX)/share/doc/librtpmidid0/
    cp README.md $(DESTDIR)/$(PREFIX)/share/doc/librtpmidid0/
    cp README.librtpmidid.md $(DESTDIR)/$(PREFIX)/share/doc/librtpmidid0/
    cp LICENSE-lib.txt $(DESTDIR)/$(PREFIX)/share/doc/librtpmidid0/LICENSE.txt

install-librtpmidid0-dev: build
    mkdir -p $(DESTDIR)/$(PREFIX)/lib/ $(DESTDIR)/$(PREFIX)/include/
    cp -a build/lib/lib*.a $(DESTDIR)/$(PREFIX)/lib/
    cp -a include/rtpmidid $(DESTDIR)/$(PREFIX)/include/
    mkdir -p $(DESTDIR)/$(PREFIX)/share/doc/librtpmidid0-dev/
    cp README.md $(DESTDIR)/$(PREFIX)/share/doc/librtpmidid0-dev/
    cp README.librtpmidid.md $(DESTDIR)/$(PREFIX)/share/doc/librtpmidid0-dev/
    cp LICENSE-lib.txt $(DESTDIR)/$(PREFIX)/share/doc/librtpmidid0-dev/LICENSE.txt
sadguitarius commented 2 months ago

Here's the PKGBUILD I'm using, basically the same as the AUR one but setting the PREFIX to /usr. It's currently pointing to my working branch, which has a few other tweaks to the build process that may not all be great for everyone. Just in case anyone wants to try this out.

pkgname='rtpmidid-git'
pkgver=r783.6d7125d
pkgrel=1
pkgdesc="RTP MIDI User Space Driver Daemon"
arch=('i686' 'x86_64')
url='https://github.com/davidmoreno/rtpmidid'
license=('GPL3')
depends=('alsa-lib' 'fmt' 'avahi')
makedepends=('git' 'cmake')
provides=('rtpmidid')
conflicts=('rtpmidid')
# source=('rtpmidid-git::git+https://github.com/davidmoreno/rtpmidid.git')
source=('rtpmidid-git::git+https://github.com/sadguitarius/rtpmidid.git#branch=makefile-fix')
sha256sums=('SKIP')

pkgver() {
  cd "$pkgname"
  #git describe --long --tags 2>/dev/null | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
  cd "$pkgname"
}

build() {
  cd "$pkgname"
  make build
}

package() {
  cd "$pkgname"
  make DESTDIR="$pkgdir" PREFIX="/usr" install
}
davidmoreno commented 1 month ago

I just updated the Makefile with new logic:

So for exmaple the debian packaging needs to call make like:

make install-rtpmidid DESTDIR=debian/rtpmidid/ SYSCONFDIR=etc PREFIX=usr

I think this is the proper way to do it, butcorrect me if I'm wrong. For arch, I prefer you send me a pull request to be sure it works.

sadguitarius commented 1 month ago

Ok great, this seems like it's working fine when I add those variables to the build script. Thank you!

I'm most of the way through updating the Arch PKGBUILD so that it will actually do all of the behind-the-scenes stuff in the same way the Debian installation works. When I'm done, I'll see if anyone will accept the changes to the current broken unofficial script so you can link to it if you want.