Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add debian build #92

Merged
merged 3 commits into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ jobs:
- name: Build
run: make

deb-build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Dependencies
run: |
sudo apt-get update
sudo apt-get install -y devscripts equivs
sudo mk-build-deps -i -t 'apt-get -y --no-install-recommends'
- name: Build
run: dpkg-buildpackage -us -uc -b

osx-build:

runs-on: macos-latest
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@
scythe
scythe2
footswitch
obj*/
*-build-deps_*
debian/files
debian/footswitch/
debian/footswitch.substvars
debian/*debhelper*
24 changes: 24 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
cmake_minimum_required(VERSION 3.13)
project(footswitch C)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY build)
set(SRCDIR src)

find_package(PkgConfig)
pkg_check_modules(HIDAPI REQUIRED hidapi-libusb)

include_directories(${HIDAPI_INCLUDE_DIRS} include)
link_libraries(${HIDAPI_LIBRARIES})
link_directories(src)

foreach(exe IN ITEMS footswitch scythe scythe2)
add_executable(${exe}
${SRCDIR}/common.c
${SRCDIR}/debug.c
${SRCDIR}/${exe}.c
)

install(TARGETS ${exe}
RUNTIME DESTINATION bin
)
endforeach()
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM debian:bookworm
drlkf marked this conversation as resolved.
Show resolved Hide resolved

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y devscripts equivs

COPY . /build
WORKDIR /build
RUN mk-build-deps -i -t 'apt-get -y --no-install-recommends' && \
dpkg-buildpackage -us -uc -b
61 changes: 39 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,46 +1,63 @@
PREFIX = /usr/local
UDEVPREFIX = /etc/udev
PREFIX := /usr/local
UDEVPREFIX := /etc/udev

TARGETS := \
footswitch \
scythe \
scythe2

INCDIR := include
SRCDIR := src
OBJDIR := obj

COMMONSRC := \
common.c \
debug.c

INSTALL := /usr/bin/install -c
INSTALLDATA := /usr/bin/install -c -m 644
CFLAGS := -Wall -I$(INCDIR)
UNAME := $(shell uname)

INSTALL = /usr/bin/install -c
INSTALLDATA = /usr/bin/install -c -m 644
CFLAGS = -Wall
UNAME := $(shell uname)
ifeq ($(UNAME), Darwin)
CFLAGS += -DOSX $(shell pkg-config --cflags hidapi)
LDLIBS = $(shell pkg-config --libs hidapi)
CFLAGS += -DOSX $(shell pkg-config --cflags hidapi)
LDLIBS := $(shell pkg-config --libs hidapi)
else
ifeq ($(UNAME), Linux)
CFLAGS += $(shell pkg-config --cflags hidapi-libusb)
LDLIBS = $(shell pkg-config --libs hidapi-libusb)
CFLAGS += $(shell pkg-config --cflags hidapi-libusb)
LDLIBS := $(shell pkg-config --libs hidapi-libusb)
else
LDLIBS = -lhidapi
LDLIBS := -lhidapi
endif
endif

all: footswitch scythe scythe2
all: $(OBJDIR) $(TARGETS)

$(OBJDIR):
mkdir $@

$(OBJDIR)/%.o: $(SRCDIR)/%.c
$(CC) $(CFLAGS) -c -o $@ $<

footswitch: footswitch.c common.c debug.c
scythe: scythe.c common.c debug.c
scythe2: scythe2.c common.c debug.c
$(TARGETS): %: $(patsubst %.c, $(OBJDIR)/%.o, $(COMMONSRC)) $(OBJDIR)/%.o
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS)

install: all
$(INSTALL) -d $(DESTDIR)$(PREFIX)/bin
$(INSTALL) footswitch $(DESTDIR)$(PREFIX)/bin
$(INSTALL) scythe $(DESTDIR)$(PREFIX)/bin
$(INSTALL) scythe2 $(DESTDIR)$(PREFIX)/bin
for target in $(TARGETS); do \
$(INSTALL) "$$target" $(DESTDIR)$(PREFIX)/bin; \
done
ifeq ($(UNAME), Linux)
$(INSTALL) -d $(DESTDIR)$(UDEVPREFIX)/rules.d
$(INSTALLDATA) 19-footswitch.rules $(DESTDIR)$(UDEVPREFIX)/rules.d
endif

uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/footswitch
rm -f $(DESTDIR)$(PREFIX)/bin/scythe
rm -f $(DESTDIR)$(PREFIX)/bin/scythe2
rm -f $(addprefix $(DESTDIR)$(PREFIX)/bin/, $(TARGETS))
ifeq ($(UNAME), Linux)
rm -f $(DESTDIR)$(UDEVPREFIX)/rules.d/19-footswitch.rules
endif

clean:
rm -f scythe scythe2 footswitch *.o
rm -rf $(TARGETS) $(OBJDIR)

19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,25 @@ The same kind of foot switches are used for building the popular [VIM Clutch][2]
Building
--------

Debian
------

On a debian machine, provided you have `devscripts` and `equivs` installed:

```bash
mk-build-deps -i
dpkg-buildpackage -us -uc -b
```

Or, you can build the package in a Docker container:

```bash
docker build .
```

Other systems
-------------

The programs are using the [hidapi][3] library and should work on Linux and OSX. To build on Linux:

sudo apt-get install libhidapi-dev
Expand Down
5 changes: 5 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
footswitch (1.0.0) stable; urgency=medium

* Initial release.

-- drlkf <[email protected]> Thu, 16 May 2024 19:27:47 +0200
1 change: 1 addition & 0 deletions debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
11
14 changes: 14 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Source: footswitch
Section: utils
Priority: optional
Maintainer: Radoslav Gerganov <[email protected]>
Build-Depends:
cmake,
libhidapi-dev,
pkg-config

Package: footswitch
Description: Command-line tools to configure PCsensor and Scythe foot switches.
Architecture: any
Depends:
libhidapi-libusb0
12 changes: 12 additions & 0 deletions debian/footswitch.udev
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# PCsensor
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7403", MODE="0666"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7404", MODE="0666"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="413d", ATTRS{idProduct}=="2107", MODE="0666"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="e026", MODE="0666"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="3553", ATTRS{idProduct}=="b001", MODE="0666"

# Scythe
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0426", ATTRS{idProduct}=="3011", MODE="0666"

# Scythe2
SUBSYSTEMS=="usb", ATTRS{idVendor}=="055a", ATTRS{idProduct}=="0998", MODE="0666"
4 changes: 4 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/make -f

%:
dh $@ --buildsystem=cmake
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading