Skip to content

Commit 2a6c986

Browse files
committed
Nix packaging.
1 parent 930f49b commit 2a6c986

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
ff-sort
22
*.png
33
*.jpg
4+
result

Makefile

+6-4
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
CC ?= cc
44
CFLAGS ?= -Os
55
CPPFLAGS += -pedantic -Wall -Wextra
6-
FARBHERD=1
6+
FARBHERD=0
77

8-
DESTDIR ?= /usr/local
8+
PREFIX ?= /usr/local
9+
DESTDIR ?= /
910

1011
# but not this..
1112
CPPFLAGS += -DFARBHERD=$(FARBHERD)
@@ -14,10 +15,11 @@ BINS=ff-sort
1415
all: $(BINS)
1516

1617
ff-sort: ff-sort.c
17-
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $^
18+
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $^ -lm
1819

1920
install: $(BINS)
20-
install $(BINS) $(DESTDIR)/bin
21+
install -d $(DESTDIR)/$(PREFIX)/bin
22+
install $(BINS) $(DESTDIR)/$(PREFIX)/bin
2123

2224
clean:
2325
rm -f $(BINS)

default.nix

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
with import <nixpkgs> {};
2+
stdenv.mkDerivation {
3+
src = ./.;
4+
name = "ff-sort";
5+
enableParallelBuilding = true;
6+
7+
installPhase = ''
8+
make install PREFIX=$out
9+
'';
10+
}

ff-sort.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@
3333
}
3434

3535
static void usage(char* self, int status) {
36-
eprintf("Usage: <farbfeld source> | %s [-x|-y] [-t type] [-l min] [-u max] [type] [args..] | <farbfeld sink>\n", self);
36+
eprintf(
37+
"Usage: <farbfeld source> | %s [-x|-y] [-l min] [-u max] type [args..] | <farbfeld sink>\n"
38+
"Type is one of:\n"
39+
"\tred/green/blue - color channel\n"
40+
"\tsum - sum of the above\n"
41+
"\thue/saturation/value - HSV\n", self);
3742
exit(status);
3843
}
3944

@@ -89,7 +94,6 @@ static int options;
8994
#define SEL_X 0
9095
#define SEL_Y 1
9196

92-
static int detection = 0;
9397
#define SEL_BRUTE 0
9498
#define SEL_EDGES 1 // soon.
9599

@@ -300,7 +304,7 @@ int main(int argc, char* argv[]) {
300304

301305
// parse arguments
302306
int opt;
303-
while ((opt = getopt(argc, argv, "xyrhu:l:t:")) != -1) {
307+
while ((opt = getopt(argc, argv, "xyrhu:l:")) != -1) {
304308
switch (opt) {
305309
case 'x':
306310
options = SEL_X;

0 commit comments

Comments
 (0)