From 51cb204eb2a7ee840a86cc66b762ddfff56f01b2 Mon Sep 17 00:00:00 2001 From: Quentin Rameau Date: Tue, 29 May 2018 18:34:52 +0200 Subject: [PATCH] Add a config option to link against system or shipped strlcpy --- Makefile | 4 ++-- config.mk | 7 +++++-- ii.c | 3 ++- 3 files changed, 9 insertions(+), 5 deletions(-) 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 */