Skip to content

Commit

Permalink
Nix packaging.
Browse files Browse the repository at this point in the history
  • Loading branch information
vifino committed Nov 3, 2022
1 parent 930f49b commit 2a6c986
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ff-sort
*.png
*.jpg
result
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
CC ?= cc
CFLAGS ?= -Os
CPPFLAGS += -pedantic -Wall -Wextra
FARBHERD=1
FARBHERD=0

DESTDIR ?= /usr/local
PREFIX ?= /usr/local
DESTDIR ?= /

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

ff-sort: ff-sort.c
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $^
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $^ -lm

install: $(BINS)
install $(BINS) $(DESTDIR)/bin
install -d $(DESTDIR)/$(PREFIX)/bin
install $(BINS) $(DESTDIR)/$(PREFIX)/bin

clean:
rm -f $(BINS)
10 changes: 10 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
with import <nixpkgs> {};
stdenv.mkDerivation {
src = ./.;
name = "ff-sort";
enableParallelBuilding = true;

installPhase = ''
make install PREFIX=$out
'';
}
10 changes: 7 additions & 3 deletions ff-sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@
}

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

Expand Down Expand Up @@ -89,7 +94,6 @@ static int options;
#define SEL_X 0
#define SEL_Y 1

static int detection = 0;
#define SEL_BRUTE 0
#define SEL_EDGES 1 // soon.

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

// parse arguments
int opt;
while ((opt = getopt(argc, argv, "xyrhu:l:t:")) != -1) {
while ((opt = getopt(argc, argv, "xyrhu:l:")) != -1) {
switch (opt) {
case 'x':
options = SEL_X;
Expand Down

0 comments on commit 2a6c986

Please sign in to comment.