Improve compiling for static binaries.
Have "#ifdef STATIC" in config.c, and the 'rmconf' target was a mess. Instead, create 'pwgr.c' with stub routines for those unavailable when statically compiled, and include that in STATICOBJ Signed-off-by: Neil Brown <neilb@suse.de>
This commit is contained in:
parent
0c239ef733
commit
c97be4db86
23
Makefile
23
Makefile
|
@ -51,7 +51,7 @@ endif
|
|||
SYSCONFDIR = /etc
|
||||
CONFFILE = $(SYSCONFDIR)/mdadm.conf
|
||||
MAILCMD =/usr/sbin/sendmail -t
|
||||
CFLAGS = $(CWFLAGS) $(STATIC) $(CPPFLAGS) -DCONFFILE=\"$(CONFFILE)\" $(CXFLAGS) -DSendmail=\""$(MAILCMD)"\"
|
||||
CFLAGS = $(CWFLAGS) $(CPPFLAGS) -DCONFFILE=\"$(CONFFILE)\" $(CXFLAGS) -DSendmail=\""$(MAILCMD)"\"
|
||||
|
||||
# If you want a static binary, you might uncomment these
|
||||
# LDFLAGS = -static
|
||||
|
@ -72,7 +72,8 @@ SRCS = mdadm.c config.c mdstat.c ReadMe.c util.c Manage.c Assemble.c Build.c \
|
|||
Create.c Detail.c Examine.c Grow.c Monitor.c dlink.c Kill.c Query.c \
|
||||
mdopen.c super0.c super1.c bitmap.c restripe.c sysfs.c
|
||||
|
||||
STATICOBJS = SHA1.o sha1.o
|
||||
STATICSRC = SHA1.c sha1.c pwgr.c
|
||||
STATICOBJS = SHA1.o sha1.o pwgr.o
|
||||
|
||||
ASSEMBLE_SRCS := mdassemble.c Assemble.c config.c dlink.c util.c super0.c super1.c
|
||||
ASSEMBLE_FLAGS:= $(CFLAGS) -DMDASSEMBLE
|
||||
|
@ -86,21 +87,17 @@ all : mdadm mdadm.man md.man mdadm.conf.man
|
|||
everything: all mdadm.static mdadm.uclibc swap_super test_stripe mdassemble mdassemble.uclibc mdassemble.static mdassemble.man
|
||||
# mdadm.tcc doesn't work..
|
||||
|
||||
mdadm : rmconf $(OBJS)
|
||||
mdadm : $(OBJS)
|
||||
$(CC) $(LDFLAGS) -o mdadm $(OBJS) $(LDLIBS)
|
||||
|
||||
mdadm.static : STATIC=-DSTATIC
|
||||
mdadm.static : rmconf $(OBJS) $(STATICOBJS)
|
||||
$(CC) $(LDFLAGS) -DSTATIC -static -o mdadm.static $(OBJS) $(STATICOBJS)
|
||||
|
||||
rmconf:
|
||||
rm -f config.o
|
||||
mdadm.static : $(OBJS) $(STATICOBJS)
|
||||
$(CC) $(LDFLAGS) -static -o mdadm.static $(OBJS) $(STATICOBJS)
|
||||
|
||||
mdadm.tcc : $(SRCS) mdadm.h
|
||||
$(TCC) -o mdadm.tcc $(SRCS)
|
||||
|
||||
mdadm.uclibc : $(SRCS) mdadm.h
|
||||
$(UCLIBC_GCC) -DUCLIBC -DHAVE_STDINT_H -o mdadm.uclibc $(SRCS) SHA1.c sha1.c
|
||||
$(UCLIBC_GCC) -DUCLIBC -DHAVE_STDINT_H -o mdadm.uclibc $(SRCS) $(STATICSRC)
|
||||
|
||||
mdadm.klibc : $(SRCS) mdadm.h
|
||||
rm -f $(OBJS)
|
||||
|
@ -111,15 +108,15 @@ test_stripe : restripe.c mdadm.h
|
|||
|
||||
mdassemble : $(ASSEMBLE_SRCS) mdadm.h
|
||||
rm -f $(OBJS)
|
||||
$(DIET_GCC) $(ASSEMBLE_FLAGS) -o mdassemble $(ASSEMBLE_SRCS) SHA1.c sha1.c
|
||||
$(DIET_GCC) $(ASSEMBLE_FLAGS) -o mdassemble $(ASSEMBLE_SRCS) $(STATICSRC)
|
||||
|
||||
mdassemble.static : $(ASSEMBLE_SRCS) mdadm.h
|
||||
rm -f $(OBJS)
|
||||
$(CC) $(LDFLAGS) $(ASSEMBLE_FLAGS) -static -DSTATIC -DHAVE_STDINT_H -o mdassemble.static $(ASSEMBLE_SRCS) SHA1.c sha1.c
|
||||
$(CC) $(LDFLAGS) $(ASSEMBLE_FLAGS) -static -DHAVE_STDINT_H -o mdassemble.static $(ASSEMBLE_SRCS) $(STATICSRC)
|
||||
|
||||
mdassemble.uclibc : $(ASSEMBLE_SRCS) mdadm.h
|
||||
rm -f $(OJS)
|
||||
$(UCLIBC_GCC) $(ASSEMBLE_FLAGS) -DSTATIC -DUCLIBC -DHAVE_STDINT_H -static -o mdassemble.uclibc $(ASSEMBLE_SRCS) SHA1.c sha1.c
|
||||
$(UCLIBC_GCC) $(ASSEMBLE_FLAGS) -DUCLIBC -DHAVE_STDINT_H -static -o mdassemble.uclibc $(ASSEMBLE_SRCS) $(STATICSRC)
|
||||
|
||||
# This doesn't work
|
||||
mdassemble.klibc : $(ASSEMBLE_SRCS) mdadm.h
|
||||
|
|
4
config.c
4
config.c
|
@ -320,14 +320,12 @@ static void createline(char *line)
|
|||
}
|
||||
createinfo.uid = strtoul(w+6, &ep, 10);
|
||||
if (*ep != 0) {
|
||||
#ifndef STATIC
|
||||
struct passwd *pw;
|
||||
/* must be a name */
|
||||
pw = getpwnam(w+6);
|
||||
if (pw)
|
||||
createinfo.uid = pw->pw_uid;
|
||||
else
|
||||
#endif /* STATIC */
|
||||
fprintf(stderr, Name ": CREATE user %s not found\n", w+6);
|
||||
}
|
||||
} else if (strncasecmp(w, "group=", 6) == 0) {
|
||||
|
@ -337,14 +335,12 @@ static void createline(char *line)
|
|||
}
|
||||
createinfo.gid = strtoul(w+6, &ep, 10);
|
||||
if (*ep != 0) {
|
||||
#ifndef STATIC
|
||||
struct group *gr;
|
||||
/* must be a name */
|
||||
gr = getgrnam(w+6);
|
||||
if (gr)
|
||||
createinfo.gid = gr->gr_gid;
|
||||
else
|
||||
#endif /* STATIC */
|
||||
fprintf(stderr, Name ": CREATE group %s not found\n", w+6);
|
||||
}
|
||||
} else if (strncasecmp(w, "mode=", 5) == 0) {
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
/*
|
||||
* We cannot link a static binary with passwd/group support, so
|
||||
* just do without
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
|
||||
struct passwd *getpwnam(const char *name)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
struct group *getgrnam(const char *name)
|
||||
{
|
||||
return NULL;
|
||||
}
|
Loading…
Reference in New Issue