2008-01-04 16:36:58 +05:30
|
|
|
# Copyright 2007-2008 Roy Marples
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-09-06 18:30:03 +05:30
|
|
|
# We should strive to keep this Makefile working with the default make
|
|
|
|
# shipped with the OS's we support. Mainly because I'm lazy and just want
|
|
|
|
# to type make instead of gmake, but also so that other distros can pick
|
|
|
|
# it up and not rely on GNU Make.
|
|
|
|
|
|
|
|
CC ?= gcc
|
2008-01-04 21:06:56 +05:30
|
|
|
AR ?= ar
|
|
|
|
RANLIB ?= ranlib
|
2007-09-06 18:30:03 +05:30
|
|
|
CFLAGS += -O2 -pipe
|
2007-09-12 03:15:26 +05:30
|
|
|
LDFLAGS += -L.
|
2008-01-04 21:27:31 +05:30
|
|
|
PICFLAG = -fPIC
|
2007-04-08 23:09:59 +05:30
|
|
|
|
2007-09-06 18:30:03 +05:30
|
|
|
# GNU Make way of detecting gcc flags we can use
|
2007-04-20 18:42:21 +05:30
|
|
|
check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
|
|
|
|
then echo "$(1)"; else echo "$(2)"; fi)
|
|
|
|
|
2007-09-06 18:30:03 +05:30
|
|
|
# pmake check for extra cflags
|
|
|
|
WEXTRA != for x in -Wdeclaration-after-statement -Wsequence-point -Wextra; do \
|
2008-01-04 21:17:34 +05:30
|
|
|
if $(CC) $$x -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
|
2007-09-06 18:30:03 +05:30
|
|
|
then echo -n "$$x "; fi \
|
|
|
|
done
|
|
|
|
|
2007-04-08 23:09:59 +05:30
|
|
|
# Loads of nice flags to ensure our code is good
|
2007-07-31 22:29:02 +05:30
|
|
|
CFLAGS += -pedantic -std=c99 \
|
2007-04-05 17:12:21 +05:30
|
|
|
-Wall -Wunused -Wimplicit -Wshadow -Wformat=2 \
|
2007-04-05 16:48:42 +05:30
|
|
|
-Wmissing-declarations -Wno-missing-prototypes -Wwrite-strings \
|
|
|
|
-Wbad-function-cast -Wnested-externs -Wcomment -Winline \
|
2007-04-08 23:09:59 +05:30
|
|
|
-Wchar-subscripts -Wcast-align -Wno-format-nonliteral \
|
|
|
|
$(call check_gcc, -Wdeclaration-after-statement) \
|
|
|
|
$(call check_gcc, -Wsequence-point) \
|
2007-09-06 18:30:03 +05:30
|
|
|
$(call check_gcc, -Wextra) $(WEXTRA)
|
2007-04-05 16:48:42 +05:30
|
|
|
|
|
|
|
# For debugging. -Werror is pointless due to ISO C issues with dlsym
|
|
|
|
#CFLAGS += -ggdb
|
|
|
|
|
2007-09-06 18:30:03 +05:30
|
|
|
# Set PAM = pam for pam support
|
|
|
|
PAM =
|
|
|
|
|
2007-12-08 08:20:35 +05:30
|
|
|
# Set TERMCAP = termcap for termcap support
|
|
|
|
TERMCAP =
|
|
|
|
|
2007-10-11 20:35:02 +05:30
|
|
|
LIBEINFOSOVER = 1
|
2007-04-05 16:48:42 +05:30
|
|
|
LIBEINFOSO = libeinfo.so.$(LIBRCSOVER)
|
|
|
|
LIBEINFOOBJS= libeinfo.o
|
2007-12-08 08:20:35 +05:30
|
|
|
LDLIBS_LIBEINFO =
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-10-11 20:35:02 +05:30
|
|
|
LIBRCSOVER = 1
|
2007-04-05 16:48:42 +05:30
|
|
|
LIBRCSO = librc.so.$(LIBRCSOVER)
|
2007-07-31 21:46:18 +05:30
|
|
|
LIBRCOBJS = librc.o librc-depend.o librc-daemon.o librc-misc.o librc-strlist.o
|
2007-09-29 22:12:08 +05:30
|
|
|
LDLIBS_LIBRC =
|
2007-07-31 21:46:18 +05:30
|
|
|
|
2007-12-19 20:16:38 +05:30
|
|
|
RCOBJS = checkpath.o fstabinfo.o mountinfo.o \
|
2007-10-31 21:16:56 +05:30
|
|
|
rc-depend.o rc-logger.o rc-misc.o rc-plugin.o rc-status.o \
|
|
|
|
rc-update.o \
|
2007-10-08 16:37:39 +05:30
|
|
|
runscript.o start-stop-daemon.o rc.o
|
2007-10-05 17:34:19 +05:30
|
|
|
LDLIBS_RC = -leinfo -lrc -lutil
|
2007-04-05 16:48:42 +05:30
|
|
|
|
|
|
|
LIB_TARGETS = $(LIBEINFOSO) $(LIBRCSO)
|
2007-10-16 19:19:00 +05:30
|
|
|
ULIB_TARGETS = libeinfo.a librc.a
|
2007-07-31 21:35:56 +05:30
|
|
|
SBIN_TARGETS = rc
|
2007-04-05 16:48:42 +05:30
|
|
|
SYS_WHITELIST = env_whitelist
|
|
|
|
|
2008-01-04 21:27:31 +05:30
|
|
|
TARGET = $(LIB_TARGETS) $(ULIB_TARGETS) $(BIN_TARGETS) $(SBIN_TARGETS)
|
2007-09-24 17:39:43 +05:30
|
|
|
|
|
|
|
RC_BINLINKS = einfon einfo ewarnn ewarn eerrorn eerror ebegin eend ewend \
|
|
|
|
eindent eoutdent esyslog eval_ecolors \
|
|
|
|
veinfo vewarn vebegin veend vewend veindent veoutdent \
|
2007-09-28 03:44:23 +05:30
|
|
|
service_starting service_started \
|
2007-09-24 17:39:43 +05:30
|
|
|
service_stopping service_stopped \
|
|
|
|
service_inactive service_wasinactive \
|
2007-12-20 21:14:38 +05:30
|
|
|
service_coldplugged service_started_daemon \
|
2007-12-19 20:16:38 +05:30
|
|
|
checkpath fstabinfo mountinfo rc-depend \
|
2008-01-02 21:08:37 +05:30
|
|
|
service_get_value service_set_value get_options save_options \
|
|
|
|
shell_var
|
2007-09-28 03:44:23 +05:30
|
|
|
RC_SBINLINKS = mark_service_starting mark_service_started \
|
|
|
|
mark_service_stopping mark_service_stopped \
|
|
|
|
mark_service_inactive mark_service_wasinactive \
|
2007-10-10 02:43:08 +05:30
|
|
|
mark_service_coldplugged mark_service_failed \
|
2007-09-25 21:08:21 +05:30
|
|
|
rc-abort
|
2007-07-31 21:35:56 +05:30
|
|
|
BINLINKS = rc-status
|
2007-11-14 19:09:34 +05:30
|
|
|
SBINLINKS = rc-update runscript start-stop-daemon
|
2007-09-26 16:16:44 +05:30
|
|
|
ALL_LINKS = $(BINLINKS) $(SBINLINKS) $(RC_BINLINKS) $(RC_SBINLINKS)
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-09-06 18:30:03 +05:30
|
|
|
CPPFLAGS += -DLIB=\"$(LIB)\"
|
2007-04-05 16:48:42 +05:30
|
|
|
|
|
|
|
# IMPORTANT!!!
|
2007-09-06 18:30:03 +05:30
|
|
|
# Ensure that we don't ship with a .svn directory to avoid RPATH security
|
|
|
|
# issues. However, this does ease development a little
|
2007-11-14 21:49:56 +05:30
|
|
|
LDFLAGS += -Wl,-rpath .
|
2007-09-06 18:30:03 +05:30
|
|
|
|
2008-01-04 20:16:45 +05:30
|
|
|
# Load an optional Makefiles - the order is important
|
2007-11-19 19:18:43 +05:30
|
|
|
TOPDIR = ..
|
|
|
|
include $(TOPDIR)/default.mk
|
2007-12-08 08:20:35 +05:30
|
|
|
include Makefile.$(TERMCAP)
|
2008-01-04 20:16:45 +05:30
|
|
|
include Makefile.$(OS)
|
2008-01-04 20:49:04 +05:30
|
|
|
include Makefile.$(PAM)
|
2007-09-12 03:15:26 +05:30
|
|
|
|
2007-09-06 18:30:03 +05:30
|
|
|
all: .depend $(TARGET)
|
|
|
|
|
2007-11-19 22:12:28 +05:30
|
|
|
version.h:
|
|
|
|
sed -n -e 's/^VERSION =[[:space:]]*\([^[:space:]]*\).*/#define VERSION "\1\"/p' ../Makefile > version.h
|
2008-01-03 22:53:42 +05:30
|
|
|
if test -n "${BRANDING}"; then \
|
|
|
|
echo "#define BRANDING \"${BRANDING}\"" >> version.h; \
|
|
|
|
fi
|
2007-11-19 22:12:28 +05:30
|
|
|
|
2008-01-04 21:27:31 +05:30
|
|
|
.SUFFIXES: .lo
|
|
|
|
.c.lo:
|
|
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) $(PICFLAG) -c $< -o $@
|
|
|
|
.o.a:
|
|
|
|
$(AR) rc $@.tmp $^
|
|
|
|
$(RANLIB) $@.tmp
|
|
|
|
mv $@.tmp $@
|
|
|
|
|
|
|
|
LIBEINFOOBJS_SO = $(LIBEINFOOBJS:.o=.lo)
|
|
|
|
$(LIBEINFOOBJS): CPPFLAGS += $(CPPFLAGS_LIBEINFO)
|
|
|
|
$(LIBEINFOOBJS_SO): CPPFLAGS += $(CPPFLAGS_LIBEINFO)
|
|
|
|
$(LIBEINFOSO): einfo.map $(LIBEINFOOBJS_SO)
|
|
|
|
$(CC) $(LDFLAGS) $(PICFLAG) -shared \
|
2007-10-03 21:16:02 +05:30
|
|
|
-Wl,-soname,$(LIBEINFOSO) \
|
|
|
|
-Wl,-version-script einfo.map \
|
2008-01-04 21:27:31 +05:30
|
|
|
-o $(LIBEINFOSO) $(LIBEINFOOBJS_SO) $(LDLIBS_LIBEINFO)
|
2007-04-05 16:48:42 +05:30
|
|
|
ln -sf $(LIBEINFOSO) libeinfo.so
|
2008-01-04 21:27:31 +05:30
|
|
|
libeinfo.a: $(LIBEINFOOBJS)
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2008-01-04 21:27:31 +05:30
|
|
|
LIBRCOBJS_SO = $(LIBRCOBJS:.o=.lo)
|
|
|
|
$(LIBRCSO): rc.map $(LIBRCOBJS_SO)
|
|
|
|
$(CC) $(LDFLAGS) $(PICFLAG) -shared \
|
2007-10-03 21:16:02 +05:30
|
|
|
-Wl,-soname,$(LIBRCSO) \
|
|
|
|
-Wl,-version-script rc.map \
|
2008-01-04 21:27:31 +05:30
|
|
|
-o $(LIBRCSO) $(LIBRCOBJS_SO) $(LDLIBS_LIBRC)
|
2007-04-05 16:48:42 +05:30
|
|
|
ln -sf $(LIBRCSO) librc.so
|
2008-01-04 21:27:31 +05:30
|
|
|
librc.a: $(LIBRCOBJS)
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2008-01-04 21:27:31 +05:30
|
|
|
$(RCOBJS): version.h
|
|
|
|
$(RCOBJS): CPPFLAGS += $(CPPFLAGS_SSD)
|
|
|
|
rc: $(RCOBJS)
|
|
|
|
rc: LDLIBS += $(LDLIBS_RC) $(LIBEINFOSO) $(LIBRCSO)
|
|
|
|
rc: LDFLAGS += $(BIN_LDFLAGS)
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-09-25 07:12:24 +05:30
|
|
|
$(ALL_LINKS): rc
|
|
|
|
ln -sf rc $@
|
|
|
|
links: $(ALL_LINKS)
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-11-19 19:18:43 +05:30
|
|
|
install:: $(TARGET)
|
2007-11-23 20:12:19 +05:30
|
|
|
install -d $(DESTDIR)/$(LIB)
|
|
|
|
install -m 0444 $(LIB_TARGETS) $(DESTDIR)/$(LIB)
|
|
|
|
install -d $(DESTDIR)/usr/$(LIB)
|
|
|
|
install -m 0444 $(ULIB_TARGETS) $(DESTDIR)/usr/$(LIB)
|
2007-11-14 22:12:56 +05:30
|
|
|
ln -sf /$(LIB)/$(LIBEINFOSO) $(DESTDIR)/usr/$(LIB)/libeinfo.so
|
|
|
|
ln -sf /$(LIB)/$(LIBRCSO) $(DESTDIR)/usr/$(LIB)/librc.so
|
2007-11-23 20:12:19 +05:30
|
|
|
install -d $(DESTDIR)/usr/include
|
|
|
|
install -m 0444 einfo.h rc.h $(DESTDIR)/usr/include
|
|
|
|
install -d $(DESTDIR)/bin
|
|
|
|
install -d $(DESTDIR)/sbin
|
|
|
|
install -m 0555 $(SBIN_TARGETS) $(DESTDIR)/sbin
|
|
|
|
install -d $(DESTDIR)/$(RC_LIB)/conf.d
|
|
|
|
install -m 0444 $(SYS_WHITELIST) $(DESTDIR)/$(RC_LIB)/conf.d
|
|
|
|
install -d $(DESTDIR)/$(RC_LIB)/bin
|
|
|
|
install -d $(DESTDIR)/$(RC_LIB)/sbin
|
2007-12-28 20:51:59 +05:30
|
|
|
for x in $(BINLINKS); do ln -sf /sbin/rc $(DESTDIR)/bin/$$x; done
|
2007-08-02 16:39:09 +05:30
|
|
|
for x in $(SBINLINKS); do ln -sf rc $(DESTDIR)/sbin/$$x; done
|
2007-12-28 20:51:59 +05:30
|
|
|
for x in $(RC_BINLINKS); do ln -sf /sbin/rc $(DESTDIR)/$(RC_LIB)/bin/$$x; done
|
|
|
|
for x in $(RC_SBINLINKS); do ln -sf /sbin/rc $(DESTDIR)/$(RC_LIB)/sbin/$$x; done
|
2007-11-28 21:15:03 +05:30
|
|
|
if test "$(PAM)" = "pam"; then \
|
|
|
|
install -d $(DESTDIR)/etc/pam.d; \
|
|
|
|
install -m 0644 start-stop-daemon.pam $(DESTDIR)/etc/pam.d/start-stop-daemon; \
|
2007-04-05 16:48:42 +05:30
|
|
|
fi
|
|
|
|
|
2007-09-25 07:12:24 +05:30
|
|
|
clean-links:
|
|
|
|
rm -f $(ALL_LINKS)
|
2007-11-19 22:12:28 +05:30
|
|
|
clean:: clean-links
|
2007-11-15 20:55:51 +05:30
|
|
|
echo > .depend
|
|
|
|
touch -r Makefile .depend
|
2007-11-19 22:12:28 +05:30
|
|
|
rm -f $(TARGET) version.h
|
2008-01-04 21:27:31 +05:30
|
|
|
rm -f *.lo *.o *~ *.core *.so *.a
|
2007-04-13 18:50:26 +05:30
|
|
|
|
2007-09-26 14:14:39 +05:30
|
|
|
check:
|
|
|
|
$(MAKE) -C test $@
|
|
|
|
|
2007-11-15 20:55:51 +05:30
|
|
|
include .depend
|
2007-09-06 18:30:03 +05:30
|
|
|
_DEPS != ls *.c *.h
|
2007-11-19 22:12:28 +05:30
|
|
|
.depend: version.h $(_DEPS)$(wildcard *.c *.h)
|
2007-04-13 18:50:26 +05:30
|
|
|
$(CC) $(CPPFLAGS) -MM *.c > .depend
|
2008-01-02 22:32:33 +05:30
|
|
|
|
2008-01-02 22:58:35 +05:30
|
|
|
depend::
|
2008-01-02 22:37:44 +05:30
|
|
|
$(CC) $(CPPFLAGS) -MM *.c > .depend
|