diff Makefile @ 26:5bdea77d0c1d

Add pwm-clip utility for setting the X11 CLIPBOARD selection
author Guido Berhoerster <guido+pwm@berhoerster.name>
date Thu, 21 Sep 2017 09:45:59 +0200
parents 616385fa1fd9
children 722a45b4028b
line wrap: on
line diff
--- a/Makefile	Wed Sep 20 23:57:51 2017 +0200
+++ b/Makefile	Thu Sep 21 09:45:59 2017 +0200
@@ -83,6 +83,7 @@
   HAVE_ASPRINTF ?=	1
   HAVE_CLOSEFROM ?=	0
   HAVE_ERR_H ?=		1
+  HAVE_GETLINE ?=	0
   HAVE_GETRANDOM ?=	0
   HAVE_SYS_QUEUE_H ?=	0
   HAVE_SETPROGNAME ?=	0
@@ -92,6 +93,7 @@
   HAVE_ASPRINTF ?=	1
   HAVE_CLOSEFROM ?=	1
   HAVE_ERR_H ?=		1
+  HAVE_GETLINE ?=	1
   HAVE_GETRANDOM ?=	0
   HAVE_SYS_QUEUE_H ?=	1
   HAVE_SETPROGNAME ?=	1
@@ -101,6 +103,7 @@
   HAVE_ASPRINTF ?=	1
   HAVE_CLOSEFROM ?=	1
   HAVE_ERR_H ?=		1
+  HAVE_GETLINE ?=	1
   HAVE_GETRANDOM ?=	0
   HAVE_SYS_QUEUE_H ?=	1
   HAVE_SYS_TREE_H ?=	1
@@ -110,6 +113,7 @@
   HAVE_ASPRINTF ?=	1
   HAVE_CLOSEFROM ?=	1
   HAVE_ERR_H ?=		1
+  HAVE_GETLINE ?=	1
   HAVE_GETRANDOM ?=	0
   HAVE_SYS_QUEUE_H ?=	1
   HAVE_SYS_TREE_H ?=	1
@@ -119,11 +123,13 @@
     HAVE_ARC4RANDOM ?=	0
     HAVE_ASPRINTF ?=	0
     HAVE_ERR_H ?=	0
+    HAVE_GETLINE ?=	0
     HAVE_GETRANDOM ?=	0
   else
     HAVE_ARC4RANDOM ?=	1
     HAVE_ASPRINTF ?=	1
     HAVE_ERR_H ?=	1
+    HAVE_GETLINE ?=	1
     HAVE_GETRANDOM ?=	1
   endif
   HAVE_CLOSEFROM ?=	1
@@ -135,6 +141,7 @@
   HAVE_ASPRINTF ?=	0
   HAVE_CLOSEFROM ?=	0
   HAVE_ERR_H ?=		0
+  HAVE_GETLINE ?=	0
   HAVE_GETRANDOM ?=	0
   HAVE_SYS_QUEUE_H ?=	0
   HAVE_SETPROGNAME ?=	0
@@ -149,6 +156,10 @@
 LIBPWM_LIB =		libpwm.a
 LIBPWM_LIB_MEMBERS =	$(LIBPWM_OBJS:%.o=$(LIBPWM_LIB)(%.o))
 
+PWM_CLIP_OBJS =		pwm-clip.o
+PWM_CLIP_BIN =		pwm-clip
+PWM_CLIP_MAN1 =		pwm-clip.1
+
 PWM_OBJS =		cmd.o \
 			io.o \
 			pager.o \
@@ -158,20 +169,23 @@
 			pwm.o \
 			tok.o
 PWM_BIN =		$(PACKAGE)
+PWM_MAN1 =		pwm.1
 
-OBJS = $(LIBCOMPAT_OBJS) $(LIBPWM_OBJS) $(PWM_OBJS)
+OBJS = $(LIBCOMPAT_OBJS) $(LIBPWM_OBJS) $(PWM_CLIP_OBJS) $(PWM_OBJS)
 
-MANPAGES = pwm.1
+MANPAGES = $(PWM_MAN1) $(PWM_CLIP_MAN1)
 
 .DEFAULT_TARGET = all
 
 .PHONY: all clean clobber dist install
 
-all: $(PWM_BIN) $(MANPAGES)
+all: $(PWM_BIN) $(PWM_CLIP_BIN) $(MANPAGES)
 
 $(PWM_BIN): XCPPFLAGS += -DPACKAGE=\"$(PACKAGE)\" \
 			-DVERSION=\"$(VERSION)\"
 $(PWM_BIN): LDLIBS =	-ltecla -lcurses -lpws -lnettle
+$(PWM_CLIP_BIN): XCPPFLAGS += -Icompat/include
+$(PWM_CLIP_BIN): LDLIBS = -lnettle
 ifeq ($(HAVE_ASPRINTF),1)
   XCPPFLAGS +=		-DHAVE_ASPRINTF
 else
@@ -196,6 +210,11 @@
 else
   LIBCOMPAT_OBJS +=	compat/err.o
 endif
+ifeq ($(HAVE_GETLINE),1)
+  XCPPFLAGS +=		-DHAVE_GETLINE
+else
+  LIBCOMPAT_OBJS +=	compat/getline.o
+endif
 ifeq ($(HAVE_SETPROGNAME),1)
   XCPPFLAGS +=		-DHAVE_SETPROGNAME
 else
@@ -223,10 +242,15 @@
 
 $(LIBPWM_LIB): $(LIBPWM_LIB_MEMBERS)
 
+$(PWM_CLIP_BIN): $(PWM_CLIP_OBJS) $(LIBPWM_LIB) $(LIBCOMPAT_LIB)
+	$(LINK.o) $^ $(LDLIBS) -o $@
+
+$(eval $(call generate-manpage-rule,$(PWM_CLIP_MAN1)))
+
 $(PWM_BIN): $(PWM_OBJS) $(LIBPWM_LIB) $(LIBCOMPAT_LIB)
 	$(LINK.o) $^ $(LDLIBS) -o $@
 
-$(eval $(call generate-manpage-rule,$(MANPAGES)))
+$(eval $(call generate-manpage-rule,$(PWM_MAN1)))
 
 %.o: %.c
 	$(MAKEDEPEND.c) $< | $(SED) -f deps.sed >$*.d
@@ -238,6 +262,7 @@
 
 install: all
 	$(INSTALL.exec) $(PWM_BIN) "$(DESTDIR)$(bindir)/$(PWM_BIN)"
+	$(INSTALL.exec) $(PWM_CLIP_BIN) "$(DESTDIR)$(bindir)/$(PWM_CLIP_BIN)"
 	for manpage in $(MANPAGES); do \
 	    if [ -L $${manpage} ]; then \
 	        $(INSTALL.link) $${manpage} \
@@ -249,7 +274,8 @@
 	done
 
 clean:
-	rm -f $(LIBCOMPAT_LIB) $(LIBPWM_LIB) $(PWM_BIN) $(OBJS) $(MANPAGES)
+	rm -f $(LIBCOMPAT_LIB) $(LIBPWM_LIB) $(PWM_CLIP_BIN) $(PWM_BIN) \
+	    $(OBJS) $(MANPAGES)
 
 clobber: clean
 	rm -f $(patsubst %.o,%.d,$(OBJS))