/[baselayout]/trunk/src/Makefile
Gentoo

Contents of /trunk/src/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3007 - (show annotations) (download)
Mon Oct 8 11:07:39 2007 UTC (6 years, 11 months ago) by uberlord
File size: 6075 byte(s)
Move rc_env_filter and rc_env_config out of librc and into rc
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 LDFLAGS += -L.
18
19 # GNU Make way of detecting gcc flags we can use
20 check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
21 then echo "$(1)"; else echo "$(2)"; fi)
22
23 # pmake check for extra cflags
24 WEXTRA != for x in -Wdeclaration-after-statement -Wsequence-point -Wextra; do \
25 if $(CC) -Wdeclaration-after-statement -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
26 then echo -n "$$x "; fi \
27 done
28
29 # Loads of nice flags to ensure our code is good
30 CFLAGS += -pedantic -std=c99 \
31 -Wall -Wunused -Wimplicit -Wshadow -Wformat=2 \
32 -Wmissing-declarations -Wno-missing-prototypes -Wwrite-strings \
33 -Wbad-function-cast -Wnested-externs -Wcomment -Winline \
34 -Wchar-subscripts -Wcast-align -Wno-format-nonliteral \
35 $(call check_gcc, -Wdeclaration-after-statement) \
36 $(call check_gcc, -Wsequence-point) \
37 $(call check_gcc, -Wextra) $(WEXTRA)
38
39 # For debugging. -Werror is pointless due to ISO C issues with dlsym
40 #CFLAGS += -ggdb
41
42 DESTDIR =
43 LIB = lib
44 RC_LIB = /$(LIB)/rc
45
46 # Set PAM = pam for pam support
47 PAM =
48
49 LIBEINFOSOVER = 0
50 LIBEINFOSO = libeinfo.so.$(LIBRCSOVER)
51 LIBEINFOOBJS= libeinfo.o
52 LDLIBS_LIBEINFO = $(LDLIBS)
53
54 LIBRCSOVER = 0
55 LIBRCSO = librc.so.$(LIBRCSOVER)
56 LIBRCOBJS = librc.o librc-depend.o librc-daemon.o librc-misc.o librc-strlist.o
57 LDLIBS_LIBRC =
58
59 RCOBJS = checkown.o env-update.o fstabinfo.o mountinfo.o \
60 rc-depend.o rc-misc.o rc-plugin.o rc-status.o rc-update.o \
61 runscript.o start-stop-daemon.o rc.o
62 LDLIBS_RC = -leinfo -lrc -lutil
63
64 LIB_TARGETS = $(LIBEINFOSO) $(LIBRCSO)
65 SBIN_TARGETS = rc
66 SYS_WHITELIST = env_whitelist
67
68 TARGET = $(LIB_TARGETS) $(BIN_TARGETS) $(SBIN_TARGETS)
69
70 RC_BINLINKS = einfon einfo ewarnn ewarn eerrorn eerror ebegin eend ewend \
71 eindent eoutdent esyslog eval_ecolors \
72 veinfo vewarn vebegin veend vewend veindent veoutdent \
73 service_starting service_started \
74 service_stopping service_stopped \
75 service_inactive service_wasinactive \
76 service_coldplugged \
77 is_runlevel_start is_runlevel_stop service_started_daemon \
78 checkown fstabinfo mountinfo rc-depend \
79 get_options save_options
80 RC_SBINLINKS = mark_service_starting mark_service_started \
81 mark_service_stopping mark_service_stopped \
82 mark_service_inactive mark_service_wasinactive \
83 mark_service_coldplugged \
84 rc-abort
85 BINLINKS = rc-status
86 SBINLINKS = env-update rc-update runscript start-stop-daemon
87 ALL_LINKS = $(BINLINKS) $(SBINLINKS) $(RC_BINLINKS) $(RC_SBINLINKS)
88
89 # We also define _BSD_SOURCE so both Linux and the BSDs get a few
90 # handy functions which makes our lives a lot easier
91 CPPFLAGS += -DLIB=\"$(LIB)\"
92
93 # IMPORTANT!!!
94 # Ensure that we don't ship with a .svn directory to avoid RPATH security
95 # issues. However, this does ease development a little
96 _SVN_LDFLAGS_SH = if test -d .svn; then echo "-Wl,-rpath ."; else echo ""; fi
97 _SVN_LDFLAGS != $(_SVN_LDFLAGS_SH)
98 LDFLAGS += $(_SVN_LDFLAGS)$(shell $(_SVN_LDFLAGS_SH))
99
100 # Load an optional OS Makefile
101 _OS_SH = u=`uname -s`; case "$${u}" in *BSD|DragonFly) echo "BSD";; *) echo "$${u}";; esac
102 _OS != $(_OS_SH)
103 OS ?= $(_OS)$(shell $(_OS_SH))
104 -include Makefile.$(OS)
105 -include Makefile.$(PAM)
106
107 all: .depend $(TARGET)
108
109 $(LIBEINFOOBJS):
110 $(CC) $(CPPFLAGS) $(CFLAGS) -fPIC -c $<
111 $(LIBEINFOSO): einfo.map $(LIBEINFOOBJS)
112 $(CC) $(LDFLAGS) -fPIC -shared \
113 -Wl,-soname,$(LIBEINFOSO) \
114 -Wl,-version-script einfo.map \
115 -o $(LIBEINFOSO) $(LIBEINFOOBJS) $(LDLIBS) $(LDLIBS_LIBEINFO)
116 ln -sf $(LIBEINFOSO) libeinfo.so
117
118 $(LIBRCOBJS):
119 $(CC) $(CPPFLAGS) $(CFLAGS) -fPIC -c $<
120 $(LIBRCSO): rc.map $(LIBRCOBJS)
121 $(CC) $(LDFLAGS) -fPIC -shared \
122 -Wl,-soname,$(LIBRCSO) \
123 -Wl,-version-script rc.map \
124 -o $(LIBRCSO) $(LIBRCOBJS) $(LDLIBS) $(LDLIBS_LIBRC)
125 ln -sf $(LIBRCSO) librc.so
126
127 $(RCOBJS):
128 $(CC) $(CPPFLAGS) $(CPPFLAGS_SSD) $(CFLAGS) -c $<
129 rc: $(LIBEINFOSO) $(LIBRCSO) $(RCOBJS)
130 $(CC) $(LDFLAGS) -o rc $(RCOBJS) $(LDLIBS) $(LDLIBS_RC)
131
132 $(ALL_LINKS): rc
133 ln -sf rc $@
134 links: $(ALL_LINKS)
135
136 install: $(TARGET)
137 install -m 0755 -d $(DESTDIR)/$(LIB)
138 install -m 0755 $(LIB_TARGETS) $(DESTDIR)/$(LIB)
139 ln -sf $(LIBEINFOSO) $(DESTDIR)/$(LIB)/libeinfo.so
140 ln -sf $(LIBRCSO) $(DESTDIR)/$(LIB)/librc.so
141 install -m 0755 -d $(DESTDIR)/usr/include
142 install -m 0644 einfo.h rc.h $(DESTDIR)/usr/include
143 install -m 0755 -d $(DESTDIR)/bin
144 install -m 0755 -d $(DESTDIR)/sbin
145 install -m 0755 $(SBIN_TARGETS) $(DESTDIR)/sbin
146 ln -sf rc-update $(DESTDIR)/sbin/update-rc
147 install -m 0755 -d $(DESTDIR)/$(RC_LIB)/conf.d
148 install -m 0644 $(SYS_WHITELIST) $(DESTDIR)/$(RC_LIB)/conf.d
149 install -m 0755 -d $(DESTDIR)/$(RC_LIB)/bin
150 install -m 0755 -d $(DESTDIR)/$(RC_LIB)/sbin
151 for x in $(BINLINKS); do ln -sf ../sbin/rc $(DESTDIR)/bin/$$x; done
152 for x in $(SBINLINKS); do ln -sf rc $(DESTDIR)/sbin/$$x; done
153 for x in $(RC_BINLINKS); do ln -sf ../../../sbin/rc $(DESTDIR)/$(RC_LIB)/bin/$$x; done
154 for x in $(RC_SBINLINKS); do ln -sf ../../../sbin/rc $(DESTDIR)/$(RC_LIB)/sbin/$$x; done
155 if test "$(PAM)" = "pam" ; then \
156 install -m 0755 -d $(DESTDIR)/etc/pam.d ; \
157 install -m 0644 start-stop-daemon.pam $(DESTDIR)/etc/pam.d/start-stop-daemon ; \
158 fi
159
160 clean-links:
161 rm -f $(ALL_LINKS)
162 clean: clean-links
163 rm -f $(TARGET)
164 rm -f *.o *~ *.core *.so .depend
165
166 check:
167 $(MAKE) -C test $@
168
169 -include .depend
170 _DEPS != ls *.c *.h
171 .depend: $(_DEPS)$(wildcard *.c *.h)
172 $(CC) $(CPPFLAGS) -MM *.c > .depend
173
174 .PHONY: all clean clean-links install links

  ViewVC Help
Powered by ViewVC 1.1.20