Add a config option to link against system or shipped strlcpy

This commit is contained in:
Quentin Rameau 2018-05-29 18:34:52 +02:00 committed by Hiltjo Posthuma
parent e32415744c
commit 51cb204eb2
3 changed files with 9 additions and 5 deletions

View File

@ -3,7 +3,7 @@
include config.mk include config.mk
SRC = ii.c strlcpy.c SRC = ii.c
OBJ = $(SRC:.c=.o) OBJ = $(SRC:.c=.o)
IICFLAGS = -DVERSION=\"$(VERSION)\" -D_DEFAULT_SOURCE $(CFLAGS) IICFLAGS = -DVERSION=\"$(VERSION)\" -D_DEFAULT_SOURCE $(CFLAGS)
@ -19,7 +19,7 @@ options:
.c.o: .c.o:
$(CC) $(IICFLAGS) -c $< $(CC) $(IICFLAGS) -c $<
ii: $(OBJ) ii: $(OBJ) $(LIBS)
$(CC) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) $(CC) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
$(OBJ): arg.h $(OBJ): arg.h

View File

@ -6,6 +6,9 @@ PREFIX = /usr/local
MANPREFIX = ${PREFIX}/share/man MANPREFIX = ${PREFIX}/share/man
DOCPREFIX = ${PREFIX}/share/doc 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 LDFLAGS = -s
LIBS = LIBS = strlcpy.o

3
ii.c
View File

@ -24,8 +24,9 @@ char *argv0;
#include "arg.h" #include "arg.h"
#undef strlcpy #ifdef NEED_STRLCPY
size_t strlcpy(char *, const char *, size_t); size_t strlcpy(char *, const char *, size_t);
#endif /* NEED_STRLCPY */
#define IRC_CHANNEL_MAX 200 #define IRC_CHANNEL_MAX 200
#define IRC_MSG_MAX 512 /* guaranteed to be <= than PIPE_BUF */ #define IRC_MSG_MAX 512 /* guaranteed to be <= than PIPE_BUF */