/[baselayout]/trunk/src/Makefile
Gentoo

Contents of /trunk/src/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.20