/[baselayout]/trunk/src/Makefile
Gentoo

Contents of /trunk/src/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2799 - (show annotations) (download)
Tue Jul 31 16:05:56 2007 UTC (7 years, 1 month ago) by uberlord
File size: 5421 byte(s)
    All our binaries are now mulicalls into rc, which makes our on disk size
    a lot smaller.
1 # Copyright 1999-2007 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 CC ?= gcc
5
6 CFLAGS ?= -Wall -O2 -pipe
7
8 check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
9 then echo "$(1)"; else echo "$(2)"; fi)
10
11 # Loads of nice flags to ensure our code is good
12 CFLAGS += -pedantic -std=c99 \
13 -Wall -Wunused -Wimplicit -Wshadow -Wformat=2 \
14 -Wmissing-declarations -Wno-missing-prototypes -Wwrite-strings \
15 -Wbad-function-cast -Wnested-externs -Wcomment -Winline \
16 -Wchar-subscripts -Wcast-align -Wno-format-nonliteral \
17 $(call check_gcc, -Wdeclaration-after-statement) \
18 $(call check_gcc, -Wsequence-point) \
19 $(call check_gcc, -Wextra)
20
21 # For debugging. -Werror is pointless due to ISO C issues with dlsym
22 #CFLAGS += -ggdb
23
24 DESTDIR =
25 LIB = lib
26
27 LIBEINFOSOVER = 0
28 LIBEINFOSO = libeinfo.so.$(LIBRCSOVER)
29 LIBEINFOOBJS= libeinfo.o
30
31 LIBRCSOVER = 0
32 LIBRCSO = librc.so.$(LIBRCSOVER)
33 LIBRCOBJS= librc.o librc-depend.o librc-daemon.o librc-misc.o librc-strlist.o \
34 env-update.o fstabinfo.o mountinfo.o \
35 rc-depend.o rc-status.o runscript.o start-stop-daemon.o
36
37 LIB_TARGETS = $(LIBEINFOSO) $(LIBRCSO)
38 SBIN_TARGETS = rc
39 SYS_WHITELIST = env_whitelist
40
41 TARGET = $(LIB_TARGETS) $(BIN_TARGETS) $(SBIN_TARGETS) $(PRIV_BIN_TARGETS)
42
43 RCLINKS = einfon einfo ewarnn ewarn eerrorn eerror ebegin eend ewend \
44 eindent eoutdent eval_ecolors \
45 veinfo vewarn vebegin veend vewend veindent veoutdent \
46 service_starting service_inactive service_started \
47 service_stopping service_stopped \
48 service_inactive service_wasinactive \
49 service_coldplugged \
50 mark_service_starting mark_service_inactive mark_service_started \
51 mark_service_stopping mark_service_stopped \
52 mark_service_inactive mark_service_wasinactive \
53 mark_service_coldplugged \
54 get_options save_options rc-abort rc-depend \
55 is_runlevel_start is_runlevel_stop service_started_daemon \
56 fstabinfo mountinfo
57 BINLINKS = rc-status
58 SBINLINKS = env-update rc-update runscript start-stop-daemon
59
60 # Quick hack to make my life easier on BSD and Linux
61 ifeq ($(OS),)
62 OS=$(shell uname -s)
63 ifneq ($(OS),Linux)
64 OS=BSD
65 endif
66 endif
67
68 ifeq ($(OS),Linux)
69 LDLIBS_RC = -ldl
70 LDLIBS_RS = -ldl
71 LDLIBS_SSD = -lrt
72 # Shouldn't need this, but it's the easiest workaround for silly
73 # Linux headers that don't work with -std=c99
74 override CPPFLAGS += -D_GNU_SOURCE
75 endif
76 ifeq ($(OS),BSD)
77 LDLIBS_LIBRC = -lkvm
78 endif
79
80 HAVE_PAM =
81 ifdef HAVE_PAM
82 CPPFLAGS_SSD = -DHAVE_PAM
83 LDLIBS_SSD += -lpam
84 endif
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 override CPPFLAGS += -DLIB=\"$(LIB)\"
89
90 # IMPORTANT!!!
91 # Remove this when releasing as it's a security risk
92 # However, this does save us using libtool when we're testing
93 # NOTE: The toplevel Makefile for baselayout will automatically
94 # disable then when doing `make dist`
95 ifneq ($(wildcard .svn),)
96 override LDFLAGS += -Wl,-rpath .
97 endif
98
99 all: $(TARGET)
100
101 $(LIBEINFOOBJS): CFLAGS += -fPIC
102 $(LIBEINFOSO): LDLIBS =
103 $(LIBEINFOSO): $(LIBEINFOOBJS)
104 $(CC) -fPIC -shared -Wl,-soname,$(LIBEINFOSO) -o $(LIBEINFOSO) $(LIBEINFOOBJS)
105 ln -sf $(LIBEINFOSO) libeinfo.so
106
107 $(LIBRCOBJS): CFLAGS += -fPIC
108 $(LIBRCSO): $(LIBRCOBJS)
109 $(CC) -fPIC -shared -Wl,-soname,$(LIBRCSO) -o $(LIBRCSO) $(LDLIBS_LIBRC) $(LIBRCOBJS)
110 ln -sf $(LIBRCSO) librc.so
111
112 env-update: $(LIBEINFOSO) $(LIBRCSO) env-update.o
113
114 fstabinfo: $(LIBEINFOSO) fstabinfo.o
115
116 mountinfo: $(LIBEINFOSO) $(LIBRCSO) mountinfo.o
117
118 rc-depend: $(LIBEINFOSO) $(LIBRCSO) rc-depend.o
119
120 rc-status: $(LIBEINFOSO) $(LIBRCSO) rc-status.o
121
122 rc-update: $(LIBEINFOSO) $(LIBRCSO) rc-update.o
123
124 rc: LDLIBS += $(LDLIBS_RC)
125 rc: $(LIBEINFOSO) $(LIBRCSO) rc-plugin.o rc.o
126
127 runscript: LDLIBS += $(LDLIBS_RS)
128 runscript: $(LIBEINFOSO) $(LIBRCSO) rc-plugin.o runscript.o
129
130 start-stop-daemon: CPPFLAGS += $(CPPFLAGS_SSD)
131 start-stop-daemon: LDLIBS += $(LDLIBS_SSD)
132 start-stop-daemon: $(LIBEINFOSO) $(LIBRCSO) start-stop-daemon.o
133
134 links: rc
135 for x in $(BINLINKS) $(SBINLINKS) $(RCLINKS) $(RCPRIVLINKS); do ln -sf rc $$x; done
136
137 install: $(TARGET)
138 install -m 0755 -d $(DESTDIR)/$(LIB)
139 install -m 0755 $(LIB_TARGETS) $(DESTDIR)/$(LIB)
140 ln -sf $(LIBEINFOSO) $(DESTDIR)/$(LIB)/libeinfo.so
141 ln -sf $(LIBRCSO) $(DESTDIR)/$(LIB)/librc.so
142 install -m 0755 -d $(DESTDIR)/usr/include
143 install -m 0644 einfo.h rc.h $(DESTDIR)/usr/include
144 install -m 0755 -d $(DESTDIR)/bin
145 install -m 0755 -d $(DESTDIR)/sbin
146 install -m 0755 $(SBIN_TARGETS) $(DESTDIR)/sbin
147 ln -sf rc-update $(DESTDIR)/sbin/update-rc
148 install -m 0755 -d $(DESTDIR)/$(LIB)/rcscripts/conf.d
149 install -m 0644 $(SYS_WHITELIST) $(DESTDIR)/$(LIB)/rcscripts/conf.d
150 install -m 0755 -d $(DESTDIR)/$(LIB)/rcscripts/bin
151 for x in $(BINLINKS); do ln -sf $(DESTDIR)/sbin/rc $(DESTDIR)/bin/$$x; done
152 for x in $(SBINLINKS); do ln -sf $(DESTDIR)/sbin/rc $(DESTDIR)/sbin/$$x; done
153 for x in $(RCLINKS); do ln -sf $(DESTDIR)/sbin/rc $(DESTDIR)/$(LIB)/rcscripts/bin/$$x; done
154 if test "$(HAVE_PAM)" != "" ; then \
155 install -m 0755 -d $(DESTDIR)/etc/pam.d ; \
156 install -m 0644 start-stop-daemon.pam $(DESTDIR)/etc/pam.d/start-stop-daemon ; \
157 fi
158
159 clean:
160 rm -f $(TARGET) $(BINLINKS) $(SBINLINKS) $(RCLINKS) $(RCPRIVLINKS)
161 rm -f *.o *~ *.core *.so .depend
162
163 -include .depend
164 .depend: $(wildcard *.c *.h)
165 $(CC) $(CPPFLAGS) -MM *.c > .depend
166
167 .PHONY: all clean install links

  ViewVC Help
Powered by ViewVC 1.1.20