2008-01-04 11:06:58 +00:00
|
|
|
# Copyright 2007-2008 Roy Marples
|
2007-04-05 11:18:42 +00:00
|
|
|
|
2007-09-06 13:00:03 +00:00
|
|
|
# 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 15:36:56 +00:00
|
|
|
AR ?= ar
|
|
|
|
RANLIB ?= ranlib
|
2007-09-06 13:00:03 +00:00
|
|
|
CFLAGS += -O2 -pipe
|
2007-09-11 21:45:26 +00:00
|
|
|
LDFLAGS += -L.
|
2007-04-08 17:39:59 +00:00
|
|
|
|
2007-09-06 13:00:03 +00:00
|
|
|
# GNU Make way of detecting gcc flags we can use
|
2007-04-20 13:12:21 +00:00
|
|
|
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 13:00:03 +00:00
|
|
|
# pmake check for extra cflags
|
|
|
|
WEXTRA != for x in -Wdeclaration-after-statement -Wsequence-point -Wextra; do \
|
2008-01-04 15:47:34 +00:00
|
|
|
if $(CC) $$x -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
|
2007-09-06 13:00:03 +00:00
|
|
|
then echo -n "$$x "; fi \
|
|
|
|
done
|
|
|
|
|
2007-04-08 17:39:59 +00:00
|
|
|
# Loads of nice flags to ensure our code is good
|
2007-07-31 16:59:02 +00:00
|
|
|
CFLAGS += -pedantic -std=c99 \
|
2007-04-05 11:42:21 +00:00
|
|
|
-Wall -Wunused -Wimplicit -Wshadow -Wformat=2 \
|
2007-04-05 11:18:42 +00:00
|
|
|
-Wmissing-declarations -Wno-missing-prototypes -Wwrite-strings \
|
|
|
|
-Wbad-function-cast -Wnested-externs -Wcomment -Winline \
|
2007-04-08 17:39:59 +00:00
|
|
|
-Wchar-subscripts -Wcast-align -Wno-format-nonliteral \
|
|
|
|
$(call check_gcc, -Wdeclaration-after-statement) \
|
|
|
|
$(call check_gcc, -Wsequence-point) \
|
2007-09-06 13:00:03 +00:00
|
|
|
$(call check_gcc, -Wextra) $(WEXTRA)
|
2007-04-05 11:18:42 +00:00
|
|
|
|
|
|
|
# For debugging. -Werror is pointless due to ISO C issues with dlsym
|
|
|
|
#CFLAGS += -ggdb
|
|
|
|
|
2007-09-06 13:00:03 +00:00
|
|
|
# Set PAM = pam for pam support
|
|
|
|
PAM =
|
|
|
|
|
2007-12-08 02:50:35 +00:00
|
|
|
# Set TERMCAP = termcap for termcap support
|
|
|
|
TERMCAP =
|
|
|
|
|
2007-10-11 15:05:02 +00:00
|
|
|
LIBEINFOSOVER = 1
|
2007-04-05 11:18:42 +00:00
|
|
|
LIBEINFOSO = libeinfo.so.$(LIBRCSOVER)
|
|
|
|
LIBEINFOOBJS= libeinfo.o
|
2007-12-08 02:50:35 +00:00
|
|
|
LDLIBS_LIBEINFO =
|
2007-04-05 11:18:42 +00:00
|
|
|
|
2007-10-11 15:05:02 +00:00
|
|
|
LIBRCSOVER = 1
|
2007-04-05 11:18:42 +00:00
|
|
|
LIBRCSO = librc.so.$(LIBRCSOVER)
|
2007-07-31 16:16:18 +00:00
|
|
|
LIBRCOBJS = librc.o librc-depend.o librc-daemon.o librc-misc.o librc-strlist.o
|
2007-09-29 16:42:08 +00:00
|
|
|
LDLIBS_LIBRC =
|
2007-07-31 16:16:18 +00:00
|
|
|
|
2007-12-19 14:46:38 +00:00
|
|
|
RCOBJS = checkpath.o fstabinfo.o mountinfo.o \
|
2007-10-31 15:46:56 +00:00
|
|
|
rc-depend.o rc-logger.o rc-misc.o rc-plugin.o rc-status.o \
|
|
|
|
rc-update.o \
|
2007-10-08 11:07:39 +00:00
|
|
|
runscript.o start-stop-daemon.o rc.o
|
2007-10-05 12:04:19 +00:00
|
|
|
LDLIBS_RC = -leinfo -lrc -lutil
|
2007-04-05 11:18:42 +00:00
|
|
|
|
|
|
|
LIB_TARGETS = $(LIBEINFOSO) $(LIBRCSO)
|
2007-10-16 13:49:00 +00:00
|
|
|
ULIB_TARGETS = libeinfo.a librc.a
|
2007-07-31 16:05:56 +00:00
|
|
|
SBIN_TARGETS = rc
|
2007-04-05 11:18:42 +00:00
|
|
|
SYS_WHITELIST = env_whitelist
|
|
|
|
|
2007-09-24 12:09:43 +00:00
|
|
|
TARGET = $(LIB_TARGETS) $(BIN_TARGETS) $(SBIN_TARGETS)
|
|
|
|
|
|
|
|
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-27 22:14:23 +00:00
|
|
|
service_starting service_started \
|
2007-09-24 12:09:43 +00:00
|
|
|
service_stopping service_stopped \
|
|
|
|
service_inactive service_wasinactive \
|
2007-12-20 15:44:38 +00:00
|
|
|
service_coldplugged service_started_daemon \
|
2007-12-19 14:46:38 +00:00
|
|
|
checkpath fstabinfo mountinfo rc-depend \
|
2008-01-02 15:38:37 +00:00
|
|
|
service_get_value service_set_value get_options save_options \
|
|
|
|
shell_var
|
2007-09-27 22:14:23 +00:00
|
|
|
RC_SBINLINKS = mark_service_starting mark_service_started \
|
|
|
|
mark_service_stopping mark_service_stopped \
|
|
|
|
mark_service_inactive mark_service_wasinactive \
|
2007-10-09 21:13:08 +00:00
|
|
|
mark_service_coldplugged mark_service_failed \
|
2007-09-25 15:38:21 +00:00
|
|
|
rc-abort
|
2007-07-31 16:05:56 +00:00
|
|
|
BINLINKS = rc-status
|
2007-11-14 13:39:34 +00:00
|
|
|
SBINLINKS = rc-update runscript start-stop-daemon
|
2007-09-26 10:46:44 +00:00
|
|
|
ALL_LINKS = $(BINLINKS) $(SBINLINKS) $(RC_BINLINKS) $(RC_SBINLINKS)
|
2007-04-05 11:18:42 +00:00
|
|
|
|
2007-09-06 13:00:03 +00:00
|
|
|
CPPFLAGS += -DLIB=\"$(LIB)\"
|
2007-04-05 11:18:42 +00:00
|
|
|
|
|
|
|
# IMPORTANT!!!
|
2007-09-06 13:00:03 +00:00
|
|
|
# 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 16:19:56 +00:00
|
|
|
LDFLAGS += -Wl,-rpath .
|
2007-09-06 13:00:03 +00:00
|
|
|
|
2008-01-04 14:46:45 +00:00
|
|
|
# Load an optional Makefiles - the order is important
|
2007-11-19 13:48:43 +00:00
|
|
|
TOPDIR = ..
|
|
|
|
include $(TOPDIR)/default.mk
|
2007-12-08 02:50:35 +00:00
|
|
|
include Makefile.$(TERMCAP)
|
2008-01-04 14:46:45 +00:00
|
|
|
include Makefile.$(OS)
|
2008-01-04 15:19:04 +00:00
|
|
|
include Makefile.$(PAM)
|
2007-09-11 21:45:26 +00:00
|
|
|
|
2007-09-06 13:00:03 +00:00
|
|
|
all: .depend $(TARGET)
|
|
|
|
|
2007-11-19 16:42:28 +00:00
|
|
|
version.h:
|
|
|
|
sed -n -e 's/^VERSION =[[:space:]]*\([^[:space:]]*\).*/#define VERSION "\1\"/p' ../Makefile > version.h
|
2008-01-03 17:23:42 +00:00
|
|
|
if test -n "${BRANDING}"; then \
|
|
|
|
echo "#define BRANDING \"${BRANDING}\"" >> version.h; \
|
|
|
|
fi
|
2007-11-19 16:42:28 +00:00
|
|
|
|
2007-09-06 13:00:03 +00:00
|
|
|
$(LIBEINFOOBJS):
|
2007-12-08 02:50:35 +00:00
|
|
|
$(CC) $(CPPFLAGS) $(CPPFLAGS_LIBEINFO) $(CFLAGS) -fPIC -c $<
|
2007-10-03 15:46:02 +00:00
|
|
|
$(LIBEINFOSO): einfo.map $(LIBEINFOOBJS)
|
|
|
|
$(CC) $(LDFLAGS) -fPIC -shared \
|
|
|
|
-Wl,-soname,$(LIBEINFOSO) \
|
|
|
|
-Wl,-version-script einfo.map \
|
2008-01-04 14:01:24 +00:00
|
|
|
-o $(LIBEINFOSO) $(LIBEINFOOBJS) $(LDLIBS_LIBEINFO)
|
2007-04-05 11:18:42 +00:00
|
|
|
ln -sf $(LIBEINFOSO) libeinfo.so
|
2008-01-04 15:36:56 +00:00
|
|
|
$(AR) rc libeinfo.a $(LIBEINFOOBJS)
|
|
|
|
$(RANLIB) libeinfo.a
|
2007-04-05 11:18:42 +00:00
|
|
|
|
2007-09-06 13:00:03 +00:00
|
|
|
$(LIBRCOBJS):
|
|
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) -fPIC -c $<
|
2007-10-03 15:46:02 +00:00
|
|
|
$(LIBRCSO): rc.map $(LIBRCOBJS)
|
|
|
|
$(CC) $(LDFLAGS) -fPIC -shared \
|
|
|
|
-Wl,-soname,$(LIBRCSO) \
|
|
|
|
-Wl,-version-script rc.map \
|
2008-01-04 14:01:24 +00:00
|
|
|
-o $(LIBRCSO) $(LIBRCOBJS) $(LDLIBS_LIBRC)
|
2007-04-05 11:18:42 +00:00
|
|
|
ln -sf $(LIBRCSO) librc.so
|
2008-01-04 15:36:56 +00:00
|
|
|
$(AR) rc librc.a $(LIBRCOBJS)
|
|
|
|
$(RANLIB) librc.a
|
2007-04-05 11:18:42 +00:00
|
|
|
|
2007-09-06 13:00:03 +00:00
|
|
|
$(RCOBJS):
|
|
|
|
$(CC) $(CPPFLAGS) $(CPPFLAGS_SSD) $(CFLAGS) -c $<
|
2007-11-19 18:36:10 +00:00
|
|
|
rc: version.h $(LIBEINFOSO) $(LIBRCSO) $(RCOBJS)
|
2008-01-04 15:19:04 +00:00
|
|
|
$(CC) $(LDFLAGS) $(BIN_LDFLAGS) -o rc $(RCOBJS) $(LDLIBS_RC)
|
2007-04-05 11:18:42 +00:00
|
|
|
|
2007-09-25 01:42:24 +00:00
|
|
|
$(ALL_LINKS): rc
|
|
|
|
ln -sf rc $@
|
|
|
|
links: $(ALL_LINKS)
|
2007-04-05 11:18:42 +00:00
|
|
|
|
2007-11-19 13:48:43 +00:00
|
|
|
install:: $(TARGET)
|
2007-11-23 14:42:19 +00:00
|
|
|
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 16:42:56 +00:00
|
|
|
ln -sf /$(LIB)/$(LIBEINFOSO) $(DESTDIR)/usr/$(LIB)/libeinfo.so
|
|
|
|
ln -sf /$(LIB)/$(LIBRCSO) $(DESTDIR)/usr/$(LIB)/librc.so
|
2007-11-23 14:42:19 +00:00
|
|
|
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 15:21:59 +00:00
|
|
|
for x in $(BINLINKS); do ln -sf /sbin/rc $(DESTDIR)/bin/$$x; done
|
2007-08-02 11:09:09 +00:00
|
|
|
for x in $(SBINLINKS); do ln -sf rc $(DESTDIR)/sbin/$$x; done
|
2007-12-28 15:21:59 +00:00
|
|
|
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 15:45:03 +00:00
|
|
|
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 11:18:42 +00:00
|
|
|
fi
|
|
|
|
|
2007-09-25 01:42:24 +00:00
|
|
|
clean-links:
|
|
|
|
rm -f $(ALL_LINKS)
|
2007-11-19 16:42:28 +00:00
|
|
|
clean:: clean-links
|
2007-11-15 15:25:51 +00:00
|
|
|
echo > .depend
|
|
|
|
touch -r Makefile .depend
|
2007-11-19 16:42:28 +00:00
|
|
|
rm -f $(TARGET) version.h
|
2007-11-15 15:25:51 +00:00
|
|
|
rm -f *.o *~ *.core *.so *.a
|
2007-04-13 13:20:26 +00:00
|
|
|
|
2007-09-26 08:44:39 +00:00
|
|
|
check:
|
|
|
|
$(MAKE) -C test $@
|
|
|
|
|
2007-11-15 15:25:51 +00:00
|
|
|
include .depend
|
2007-09-06 13:00:03 +00:00
|
|
|
_DEPS != ls *.c *.h
|
2007-11-19 16:42:28 +00:00
|
|
|
.depend: version.h $(_DEPS)$(wildcard *.c *.h)
|
2007-04-13 13:20:26 +00:00
|
|
|
$(CC) $(CPPFLAGS) -MM *.c > .depend
|
2008-01-02 17:02:33 +00:00
|
|
|
|
2008-01-02 17:28:35 +00:00
|
|
|
depend::
|
2008-01-02 17:07:44 +00:00
|
|
|
$(CC) $(CPPFLAGS) -MM *.c > .depend
|