aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2021-09-16 18:49:42 +0200
committerMattias Andrée <maandree@kth.se>2021-09-16 18:49:42 +0200
commit195bfa0749997706198dc36e38614eb2693c17d9 (patch)
tree57af493b58900810fdee9378de8e92ac5b8b4629
parentUse simple make file, remove info manual, and other crap, change style, use arg.h instead of getopt, and change license (diff)
downloadunstickpixels-195bfa0749997706198dc36e38614eb2693c17d9.tar.gz
unstickpixels-195bfa0749997706198dc36e38614eb2693c17d9.tar.bz2
unstickpixels-195bfa0749997706198dc36e38614eb2693c17d9.tar.xz
Improve makefile + m style fix + fix warnings3.0.1
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r--Makefile14
-rw-r--r--config.mk6
-rw-r--r--unstickpixels.c45
3 files changed, 38 insertions, 27 deletions
diff --git a/Makefile b/Makefile
index 54a0a31..df9d73f 100644
--- a/Makefile
+++ b/Makefile
@@ -3,28 +3,28 @@
CONFIGFILE = config.mk
include $(CONFIGFILE)
+
all: unstickpixels
+unstickpixels.o: unstickpixels.c arg.h
-unstickpixels: unstickpixels.o
- $(CC) -o $@ unstickpixels.o $(LDFLAGS)
+.c.o:
+ $(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS)
-unstickpixels.o: unstickpixels.c arg.h
+.o:
+ $(CC) -o $@ $< $(LDFLAGS)
install: unstickpixels
mkdir -p -- "$(DESTDIR)$(PREFIX)/bin/"
mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man1/"
- mkdir -p -- "$(DESTDIR)$(PREFIX)/share/licenses/unstickpixels"
cp -- unstickpixels "$(DESTDIR)$(PREFIX)/bin/"
cp -- unstickpixels.1 "$(DESTDIR)$(MANPREFIX)/man1/"
- cp -- LICENSE "$(DESTDIR)$(PREFIX)/share/licenses/unstickpixels"
uninstall:
-rm -f -- "$(DESTDIR)$(PREFIX)/bin/unstickpixels"
-rm -f -- "$(DESTDIR)$(MANPREFIX)/man1/unstickpixels.1"
- -rm -rf -- "$(DESTDIR)$(PREFIX)/share/licenses/unstickpixels"
clean:
- -rm -f -- unstickpixels *.o
+ -rm -f -- unstickpixels *.o *.su
.SUFFIXES:
.SUFFIXES: .o .c
diff --git a/config.mk b/config.mk
index 060c337..71c611f 100644
--- a/config.mk
+++ b/config.mk
@@ -1,6 +1,8 @@
-PREFIX = /usr/local
+PREFIX = /usr
MANPREFIX = $(PREFIX)/share/man
+CC = cc
+
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700
-CFLAGS = -std=c99 -Wall -Wextra -O2 $(CPPFLAGS)
+CFLAGS = -std=c99 -Wall -O2
LDFLAGS = -s -lgamma
diff --git a/unstickpixels.c b/unstickpixels.c
index 699f0ac..e49af2a 100644
--- a/unstickpixels.c
+++ b/unstickpixels.c
@@ -164,7 +164,8 @@ usage(void)
*
* @return 0 on success, -1 on error.
*/
-static void term_clut()
+static void
+term_clut(void)
{
size_t i, j;
if (clut_state == 2)
@@ -178,15 +179,22 @@ static void term_clut()
libgamma_gamma_ramps16_free(ramps_blue[i]);
libgamma_gamma_ramps16_free(ramps_saved[i]);
}
- free((void *)crtcs);
- free((void *)ramps_red);
- free((void *)ramps_green);
- free((void *)ramps_blue);
- free((void *)ramps_saved);
+#if defined(__GNUC__)
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"
+#endif
+ free(crtcs);
+ free(ramps_red);
+ free(ramps_green);
+ free(ramps_blue);
+ free(ramps_saved);
for (i = 0; parts && parts[i]; i++)
libgamma_partition_free(parts[i]);
- free((void *)parts);
- free((void *)sitename);
+ free(parts);
+ free(sitename);
+#if defined(__GNUC__)
+# pragma GCC diagnostic pop
+#endif
if (clut_state)
libgamma_site_destroy(&site);
sitename = NULL;
@@ -202,7 +210,8 @@ static void term_clut()
*
* @return 0 on success, -1 on error.
*/
-static int init_clut()
+static int
+init_clut(void)
{
int method, error = 0;
size_t i, j, k, n = 0;
@@ -361,7 +370,7 @@ fail:
static void
sigexit(int signo)
{
- signal(signo, sigexit);
+ (void) signo;
please_exit = 1;
}
@@ -374,6 +383,7 @@ main(int argc, char *argv[])
struct timespec interval;
int status, vt = 0;
pid_t pid = -1;
+ struct sigaction sa;
int saved_errno;
ARGBEGIN {
@@ -394,14 +404,13 @@ main(int argc, char *argv[])
printf(WELCOME_MESSAGE);
fflush(stdout);
- siginterrupt(SIGHUP, 1);
- siginterrupt(SIGTERM, 1);
- siginterrupt(SIGINT, 1);
- siginterrupt(SIGQUIT, 1);
- signal(SIGHUP, sigexit);
- signal(SIGTERM, sigexit);
- signal(SIGINT, sigexit);
- signal(SIGQUIT, sigexit);
+ memset(&sa, 0, sizeof(sa));
+ sa.sa_handler = sigexit;
+ sa.sa_flags = SA_RESTART;
+ sigaction(SIGHUP, &sa, NULL);
+ sigaction(SIGTERM, &sa, NULL);
+ sigaction(SIGINT, &sa, NULL);
+ sigaction(SIGQUIT, &sa, NULL);
if (read(STDIN_FILENO, &started, 1) < 0)
goto done;