/[baselayout]/trunk/src/Makefile
Gentoo

Contents of /trunk/src/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2550 - (show annotations) (download)
Fri Apr 6 01:04:07 2007 UTC (7 years, 5 months ago) by uberlord
File size: 4950 byte(s)
Misc fixes, plugged a memory leak in runscript.c and use va_copy to avoid nasty segfaults
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 CFLAGS += -pedantic -std=c99 \
8 -Wall -Wunused -Wimplicit -Wshadow -Wformat=2 \
9 -Wmissing-declarations -Wno-missing-prototypes -Wwrite-strings \
10 -Wbad-function-cast -Wnested-externs -Wcomment -Winline \
11 -Wchar-subscripts -Wcast-align -Wno-format-nonliteral
12
13 # Early GCC versions don't support these flags, so you may need to comment
14 # this line out
15 CFLAGS += -Wsequence-point -Wextra -Wdeclaration-after-statement
16
17 # For debugging. -Werror is pointless due to ISO C issues with dlsym
18 #CFLAGS += -ggdb
19
20 DESTDIR =
21 LIB = lib
22
23 LIBEINFOSOVER = 0
24 LIBEINFOSO = libeinfo.so.$(LIBRCSOVER)
25 LIBEINFOOBJS= libeinfo.o
26
27 LIBRCSOVER = 0
28 LIBRCSO = librc.so.$(LIBRCSOVER)
29 LIBRCOBJS= librc.o librc-depend.o librc-daemon.o librc-misc.o librc-strlist.o
30
31 LIB_TARGETS = $(LIBEINFOSO) $(LIBRCSO)
32 BIN_TARGETS = rc-status
33 SBIN_TARGETS = rc rc-update runscript start-stop-daemon
34 PRIV_BIN_TARGETS = env-update fstabinfo mountinfo rc-depend
35 SYS_WHITELIST = env_whitelist
36
37 TARGET = $(LIB_TARGETS) $(BIN_TARGETS) $(SBIN_TARGETS) $(PRIV_BIN_TARGETS)
38
39 RCLINKS = einfon einfo ewarnn ewarn eerrorn eerror ebegin eend ewend \
40 eindent eoutdent eflush color_terminal \
41 veinfo vewarn vebegin veend vewend veindent veoutdent \
42 service_starting service_inactive service_started \
43 service_stopping service_stopped \
44 service_inactive service_wasinactive \
45 service_coldplugged \
46 mark_service_starting mark_service_inactive mark_service_started \
47 mark_service_stopping mark_service_stopped \
48 mark_service_inactive mark_service_wasinactive \
49 mark_service_coldplugged \
50 get_options save_options \
51 is_runlevel_start is_runlevel_stop service_started_daemon
52
53 # Quick hack to make my life easier on BSD and Linux
54 ifeq ($(OS),)
55 OS=$(shell uname -s)
56 ifneq ($(OS),Linux)
57 OS=BSD
58 endif
59 endif
60
61 ifeq ($(OS),Linux)
62 LDLIBS_RC = -ldl
63 LDLIBS_RS = -ldl
64 # Shouldn't need this, but it's the easiest workaround for silly
65 # Linux headers that don't work with -std=c99
66 override CFLAGS += -D_GNU_SOURCE
67 endif
68 ifeq ($(OS),BSD)
69 override LDLIBS += -lkvm
70 endif
71
72 HAVE_PAM =
73 ifdef HAVE_PAM
74 CFLAGS_SSD = -DHAVE_PAM
75 LDLIBS_SSD = -lpam
76 endif
77
78 # We also define _BSD_SOURCE so both Linux and the BSDs get a few
79 # handy functions which makes our lives a lot easier
80 override CFLAGS += -DLIBDIR=\"$(LIB)\"
81
82 # IMPORTANT!!!
83 # Remove this when releasing as it's a security risk
84 # However, this does save us using libtool when we're testing
85 # NOTE: The toplevel Makefile for baselayout will automatically
86 # disable then when doing `make dist`
87 ##override LDFLAGS += -Wl,-rpath .
88
89 all: $(TARGET)
90
91 $(LIBEINFOOBJS): CFLAGS += -fPIC
92 $(LIBEINFOSO): LDLIBS =
93 $(LIBEINFOSO): $(LIBEINFOOBJS)
94 $(CC) -fPIC -shared -Wl,-soname,$(LIBEINFOSO) -o $(LIBEINFOSO) $(LIBEINFOOBJS)
95 ln -sf $(LIBEINFOSO) libeinfo.so
96
97 $(LIBRCOBJS): CFLAGS += -fPIC
98 $(LIBRCSO): $(LIBRCOBJS)
99 $(CC) -fPIC -shared -Wl,-soname,$(LIBRCSO) -o $(LIBRCSO) $(LIBRCOBJS)
100 ln -sf $(LIBRCSO) librc.so
101
102 splash: CFLAGS += -fPIC
103 splash: splash.o
104 $(CC) -fPIC -shared -Wl,-soname,splash.so -o splash.so splash.o
105
106 env-update: $(LIBEINFOSO) $(LIBRCSO) env-update.o
107
108 fstabinfo: $(LIBEINFOSO) fstabinfo.o
109
110 mountinfo: $(LIBEINFOSO) $(LIBRCSO) mountinfo.o
111
112 rc-depend: $(LIBEINFOSO) $(LIBRCSO) rc-depend.o
113
114 rc-status: $(LIBEINFOSO) $(LIBRCSO) rc-status.o
115
116 rc-update: $(LIBEINFOSO) $(LIBRCSO) rc-update.o
117
118 rc: LDLIBS += $(LDLIBS_RC)
119 rc: $(LIBEINFOSO) $(LIBRCSO) rc-plugin.o rc.o
120
121 runscript: LDLIBS += $(LDLIBS_RS)
122 runscript: $(LIBEINFOSO) $(LIBRCSO) rc-plugin.o runscript.o
123
124 start-stop-daemon: CFLAGS += $(CFLAGS_SSD)
125 start-stop-daemon: LDLIBS += $(LDLIBS_SSD)
126 start-stop-daemon: $(LIBEINFOSO) $(LIBRCSO) start-stop-daemon.o
127
128 links: rc
129 for x in $(RCLINKS) $(RCPRIVLINKS); do ln -sf rc $$x; done
130
131 install: $(TARGET)
132 install -m 0755 -d $(DESTDIR)/$(LIB)
133 install -m 0755 $(LIB_TARGETS) $(DESTDIR)/$(LIB)
134 ln -sf $(LIBEINFOSO) $(DESTDIR)/$(LIB)/libeinfo.so
135 ln -sf $(LIBRCSO) $(DESTDIR)/$(LIB)/librc.so
136 install -m 0755 -d $(DESTDIR)/usr/include
137 install -m 0644 einfo.h rc.h $(DESTDIR)/usr/include
138 install -m 0755 -d $(DESTDIR)/bin
139 install -m 0755 $(BIN_TARGETS) $(DESTDIR)/bin
140 install -m 0755 -d $(DESTDIR)/sbin
141 install -m 0755 $(SBIN_TARGETS) $(DESTDIR)/sbin
142 install -m 0755 -d $(DESTDIR)/$(LIB)/rcscripts/conf.d
143 install -m 0644 $(SYS_WHITELIST) $(DESTDIR)/$(LIB)/rcscripts/conf.d
144 install -m 0755 -d $(DESTDIR)/$(LIB)/rcscripts/bin
145 install -m 0755 $(PRIV_BIN_TARGETS) $(DESTDIR)/$(LIB)/rcscripts/bin
146 for x in $(RCLINKS); do ln -sf $(DESTDIR)/sbin/rc $(DESTDIR)/$(LIB)/rcscripts/bin/$$x; done
147 if test "$(HAVE_PAM)" != "" ; then \
148 install -m 0755 -d $(DESTDIR)/etc/pam.d ; \
149 install -m 0644 start-stop-daemon.pam $(DESTDIR)/etc/pam.d/start-stop-daemon ; \
150 fi
151
152 clean:
153 rm -f $(TARGET) $(RCLINKS) $(RCPRIVLINKS)
154 rm -f *.o *~ *.core *.so

  ViewVC Help
Powered by ViewVC 1.1.20