/[baselayout]/trunk/src/Makefile
Gentoo

Contents of /trunk/src/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2874 - (show annotations) (download)
Mon Sep 10 21:26:13 2007 UTC (7 years, 7 months ago) by uberlord
File size: 5767 byte(s)
librc should link against libeinfo too
1 # Copyright 1999-2007 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 # We should strive to keep this Makefile working with the default make
5 # shipped with the OS's we support. Mainly because I'm lazy and just want
6 # to type make instead of gmake, but also so that other distros can pick
7 # it up and not rely on GNU Make.
8
9 # NOTE:- FreeBSD and DragonFly have no way of optionally including files
10 # that works with GNU make and vice versa. NetBSD and OpenBSD makes do.
11 # You can get a patch from
12 # http://www.freebsd.org/cgi/query-pr.cgi?pr=standards/116081
13 # to fix this. We include this patch with Gentoo/FreeBSD :)
14
15 CC ?= gcc
16 CFLAGS += -O2 -pipe
17
18 # GNU Make way of detecting gcc flags we can use
19 check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
20 then echo "$(1)"; else echo "$(2)"; fi)
21
22 # pmake check for extra cflags
23 WEXTRA != for x in -Wdeclaration-after-statement -Wsequence-point -Wextra; do \
24 if $(CC) -Wdeclaration-after-statement -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
25 then echo -n "$$x "; fi \
26 done
27
28 # Loads of nice flags to ensure our code is good
29 CFLAGS += -pedantic -std=c99 \
30 -Wall -Wunused -Wimplicit -Wshadow -Wformat=2 \
31 -Wmissing-declarations -Wno-missing-prototypes -Wwrite-strings \
32 -Wbad-function-cast -Wnested-externs -Wcomment -Winline \
33 -Wchar-subscripts -Wcast-align -Wno-format-nonliteral \
34 $(call check_gcc, -Wdeclaration-after-statement) \
35 $(call check_gcc, -Wsequence-point) \
36 $(call check_gcc, -Wextra) $(WEXTRA)
37
38 # For debugging. -Werror is pointless due to ISO C issues with dlsym
39 #CFLAGS += -ggdb
40
41 DESTDIR =
42 LIB = lib
43
44 # Set PAM = pam for pam support
45 PAM =
46
47 # Load an optional OS Makefile
48 _OS_SH = u=`uname -s`; case "$${u}" in *BSD|DragonFly) echo "BSD";; *) echo "$${u}";; esac
49 _OS != $(_OS_SH)
50 OS ?= $(_OS)$(shell $(_OS_SH))
51 -include Makefile.$(OS)
52 -include Makefile.$(PAM)
53
54 LIBEINFOSOVER = 0
55 LIBEINFOSO = libeinfo.so.$(LIBRCSOVER)
56 LIBEINFOOBJS= libeinfo.o
57
58 LIBRCSOVER = 0
59 LIBRCSO = librc.so.$(LIBRCSOVER)
60 LIBRCOBJS = librc.o librc-depend.o librc-daemon.o librc-misc.o librc-strlist.o
61 LDLIBS_LIBRC = $(LIBEINFOSO)
62
63 RCOBJS = env-update.o fstabinfo.o mountinfo.o \
64 rc-depend.o rc-plugin.o rc-status.o rc-update.o runscript.o \
65 start-stop-daemon.o rc.o
66
67 LIB_TARGETS = $(LIBEINFOSO) $(LIBRCSO)
68 SBIN_TARGETS = rc
69 SYS_WHITELIST = env_whitelist
70
71 TARGET = $(LIB_TARGETS) $(BIN_TARGETS) $(SBIN_TARGETS) $(PRIV_BIN_TARGETS)
72
73 RCLINKS = einfon einfo ewarnn ewarn eerrorn eerror ebegin eend ewend \
74 eindent eoutdent esyslog eval_ecolors \
75 veinfo vewarn vebegin veend vewend veindent veoutdent \
76 service_starting service_inactive service_started \
77 service_stopping service_stopped \
78 service_inactive service_wasinactive \
79 service_coldplugged \
80 mark_service_starting mark_service_inactive mark_service_started \
81 mark_service_stopping mark_service_stopped \
82 mark_service_inactive mark_service_wasinactive \
83 mark_service_coldplugged \
84 get_options save_options rc-abort rc-depend \
85 is_runlevel_start is_runlevel_stop service_started_daemon \
86 fstabinfo mountinfo
87 BINLINKS = rc-status
88 SBINLINKS = env-update rc-update runscript start-stop-daemon
89
90 # We also define _BSD_SOURCE so both Linux and the BSDs get a few
91 # handy functions which makes our lives a lot easier
92 CPPFLAGS += -DLIB=\"$(LIB)\"
93
94 # IMPORTANT!!!
95 # Ensure that we don't ship with a .svn directory to avoid RPATH security
96 # issues. However, this does ease development a little
97 _SVN_LDFLAGS_SH = if test -d .svn; then echo "-Wl,-rpath ."; else echo ""; fi
98 _SVN_LDFLAGS != $(_SVN_LDFLAGS_SH)
99 LDFLAGS += $(_SVN_LDFLAGS)$(shell $(_SVN_LDFLAGS_SH))
100
101 all: .depend $(TARGET)
102
103 $(LIBEINFOOBJS):
104 $(CC) $(CPPFLAGS) $(CFLAGS) -fPIC -c $<
105 $(LIBEINFOSO): $(LIBEINFOOBJS)
106 $(CC) $(LDFLAGS) -fPIC -shared -Wl,-soname,$(LIBEINFOSO) -o $(LIBEINFOSO) $(LIBEINFOOBJS)
107 ln -sf $(LIBEINFOSO) libeinfo.so
108
109 $(LIBRCOBJS):
110 $(CC) $(CPPFLAGS) $(CFLAGS) -fPIC -c $<
111 $(LIBRCSO): $(LIBRCOBJS) $(LIBEINFOSO)
112 $(CC) $(LDFLAGS) -fPIC -shared -Wl,-soname,$(LIBRCSO) -o $(LIBRCSO) $(LDLIBS_LIBRC) $(LIBRCOBJS)
113 ln -sf $(LIBRCSO) librc.so
114
115 $(RCOBJS):
116 $(CC) $(CPPFLAGS) $(CPPFLAGS_SSD) $(CFLAGS) -c $<
117 rc: $(LIBEINFOSO) $(LIBRCSO) $(RCOBJS)
118 $(CC) $(LDFLAGS) -o rc $(RCOBJS) $(LIBRCSO) $(LIBEINFOSO) $(LDLIBS_SSD) $(LDLIBS_RC)
119
120 links: rc
121 for x in $(BINLINKS) $(SBINLINKS) $(RCLINKS) $(RCPRIVLINKS); do ln -sf rc $$x; done
122
123 install: $(TARGET)
124 install -m 0755 -d $(DESTDIR)/$(LIB)
125 install -m 0755 $(LIB_TARGETS) $(DESTDIR)/$(LIB)
126 ln -sf $(LIBEINFOSO) $(DESTDIR)/$(LIB)/libeinfo.so
127 ln -sf $(LIBRCSO) $(DESTDIR)/$(LIB)/librc.so
128 install -m 0755 -d $(DESTDIR)/usr/include
129 install -m 0644 einfo.h rc.h $(DESTDIR)/usr/include
130 install -m 0755 -d $(DESTDIR)/bin
131 install -m 0755 -d $(DESTDIR)/sbin
132 install -m 0755 $(SBIN_TARGETS) $(DESTDIR)/sbin
133 ln -sf rc-update $(DESTDIR)/sbin/update-rc
134 install -m 0755 -d $(DESTDIR)/$(LIB)/rcscripts/conf.d
135 install -m 0644 $(SYS_WHITELIST) $(DESTDIR)/$(LIB)/rcscripts/conf.d
136 install -m 0755 -d $(DESTDIR)/$(LIB)/rcscripts/bin
137 for x in $(BINLINKS); do ln -sf ../sbin/rc $(DESTDIR)/bin/$$x; done
138 for x in $(SBINLINKS); do ln -sf rc $(DESTDIR)/sbin/$$x; done
139 for x in $(RCLINKS); do ln -sf ../../../sbin/rc $(DESTDIR)/$(LIB)/rcscripts/bin/$$x; done
140 if test "$(PAM)" != "pam" ; then \
141 install -m 0755 -d $(DESTDIR)/etc/pam.d ; \
142 install -m 0644 start-stop-daemon.pam $(DESTDIR)/etc/pam.d/start-stop-daemon ; \
143 fi
144
145 clean:
146 rm -f $(TARGET) $(BINLINKS) $(SBINLINKS) $(RCLINKS) $(RCPRIVLINKS)
147 rm -f *.o *~ *.core *.so .depend
148
149 -include .depend
150 _DEPS != ls *.c *.h
151 .depend: $(_DEPS)$(wildcard *.c *.h)
152 $(CC) $(CPPFLAGS) -MM *.c > .depend
153
154 .PHONY: all clean install links

  ViewVC Help
Powered by ViewVC 1.1.20