[hackers] [ii] Add a config option to link against system or shipped strlcpy || Quentin Rameau

From: <git@suckless.org>
Date: Sat Jun 02 2018 - 14:26:46 CEST

commit 51cb204eb2a7ee840a86cc66b762ddfff56f01b2
Author: Quentin Rameau <quinq@fifth.space>
AuthorDate: Tue May 29 18:34:52 2018 +0200
Commit: Hiltjo Posthuma <hiltjo@codemadness.org>
CommitDate: Sat Jun 2 14:25:28 2018 +0200

    Add a config option to link against system or shipped strlcpy

diff --git a/Makefile b/Makefile
index 3f9669f..21c0311 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@
 
 include config.mk
 
-SRC = ii.c strlcpy.c
+SRC = ii.c
 OBJ = $(SRC:.c=.o)
 
 IICFLAGS = -DVERSION=\"$(VERSION)\" -D_DEFAULT_SOURCE $(CFLAGS)
@@ -19,7 +19,7 @@ options:
 .c.o:
         $(CC) $(IICFLAGS) -c $<
 
-ii: $(OBJ)
+ii: $(OBJ) $(LIBS)
         $(CC) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
 
 $(OBJ): arg.h
diff --git a/config.mk b/config.mk
index 3b629db..957bae0 100644
--- a/config.mk
+++ b/config.mk
@@ -6,6 +6,9 @@ PREFIX = /usr/local
 MANPREFIX = ${PREFIX}/share/man
 DOCPREFIX = ${PREFIX}/share/doc
 
-CFLAGS = -Os
+# on systems which provide strlcpy(3),
+# remove NEED_STRLCPY from CFLAGS and
+# remove strlcpy.o from LIBS
+CFLAGS = -DNEED_STRLCPY -Os
 LDFLAGS = -s
-LIBS =
+LIBS = strlcpy.o
diff --git a/ii.c b/ii.c
index fc02d7f..53fa986 100644
--- a/ii.c
+++ b/ii.c
@@ -24,8 +24,9 @@ char *argv0;
 
 #include "arg.h"
 
-#undef strlcpy
+#ifdef NEED_STRLCPY
 size_t strlcpy(char *, const char *, size_t);
+#endif /* NEED_STRLCPY */
 
 #define IRC_CHANNEL_MAX 200
 #define IRC_MSG_MAX 512 /* guaranteed to be <= than PIPE_BUF */
Received on Sat, 2 Jun 2018 14:26:46 +0200 (CEST)

This archive was generated by hypermail 2.1.8 : Sat Jun 02 2018 - 14:36:19 CEST