libbsd: Branch 'master' - 8 commits
Guillem Jover
guillem at kemper.freedesktop.org
Sun Jan 31 05:20:35 PST 2010
Makefile | 27 ++++++++++++++++++++-------
include/bsd/stdlib.h | 6 +++---
src/progname.c | 19 ++++++++++++++-----
3 files changed, 37 insertions(+), 15 deletions(-)
New commits:
commit 06a60a166ab19000b024dc1f70880278c09d8bc3
Author: Guillem Jover <guillem at hadrons.org>
Date: Sun Jan 31 14:13:24 2010 +0100
build: Use proper user variables during build
To compile we need to use CPPFLAGS and CFLAGS, to link CFLAGS and
LDFLAGS. Rename MK_CFLAGS to MK_CPPFLAGS as those are only relevant
at compilation time.
Reported-by: Eric Smith <eric at brouhaha.com>
diff --git a/Makefile b/Makefile
index e9dda45..da3780a 100644
--- a/Makefile
+++ b/Makefile
@@ -104,13 +104,18 @@ AR = ar
CC = gcc
CCLD = $(CC)
-# Set default value for compilation
+# Set default values for user variables
+CPPFLAGS ?=
CFLAGS ?= -g -Wall -Wextra -Wno-unused-variable
+LDFLAGS ?=
-MK_CFLAGS := -Iinclude/ -include bsd/bsd.h -D_GNU_SOURCE -D__REENTRANT
+# Internal makefile variables
+MK_CPPFLAGS := -Iinclude/ -include bsd/bsd.h -D_GNU_SOURCE -D__REENTRANT
+MK_CFLAGS :=
+MK_LDFLAGS :=
-COMPILE = $(CC) $(MK_CFLAGS) $(CFLAGS)
-LINK = $(CCLD)
+COMPILE = $(CC) $(MK_CPPFLAGS) $(CPPFLAGS) $(MK_CFLAGS) $(CFLAGS)
+LINK = $(CCLD) $(MK_CFLAGS) $(CFLAGS) $(MK_LDFLAGS) $(LDFLAGS)
prefix = /usr
exec_prefix =
commit 51863b6cf92883b6f2d58aa764b107e15d834b6f
Author: Guillem Jover <guillem at hadrons.org>
Date: Sat Jan 30 22:43:29 2010 +0100
build: Use new AR variable instead of hardcoded command
diff --git a/Makefile b/Makefile
index 4e1ac28..e9dda45 100644
--- a/Makefile
+++ b/Makefile
@@ -100,6 +100,7 @@ LIB_MANS := $(patsubst %,src/%,$(LIB_MANS))
LIB_STATIC_OBJS := $(LIB_SRCS:%.c=%.o)
LIB_SHARED_OBJS := $(LIB_SRCS:%.c=%.lo)
+AR = ar
CC = gcc
CCLD = $(CC)
@@ -146,7 +147,7 @@ $(LIB_PKGCONFIG): $(LIB_PKGCONFIG).in
$< > $@
$(LIB_STATIC): $(LIB_STATIC_OBJS)
- ar rcs $@ $^
+ $(AR) rcs $@ $^
$(LIB_SHARED_SO): $(LIB_SONAME)
ln -fs $^ $@
commit 08afd5d4c9a8579edabc5539e7404677a4f3df71
Author: Guillem Jover <guillem at hadrons.org>
Date: Sat Jan 30 22:42:00 2010 +0100
build: Refactor COMPILER and LINK commands into new variables
diff --git a/Makefile b/Makefile
index 5c5a690..4e1ac28 100644
--- a/Makefile
+++ b/Makefile
@@ -108,6 +108,9 @@ CFLAGS ?= -g -Wall -Wextra -Wno-unused-variable
MK_CFLAGS := -Iinclude/ -include bsd/bsd.h -D_GNU_SOURCE -D__REENTRANT
+COMPILE = $(CC) $(MK_CFLAGS) $(CFLAGS)
+LINK = $(CCLD)
+
prefix = /usr
exec_prefix =
libdir = ${exec_prefix}/lib
@@ -123,10 +126,10 @@ libs: $(LIB_STATIC) $(LIB_SHARED_SO) $(LIB_PKGCONFIG)
man: $(LIB_MANS)
%.lo: %.c
- $(CC) -o $@ $(MK_CFLAGS) $(CFLAGS) -DPIC -fPIC -c $<
+ $(COMPILE) -o $@ -DPIC -fPIC -c $<
%.o: %.c
- $(CC) -o $@ $(MK_CFLAGS) $(CFLAGS) -c $<
+ $(COMPILE) -o $@ -c $<
src/md5.3bsd: src/mdX.3
sed -e 's/mdX/md5/g' -e 's/mdY/md4/g' -e 's/MDX/MD5/g' $< > $@
@@ -152,7 +155,7 @@ $(LIB_SONAME): $(LIB_SHARED)
ln -fs $^ $@
$(LIB_SHARED): $(LIB_SHARED_OBJS)
- $(CCLD) \
+ $(LINK) \
-shared \
-Wl,-soname -Wl,$(LIB_SONAME) \
-Wl,--version-script=Versions \
commit 1f0b0b23cd0a215c575a4becf686e5e005732848
Author: Guillem Jover <guillem at hadrons.org>
Date: Sat Jan 30 22:40:01 2010 +0100
build: Use CCLD instead of hardcoded gcc for linking
diff --git a/Makefile b/Makefile
index 05f344d..5c5a690 100644
--- a/Makefile
+++ b/Makefile
@@ -101,6 +101,7 @@ LIB_STATIC_OBJS := $(LIB_SRCS:%.c=%.o)
LIB_SHARED_OBJS := $(LIB_SRCS:%.c=%.lo)
CC = gcc
+CCLD = $(CC)
# Set default value for compilation
CFLAGS ?= -g -Wall -Wextra -Wno-unused-variable
@@ -151,7 +152,8 @@ $(LIB_SONAME): $(LIB_SHARED)
ln -fs $^ $@
$(LIB_SHARED): $(LIB_SHARED_OBJS)
- gcc -shared \
+ $(CCLD) \
+ -shared \
-Wl,-soname -Wl,$(LIB_SONAME) \
-Wl,--version-script=Versions \
-o $@ $^
commit 32d79b0310b6602e4846a5972bebde6b169945f3
Author: Guillem Jover <guillem at hadrons.org>
Date: Sat Jan 30 22:39:18 2010 +0100
build: By default set CC to gcc
diff --git a/Makefile b/Makefile
index d63ac12..05f344d 100644
--- a/Makefile
+++ b/Makefile
@@ -100,6 +100,8 @@ LIB_MANS := $(patsubst %,src/%,$(LIB_MANS))
LIB_STATIC_OBJS := $(LIB_SRCS:%.c=%.o)
LIB_SHARED_OBJS := $(LIB_SRCS:%.c=%.lo)
+CC = gcc
+
# Set default value for compilation
CFLAGS ?= -g -Wall -Wextra -Wno-unused-variable
commit cd730a02c36397e4b962271fa6d9119dc820dd4d
Author: Eric Smith <eric at brouhaha.com>
Date: Sat Jan 30 22:13:18 2010 +0100
build: Install shared library with 755 permission
The Makefile should install the shared library with 755 permission
rather than 644. That's standard practice, and required when building
RPMs on Fedora to get a debuginfo package.
diff --git a/Makefile b/Makefile
index 258bb0c..d63ac12 100644
--- a/Makefile
+++ b/Makefile
@@ -177,7 +177,7 @@ install: libs man
mkdir -p $(DESTDIR)$(mandir)/man3
mkdir -p $(DESTDIR)$(pkgconfigdir)
install -m644 $(LIB_STATIC) $(DESTDIR)$(usrlibdir)
- install -m644 $(LIB_SHARED) $(DESTDIR)$(libdir)
+ install -m755 $(LIB_SHARED) $(DESTDIR)$(libdir)
for i in $(LIB_INCLUDES); do \
install -m644 include/$$i $(DESTDIR)$(includedir)/$$i; \
done
commit 11f2c32df2722a758f150fb3242d208904ffdacb
Author: Guillem Jover <guillem at hadrons.org>
Date: Sat Jan 30 22:00:18 2010 +0100
Fix setprogname to strip leading paths from progname
diff --git a/src/progname.c b/src/progname.c
index a5675c0..ef56144 100644
--- a/src/progname.c
+++ b/src/progname.c
@@ -29,6 +29,8 @@
Rejected in glibc (http://sourceware.org/ml/libc-alpha/2006-03/msg00125.html)
*/
+#include <string.h>
+
#include <bsd/stdlib.h>
static const char *__progname = NULL;
@@ -40,7 +42,13 @@ getprogname(void)
}
void
-setprogname(const char *new)
+setprogname(const char *progname)
{
- __progname = new;
+ const char *last_slash;
+
+ last_slash = strrchr(progname, '/');
+ if (last_slash == NULL)
+ __progname = progname;
+ else
+ __progname = last_slash + 1;
}
commit 30c794083f5211ecf82f5c3614f35a16a7e4d354
Author: Guillem Jover <guillem at hadrons.org>
Date: Thu Jan 21 14:34:55 2010 +0100
Make setprogname and getprogname arguments and return value const
This is more correct as the strings are not going to be changed, and it
matches the function signatures on other BSDs.
Suggested-by: Aurelien Jarno <aurel32 at debian.org>
diff --git a/include/bsd/stdlib.h b/include/bsd/stdlib.h
index cec5a28..6e7a88c 100644
--- a/include/bsd/stdlib.h
+++ b/include/bsd/stdlib.h
@@ -1,7 +1,7 @@
/*
* Copyright © 2005 Aurelien Jarno
* Copyright © 2006 Robert Millan
- * Copyright © 2008, 2009 Guillem Jover
+ * Copyright © 2008, 2009, 2010 Guillem Jover
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -48,8 +48,8 @@ void arc4random_addrandom(u_char *dat, int datlen);
int dehumanize_number(const char *str, int64_t *size);
-char *getprogname ();
-void setprogname (char *);
+const char *getprogname(void);
+void setprogname(const char *);
int heapsort (void *, size_t, size_t, int (*)(const void *, const void *));
diff --git a/src/progname.c b/src/progname.c
index 0a47c22..a5675c0 100644
--- a/src/progname.c
+++ b/src/progname.c
@@ -1,5 +1,6 @@
/*
* Copyright © 2006 Robert Millan
+ * Copyright © 2010 Guillem Jover
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,16 +31,16 @@
#include <bsd/stdlib.h>
-static char *__progname = NULL;
+static const char *__progname = NULL;
-char *
-getprogname()
+const char *
+getprogname(void)
{
return __progname;
}
void
-setprogname(char *new)
+setprogname(const char *new)
{
__progname = new;
}
More information about the libbsd
mailing list