Skip to content

Commit 4df9014

Browse files
committed
feat: add debian build
1 parent 4cd2303 commit 4df9014

17 files changed

+134
-22
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,9 @@
33
scythe
44
scythe2
55
footswitch
6+
obj*/
7+
*-build-deps_*
8+
debian/files
9+
debian/footswitch-cli/
10+
debian/footswitch-cli.substvars
11+
debian/*debhelper*

CMakeLists.txt

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
cmake_minimum_required(VERSION 3.13)
2+
project(footswitch-cli C)
3+
4+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY build)
5+
set(SRCDIR src)
6+
7+
find_package(PkgConfig)
8+
pkg_check_modules(HIDAPI REQUIRED hidapi-libusb)
9+
10+
include_directories(${HIDAPI_INCLUDE_DIRS} include)
11+
link_libraries(${HIDAPI_LIBRARIES})
12+
link_directories(src)
13+
14+
foreach(exe IN ITEMS footswitch scythe scythe2)
15+
add_executable(${exe}-cli
16+
${SRCDIR}/common.c
17+
${SRCDIR}/debug.c
18+
${SRCDIR}/${exe}.c
19+
)
20+
21+
install(TARGETS ${exe}-cli
22+
RUNTIME DESTINATION bin
23+
)
24+
endforeach()

Dockerfile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM debian:bookworm
2+
3+
ENV DEBIAN_FRONTEND=noninteractive
4+
RUN apt-get update && \
5+
apt-get install -y devscripts equivs
6+
7+
COPY . /build
8+
WORKDIR /build
9+
RUN mk-build-deps -i -t 'apt-get -y --no-install-recommends' && \
10+
dpkg-buildpackage -us -uc -b

Makefile

+39-22
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,63 @@
1-
PREFIX = /usr/local
2-
UDEVPREFIX = /etc/udev
1+
PREFIX := /usr/local
2+
UDEVPREFIX := /etc/udev
3+
4+
TARGETS := \
5+
footswitch \
6+
scythe \
7+
scythe2
8+
9+
INCDIR := include
10+
SRCDIR := src
11+
OBJDIR := obj
12+
13+
COMMONSRC := \
14+
common.c \
15+
debug.c
16+
17+
INSTALL := /usr/bin/install -c
18+
INSTALLDATA := /usr/bin/install -c -m 644
19+
CFLAGS := -Wall -I$(INCDIR)
20+
UNAME := $(shell uname)
321

4-
INSTALL = /usr/bin/install -c
5-
INSTALLDATA = /usr/bin/install -c -m 644
6-
CFLAGS = -Wall
7-
UNAME := $(shell uname)
822
ifeq ($(UNAME), Darwin)
9-
CFLAGS += -DOSX $(shell pkg-config --cflags hidapi)
10-
LDLIBS = $(shell pkg-config --libs hidapi)
23+
CFLAGS += -DOSX $(shell pkg-config --cflags hidapi)
24+
LDLIBS := $(shell pkg-config --libs hidapi)
1125
else
1226
ifeq ($(UNAME), Linux)
13-
CFLAGS += $(shell pkg-config --cflags hidapi-libusb)
14-
LDLIBS = $(shell pkg-config --libs hidapi-libusb)
27+
CFLAGS += $(shell pkg-config --cflags hidapi-libusb)
28+
LDLIBS := $(shell pkg-config --libs hidapi-libusb)
1529
else
16-
LDLIBS = -lhidapi
30+
LDLIBS := -lhidapi
1731
endif
1832
endif
1933

20-
all: footswitch scythe scythe2
34+
all: $(OBJDIR) $(TARGETS)
35+
36+
$(OBJDIR):
37+
mkdir $@
38+
39+
$(OBJDIR)/%.o: $(SRCDIR)/%.c
40+
$(CC) $(CFLAGS) -c -o $@ $<
2141

22-
footswitch: footswitch.c common.c debug.c
23-
scythe: scythe.c common.c debug.c
24-
scythe2: scythe2.c common.c debug.c
42+
$(TARGETS): %: $(patsubst %.c, $(OBJDIR)/%.o, $(COMMONSRC)) $(OBJDIR)/%.o
43+
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS)
2544

2645
install: all
2746
$(INSTALL) -d $(DESTDIR)$(PREFIX)/bin
28-
$(INSTALL) footswitch $(DESTDIR)$(PREFIX)/bin
29-
$(INSTALL) scythe $(DESTDIR)$(PREFIX)/bin
30-
$(INSTALL) scythe2 $(DESTDIR)$(PREFIX)/bin
47+
for target in $(TARGETS); do \
48+
$(INSTALL) "$$target" $(DESTDIR)$(PREFIX)/bin; \
49+
done
3150
ifeq ($(UNAME), Linux)
3251
$(INSTALL) -d $(DESTDIR)$(UDEVPREFIX)/rules.d
3352
$(INSTALLDATA) 19-footswitch.rules $(DESTDIR)$(UDEVPREFIX)/rules.d
3453
endif
3554

3655
uninstall:
37-
rm -f $(DESTDIR)$(PREFIX)/bin/footswitch
38-
rm -f $(DESTDIR)$(PREFIX)/bin/scythe
39-
rm -f $(DESTDIR)$(PREFIX)/bin/scythe2
56+
rm -f $(addprefix $(DESTDIR)$(PREFIX)/bin/, $(TARGETS))
4057
ifeq ($(UNAME), Linux)
4158
rm -f $(DESTDIR)$(UDEVPREFIX)/rules.d/19-footswitch.rules
4259
endif
4360

4461
clean:
45-
rm -f scythe scythe2 footswitch *.o
62+
rm -rf $(TARGETS) $(OBJDIR)
4663

README.md

+19
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,25 @@ The same kind of foot switches are used for building the popular [VIM Clutch][2]
2424
Building
2525
--------
2626

27+
Debian
28+
------
29+
30+
On a debian machine, provided you have `devscripts` and `equivs` installed:
31+
32+
```bash
33+
mk-build-deps -i
34+
dpkg-buildpackage -us -uc -b
35+
```
36+
37+
Or, you can build the package in a Docker container:
38+
39+
```bash
40+
docker build .
41+
```
42+
43+
Other systems
44+
-------------
45+
2746
The programs are using the [hidapi][3] library and should work on Linux and OSX. To build on Linux:
2847

2948
sudo apt-get install libhidapi-dev

debian/changelog

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
footswitch-cli (1.0.0) stable; urgency=medium
2+
3+
* Initial release.
4+
5+
-- drlkf <drlkf@drlkf.net> Thu, 16 May 2024 19:27:47 +0200

debian/compat

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
11

debian/control

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Source: footswitch-cli
2+
Section: utils
3+
Priority: optional
4+
Maintainer: Radoslav Gerganov <rgerganov@gmail.com>
5+
Build-Depends:
6+
cmake,
7+
libhidapi-dev,
8+
pkg-config
9+
10+
Package: footswitch-cli
11+
Description: Command-line tools to configure PCsensor and Scythe foot switches.
12+
Architecture: any
13+
Depends:
14+
libhidapi-libusb0

debian/footswitch-cli.udev

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# PCsensor
2+
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7403", MODE="0666"
3+
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7404", MODE="0666"
4+
SUBSYSTEMS=="usb", ATTRS{idVendor}=="413d", ATTRS{idProduct}=="2107", MODE="0666"
5+
SUBSYSTEMS=="usb", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="e026", MODE="0666"
6+
SUBSYSTEMS=="usb", ATTRS{idVendor}=="3553", ATTRS{idProduct}=="b001", MODE="0666"
7+
8+
# Scythe
9+
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0426", ATTRS{idProduct}=="3011", MODE="0666"
10+
11+
# Scythe2
12+
SUBSYSTEMS=="usb", ATTRS{idVendor}=="055a", ATTRS{idProduct}=="0998", MODE="0666"

debian/rules

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/make -f
2+
3+
%:
4+
dh $@ --buildsystem=cmake

common.h include/common.h

File renamed without changes.

debug.h include/debug.h

File renamed without changes.

common.c src/common.c

File renamed without changes.

debug.c src/debug.c

File renamed without changes.

footswitch.c src/footswitch.c

File renamed without changes.

scythe.c src/scythe.c

File renamed without changes.

scythe2.c src/scythe2.c

File renamed without changes.

0 commit comments

Comments
 (0)