/[baselayout]/trunk/src/Makefile
Gentoo

Contents of /trunk/src/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2876 - (show annotations) (download)
Tue Sep 11 22:06:27 2007 UTC (7 years ago) by uberlord
File size: 5847 byte(s)
More --as-needed foo
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
45 # Set PAM = pam for pam support
46 PAM =
47
48 LIBEINFOSOVER = 0
49 LIBEINFOSO = libeinfo.so.$(LIBRCSOVER)
50 LIBEINFOOBJS= libeinfo.o
51 LDLIBS_LIBEINFO = $(LDLIBS)
52
53 LIBRCSOVER = 0
54 LIBRCSO = librc.so.$(LIBRCSOVER)
55 LIBRCOBJS = librc.o librc-depend.o librc-daemon.o librc-misc.o librc-strlist.o
56 LDLIBS_LIBRC = -leinfo
57
58 RCOBJS = env-update.o fstabinfo.o mountinfo.o \
59 rc-depend.o rc-plugin.o rc-status.o rc-update.o runscript.o \
60 start-stop-daemon.o rc.o
61 LDLIBS_RC = $(LDLIBS_LIBRC) -lrc
62
63 LIB_TARGETS = $(LIBEINFOSO) $(LIBRCSO)
64 SBIN_TARGETS = rc
65 SYS_WHITELIST = env_whitelist
66
67 TARGET = $(LIB_TARGETS) $(BIN_TARGETS) $(SBIN_TARGETS) $(PRIV_BIN_TARGETS)
68
69 RCLINKS = einfon einfo ewarnn ewarn eerrorn eerror ebegin eend ewend \
70 eindent eoutdent esyslog eval_ecolors \
71 veinfo vewarn vebegin veend vewend veindent veoutdent \
72 service_starting service_inactive service_started \
73 service_stopping service_stopped \
74 service_inactive service_wasinactive \
75 service_coldplugged \
76 mark_service_starting mark_service_inactive mark_service_started \
77 mark_service_stopping mark_service_stopped \
78 mark_service_inactive mark_service_wasinactive \
79 mark_service_coldplugged \
80 get_options save_options rc-abort rc-depend \
81 is_runlevel_start is_runlevel_stop service_started_daemon \
82 fstabinfo mountinfo
83 BINLINKS = rc-status
84 SBINLINKS = env-update rc-update runscript start-stop-daemon
85
86 # We also define _BSD_SOURCE so both Linux and the BSDs get a few
87 # handy functions which makes our lives a lot easier
88 CPPFLAGS += -DLIB=\"$(LIB)\"
89
90 # IMPORTANT!!!
91 # Ensure that we don't ship with a .svn directory to avoid RPATH security
92 # issues. However, this does ease development a little
93 _SVN_LDFLAGS_SH = if test -d .svn; then echo "-Wl,-rpath ."; else echo ""; fi
94 _SVN_LDFLAGS != $(_SVN_LDFLAGS_SH)
95 LDFLAGS += $(_SVN_LDFLAGS)$(shell $(_SVN_LDFLAGS_SH))
96
97 # Load an optional OS Makefile
98 _OS_SH = u=`uname -s`; case "$${u}" in *BSD|DragonFly) echo "BSD";; *) echo "$${u}";; esac
99 _OS != $(_OS_SH)
100 OS ?= $(_OS)$(shell $(_OS_SH))
101 -include Makefile.$(OS)
102 -include Makefile.$(PAM)
103
104 all: .depend $(TARGET)
105
106 $(LIBEINFOOBJS):
107 $(CC) $(CPPFLAGS) $(CFLAGS) -fPIC -c $<
108 $(LIBEINFOSO): $(LIBEINFOOBJS)
109 $(CC) $(LDFLAGS) -fPIC -shared -Wl,-soname,$(LIBEINFOSO) -o $(LIBEINFOSO) $(LIBEINFOOBJS) $(LDLIBS) $(LDLIBS_LIBEINFO)
110 ln -sf $(LIBEINFOSO) libeinfo.so
111
112 $(LIBRCOBJS):
113 $(CC) $(CPPFLAGS) $(CFLAGS) -fPIC -c $<
114 $(LIBRCSO): $(LIBRCOBJS) $(LIBEINFOSO)
115 $(CC) $(LDFLAGS) -fPIC -shared -Wl,-soname,$(LIBRCSO) -o $(LIBRCSO) $(LIBRCOBJS) $(LDLIBS) $(LDLIBS_LIBRC)
116 ln -sf $(LIBRCSO) librc.so
117
118 $(RCOBJS):
119 $(CC) $(CPPFLAGS) $(CPPFLAGS_SSD) $(CFLAGS) -c $<
120 rc: $(LIBEINFOSO) $(LIBRCSO) $(RCOBJS)
121 $(CC) $(LDFLAGS) -o rc $(RCOBJS) $(LDLIBS) $(LDLIBS_RC)
122
123 links: rc
124 for x in $(BINLINKS) $(SBINLINKS) $(RCLINKS) $(RCPRIVLINKS); do ln -sf rc $$x; done
125
126 install: $(TARGET)
127 install -m 0755 -d $(DESTDIR)/$(LIB)
128 install -m 0755 $(LIB_TARGETS) $(DESTDIR)/$(LIB)
129 ln -sf $(LIBEINFOSO) $(DESTDIR)/$(LIB)/libeinfo.so
130 ln -sf $(LIBRCSO) $(DESTDIR)/$(LIB)/librc.so
131 install -m 0755 -d $(DESTDIR)/usr/include
132 install -m 0644 einfo.h rc.h $(DESTDIR)/usr/include
133 install -m 0755 -d $(DESTDIR)/bin
134 install -m 0755 -d $(DESTDIR)/sbin
135 install -m 0755 $(SBIN_TARGETS) $(DESTDIR)/sbin
136 ln -sf rc-update $(DESTDIR)/sbin/update-rc
137 install -m 0755 -d $(DESTDIR)/$(LIB)/rcscripts/conf.d
138 install -m 0644 $(SYS_WHITELIST) $(DESTDIR)/$(LIB)/rcscripts/conf.d
139 install -m 0755 -d $(DESTDIR)/$(LIB)/rcscripts/bin
140 for x in $(BINLINKS); do ln -sf ../sbin/rc $(DESTDIR)/bin/$$x; done
141 for x in $(SBINLINKS); do ln -sf rc $(DESTDIR)/sbin/$$x; done
142 for x in $(RCLINKS); do ln -sf ../../../sbin/rc $(DESTDIR)/$(LIB)/rcscripts/bin/$$x; done
143 if test "$(PAM)" != "pam" ; then \
144 install -m 0755 -d $(DESTDIR)/etc/pam.d ; \
145 install -m 0644 start-stop-daemon.pam $(DESTDIR)/etc/pam.d/start-stop-daemon ; \
146 fi
147
148 clean:
149 rm -f $(TARGET) $(BINLINKS) $(SBINLINKS) $(RCLINKS) $(RCPRIVLINKS)
150 rm -f *.o *~ *.core *.so .depend
151
152 -include .depend
153 _DEPS != ls *.c *.h
154 .depend: $(_DEPS)$(wildcard *.c *.h)
155 $(CC) $(CPPFLAGS) -MM *.c > .depend
156
157 .PHONY: all clean install links

  ViewVC Help
Powered by ViewVC 1.1.20