2007-04-05 16:48:42 +05:30
|
|
|
# Copyright 1999-2007 Gentoo Foundation
|
|
|
|
# Distributed under the terms of the GNU General Public License v2
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
# NOTE:- FreeBSD and DragonFly have no way of optionally including files
|
|
|
|
# that works with GNU make and vice versa. NetBSD and OpenBSD makes do.
|
|
|
|
# You can get a patch from
|
|
|
|
# http://www.freebsd.org/cgi/query-pr.cgi?pr=standards/116081
|
|
|
|
# to fix this. We include this patch with Gentoo/FreeBSD :)
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-09-06 18:30:03 +05:30
|
|
|
CC ?= gcc
|
|
|
|
CFLAGS += -O2 -pipe
|
2007-09-12 03:15:26 +05:30
|
|
|
LDFLAGS += -L.
|
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 \
|
|
|
|
if $(CC) -Wdeclaration-after-statement -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
|
|
|
|
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
|
|
|
|
|
|
|
|
DESTDIR =
|
|
|
|
LIB = lib
|
2007-09-19 19:23:40 +05:30
|
|
|
RC_LIB = /$(LIB)/rc
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-09-06 18:30:03 +05:30
|
|
|
# Set PAM = pam for pam support
|
|
|
|
PAM =
|
|
|
|
|
2007-04-05 16:48:42 +05:30
|
|
|
LIBEINFOSOVER = 0
|
|
|
|
LIBEINFOSO = libeinfo.so.$(LIBRCSOVER)
|
|
|
|
LIBEINFOOBJS= libeinfo.o
|
2007-09-12 03:36:27 +05:30
|
|
|
LDLIBS_LIBEINFO = $(LDLIBS)
|
2007-04-05 16:48:42 +05:30
|
|
|
|
|
|
|
LIBRCSOVER = 0
|
|
|
|
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-09-19 21:57:37 +05:30
|
|
|
RCOBJS = checkown.o env-update.o fstabinfo.o mountinfo.o \
|
2007-10-08 16:37:39 +05:30
|
|
|
rc-depend.o rc-misc.o rc-plugin.o rc-status.o rc-update.o \
|
|
|
|
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-07-31 21:35:56 +05:30
|
|
|
SBIN_TARGETS = rc
|
2007-04-05 16:48:42 +05:30
|
|
|
SYS_WHITELIST = env_whitelist
|
|
|
|
|
2007-09-24 17:39:43 +05:30
|
|
|
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-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 \
|
|
|
|
service_coldplugged \
|
|
|
|
is_runlevel_start is_runlevel_stop service_started_daemon \
|
2007-09-25 21:08:21 +05:30
|
|
|
checkown fstabinfo mountinfo rc-depend \
|
|
|
|
get_options save_options
|
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 \
|
|
|
|
mark_service_coldplugged \
|
2007-09-25 21:08:21 +05:30
|
|
|
rc-abort
|
2007-07-31 21:35:56 +05:30
|
|
|
BINLINKS = rc-status
|
|
|
|
SBINLINKS = env-update 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
|
|
|
|
|
|
|
# We also define _BSD_SOURCE so both Linux and the BSDs get a few
|
|
|
|
# handy functions which makes our lives a lot easier
|
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
|
|
|
|
_SVN_LDFLAGS_SH = if test -d .svn; then echo "-Wl,-rpath ."; else echo ""; fi
|
|
|
|
_SVN_LDFLAGS != $(_SVN_LDFLAGS_SH)
|
|
|
|
LDFLAGS += $(_SVN_LDFLAGS)$(shell $(_SVN_LDFLAGS_SH))
|
|
|
|
|
2007-09-12 03:15:26 +05:30
|
|
|
# Load an optional OS Makefile
|
|
|
|
_OS_SH = u=`uname -s`; case "$${u}" in *BSD|DragonFly) echo "BSD";; *) echo "$${u}";; esac
|
|
|
|
_OS != $(_OS_SH)
|
|
|
|
OS ?= $(_OS)$(shell $(_OS_SH))
|
|
|
|
-include Makefile.$(OS)
|
|
|
|
-include Makefile.$(PAM)
|
|
|
|
|
2007-09-06 18:30:03 +05:30
|
|
|
all: .depend $(TARGET)
|
|
|
|
|
|
|
|
$(LIBEINFOOBJS):
|
|
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) -fPIC -c $<
|
2007-10-03 21:16:02 +05:30
|
|
|
$(LIBEINFOSO): einfo.map $(LIBEINFOOBJS)
|
|
|
|
$(CC) $(LDFLAGS) -fPIC -shared \
|
|
|
|
-Wl,-soname,$(LIBEINFOSO) \
|
|
|
|
-Wl,-version-script einfo.map \
|
|
|
|
-o $(LIBEINFOSO) $(LIBEINFOOBJS) $(LDLIBS) $(LDLIBS_LIBEINFO)
|
2007-04-05 16:48:42 +05:30
|
|
|
ln -sf $(LIBEINFOSO) libeinfo.so
|
|
|
|
|
2007-09-06 18:30:03 +05:30
|
|
|
$(LIBRCOBJS):
|
|
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) -fPIC -c $<
|
2007-10-03 21:16:02 +05:30
|
|
|
$(LIBRCSO): rc.map $(LIBRCOBJS)
|
|
|
|
$(CC) $(LDFLAGS) -fPIC -shared \
|
|
|
|
-Wl,-soname,$(LIBRCSO) \
|
|
|
|
-Wl,-version-script rc.map \
|
|
|
|
-o $(LIBRCSO) $(LIBRCOBJS) $(LDLIBS) $(LDLIBS_LIBRC)
|
2007-04-05 16:48:42 +05:30
|
|
|
ln -sf $(LIBRCSO) librc.so
|
|
|
|
|
2007-09-06 18:30:03 +05:30
|
|
|
$(RCOBJS):
|
|
|
|
$(CC) $(CPPFLAGS) $(CPPFLAGS_SSD) $(CFLAGS) -c $<
|
|
|
|
rc: $(LIBEINFOSO) $(LIBRCSO) $(RCOBJS)
|
2007-09-12 03:36:27 +05:30
|
|
|
$(CC) $(LDFLAGS) -o rc $(RCOBJS) $(LDLIBS) $(LDLIBS_RC)
|
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
|
|
|
|
|
|
|
install: $(TARGET)
|
|
|
|
install -m 0755 -d $(DESTDIR)/$(LIB)
|
|
|
|
install -m 0755 $(LIB_TARGETS) $(DESTDIR)/$(LIB)
|
2007-04-13 18:29:12 +05:30
|
|
|
ln -sf $(LIBEINFOSO) $(DESTDIR)/$(LIB)/libeinfo.so
|
|
|
|
ln -sf $(LIBRCSO) $(DESTDIR)/$(LIB)/librc.so
|
2007-04-05 16:48:42 +05:30
|
|
|
install -m 0755 -d $(DESTDIR)/usr/include
|
|
|
|
install -m 0644 einfo.h rc.h $(DESTDIR)/usr/include
|
|
|
|
install -m 0755 -d $(DESTDIR)/bin
|
|
|
|
install -m 0755 -d $(DESTDIR)/sbin
|
|
|
|
install -m 0755 $(SBIN_TARGETS) $(DESTDIR)/sbin
|
2007-04-13 18:09:14 +05:30
|
|
|
ln -sf rc-update $(DESTDIR)/sbin/update-rc
|
2007-09-19 19:23:40 +05:30
|
|
|
install -m 0755 -d $(DESTDIR)/$(RC_LIB)/conf.d
|
|
|
|
install -m 0644 $(SYS_WHITELIST) $(DESTDIR)/$(RC_LIB)/conf.d
|
|
|
|
install -m 0755 -d $(DESTDIR)/$(RC_LIB)/bin
|
2007-09-24 17:39:43 +05:30
|
|
|
install -m 0755 -d $(DESTDIR)/$(RC_LIB)/sbin
|
2007-08-02 16:39:09 +05:30
|
|
|
for x in $(BINLINKS); do ln -sf ../sbin/rc $(DESTDIR)/bin/$$x; done
|
|
|
|
for x in $(SBINLINKS); do ln -sf rc $(DESTDIR)/sbin/$$x; done
|
2007-09-24 17:39:43 +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-09-19 19:23:40 +05:30
|
|
|
if test "$(PAM)" = "pam" ; then \
|
2007-04-05 16:48:42 +05:30
|
|
|
install -m 0755 -d $(DESTDIR)/etc/pam.d ; \
|
|
|
|
install -m 0644 start-stop-daemon.pam $(DESTDIR)/etc/pam.d/start-stop-daemon ; \
|
|
|
|
fi
|
|
|
|
|
2007-09-25 07:12:24 +05:30
|
|
|
clean-links:
|
|
|
|
rm -f $(ALL_LINKS)
|
|
|
|
clean: clean-links
|
|
|
|
rm -f $(TARGET)
|
2007-04-13 20:53:03 +05:30
|
|
|
rm -f *.o *~ *.core *.so .depend
|
2007-04-13 18:50:26 +05:30
|
|
|
|
2007-09-26 14:14:39 +05:30
|
|
|
check:
|
|
|
|
$(MAKE) -C test $@
|
|
|
|
|
2007-04-13 18:50:26 +05:30
|
|
|
-include .depend
|
2007-09-06 18:30:03 +05:30
|
|
|
_DEPS != ls *.c *.h
|
|
|
|
.depend: $(_DEPS)$(wildcard *.c *.h)
|
2007-04-13 18:50:26 +05:30
|
|
|
$(CC) $(CPPFLAGS) -MM *.c > .depend
|
|
|
|
|
2007-09-25 07:12:24 +05:30
|
|
|
.PHONY: all clean clean-links install links
|