From: Ben Harris Date: Sat, 24 Nov 2018 11:12:03 +0000 (+0000) Subject: Control libgpiod code with #ifdef. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=697f66aecc490df1e2d4f402f7a434ae30e79b49;p=clunk.git Control libgpiod code with #ifdef. That way I can build on older Linux systems. --- diff --git a/clunk.c b/clunk.c index 868a5c8..0637a71 100644 --- a/clunk.c +++ b/clunk.c @@ -3,7 +3,9 @@ #include #include #include +#ifdef WITH_LIBGPIOD #include +#endif /* WITH_LIBGPIOD */ #include #include #include @@ -64,6 +66,7 @@ dummy_out(bool state) } } +#ifdef WITH_LIBGPIOD static struct gpiod_line *libgpiod_line; static void @@ -73,6 +76,7 @@ libgpiod_out(bool state) if (gpiod_line_set_value(libgpiod_line, state) == -1) err(1, "gpiod_line_set_value"); } +#endif /* WITH_LIBGPIOD */ static void (*outfn)(bool) = &dummy_out; @@ -189,6 +193,7 @@ init_statefile(char const *statefilename) } } +#ifdef WITH_LIBGPIOD static void init_libgpiod(char const *gpio_name) { @@ -200,6 +205,7 @@ init_libgpiod(char const *gpio_name) err(1, "requesting '%s'", gpio_name); outfn = &libgpiod_out; } +#endif /* WITH_LIBGPIOD */ static void init(int argc, char **argv) @@ -226,7 +232,11 @@ init(int argc, char **argv) if (timer_create(CLOCK_REALTIME, &sev, &main_timer) != 0) err(1, "timer_create"); - while ((opt = getopt(argc, argv, "f:g:s:")) != -1) { + while ((opt = getopt(argc, argv, "f:s:" +#ifdef WITH_LIBGPIOD + "g:" +#endif /* WITH_LIBGPIOD */ + )) != -1) { switch (opt) { case 'f': statefile = optarg; @@ -234,9 +244,11 @@ init(int argc, char **argv) case 's': statestr = optarg; break; +#ifdef WITH_LIBGPIOD case 'g': init_libgpiod(optarg); break; +#endif /* WITH_LIBGPIOD */ } } if (statefile != NULL)