Add a config option to link against system or shipped strlcpy - ii - irc it, si… | |
git clone git://git.suckless.org/ii | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 51cb204eb2a7ee840a86cc66b762ddfff56f01b2 | |
parent e32415744c0e7f2d75d4669addefc1b50f977cd6 | |
Author: Quentin Rameau <[email protected]> | |
Date: Tue, 29 May 2018 18:34:52 +0200 | |
Add a config option to link against system or shipped strlcpy | |
Diffstat: | |
M Makefile | 4 ++-- | |
M config.mk | 7 +++++-- | |
M ii.c | 3 ++- | |
3 files changed, 9 insertions(+), 5 deletions(-) | |
--- | |
diff --git 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 | |
@@ -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 | |
@@ -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 */ |