/[baselayout]/trunk/src/Makefile
Gentoo

Contents of /trunk/src/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2810 - (show annotations) (download)
Thu Aug 2 11:09:09 2007 UTC (7 years, 1 month ago) by uberlord
File size: 4967 byte(s)
rc1
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
35 RCOBJS = env-update.o fstabinfo.o mountinfo.o \
36 rc-depend.o rc-plugin.o rc-status.o runscript.o start-stop-daemon.o
37
38 LIB_TARGETS = $(LIBEINFOSO) $(LIBRCSO)
39 SBIN_TARGETS = rc
40 SYS_WHITELIST = env_whitelist
41
42 TARGET = $(LIB_TARGETS) $(BIN_TARGETS) $(SBIN_TARGETS) $(PRIV_BIN_TARGETS)
43
44 RCLINKS = einfon einfo ewarnn ewarn eerrorn eerror ebegin eend ewend \
45 eindent eoutdent eval_ecolors \
46 veinfo vewarn vebegin veend vewend veindent veoutdent \
47 service_starting service_inactive service_started \
48 service_stopping service_stopped \
49 service_inactive service_wasinactive \
50 service_coldplugged \
51 mark_service_starting mark_service_inactive mark_service_started \
52 mark_service_stopping mark_service_stopped \
53 mark_service_inactive mark_service_wasinactive \
54 mark_service_coldplugged \
55 get_options save_options rc-abort rc-depend \
56 is_runlevel_start is_runlevel_stop service_started_daemon \
57 fstabinfo mountinfo
58 BINLINKS = rc-status
59 SBINLINKS = env-update rc-update runscript start-stop-daemon
60
61 # Quick hack to make my life easier on BSD and Linux
62 ifeq ($(OS),)
63 OS=$(shell uname -s)
64 ifneq ($(OS),Linux)
65 OS=BSD
66 endif
67 endif
68
69 ifeq ($(OS),Linux)
70 LDLIBS_RC = -ldl
71 LDLIBS_RS = -ldl
72 LDLIBS_SSD = -lrt
73 # Shouldn't need this, but it's the easiest workaround for silly
74 # Linux headers that don't work with -std=c99
75 override CPPFLAGS += -D_GNU_SOURCE
76 endif
77 ifeq ($(OS),BSD)
78 LDLIBS_LIBRC = -lkvm
79 endif
80
81 HAVE_PAM =
82 ifdef HAVE_PAM
83 CPPFLAGS_SSD = -DHAVE_PAM
84 LDLIBS_SSD += -lpam
85 endif
86
87 # We also define _BSD_SOURCE so both Linux and the BSDs get a few
88 # handy functions which makes our lives a lot easier
89 override CPPFLAGS += -DLIB=\"$(LIB)\"
90
91 # IMPORTANT!!!
92 # Remove this when releasing as it's a security risk
93 # However, this does save us using libtool when we're testing
94 # NOTE: The toplevel Makefile for baselayout will automatically
95 # disable then when doing `make dist`
96 ifneq ($(wildcard .svn),)
97 override LDFLAGS += -Wl,-rpath .
98 endif
99
100 all: $(TARGET)
101
102 $(LIBEINFOOBJS): override CFLAGS += -fPIC
103 $(LIBEINFOSO): LDLIBS =
104 $(LIBEINFOSO): $(LIBEINFOOBJS)
105 $(CC) -fPIC -shared -Wl,-soname,$(LIBEINFOSO) -o $(LIBEINFOSO) $(LIBEINFOOBJS)
106 ln -sf $(LIBEINFOSO) libeinfo.so
107
108 $(LIBRCOBJS): override CFLAGS += -fPIC
109 $(LIBRCSO): $(LIBRCOBJS)
110 $(CC) -fPIC -shared -Wl,-soname,$(LIBRCSO) -o $(LIBRCSO) $(LDLIBS_LIBRC) $(LIBRCOBJS)
111 ln -sf $(LIBRCSO) librc.so
112
113 rc: override CPPFLAGS += $(CPPFLAGS_SSD)
114 rc: override LDLIBS += $(LDLIBS_RC) $(LDLIBS_RS) $(LDLIBS_SSD)
115 rc: $(LIBEINFOSO) $(LIBRCSO) $(RCOBJS) rc.o
116
117 links: rc
118 for x in $(BINLINKS) $(SBINLINKS) $(RCLINKS) $(RCPRIVLINKS); do ln -sf rc $$x; done
119
120 install: $(TARGET)
121 install -m 0755 -d $(DESTDIR)/$(LIB)
122 install -m 0755 $(LIB_TARGETS) $(DESTDIR)/$(LIB)
123 ln -sf $(LIBEINFOSO) $(DESTDIR)/$(LIB)/libeinfo.so
124 ln -sf $(LIBRCSO) $(DESTDIR)/$(LIB)/librc.so
125 install -m 0755 -d $(DESTDIR)/usr/include
126 install -m 0644 einfo.h rc.h $(DESTDIR)/usr/include
127 install -m 0755 -d $(DESTDIR)/bin
128 install -m 0755 -d $(DESTDIR)/sbin
129 install -m 0755 $(SBIN_TARGETS) $(DESTDIR)/sbin
130 ln -sf rc-update $(DESTDIR)/sbin/update-rc
131 install -m 0755 -d $(DESTDIR)/$(LIB)/rcscripts/conf.d
132 install -m 0644 $(SYS_WHITELIST) $(DESTDIR)/$(LIB)/rcscripts/conf.d
133 install -m 0755 -d $(DESTDIR)/$(LIB)/rcscripts/bin
134 for x in $(BINLINKS); do ln -sf ../sbin/rc $(DESTDIR)/bin/$$x; done
135 for x in $(SBINLINKS); do ln -sf rc $(DESTDIR)/sbin/$$x; done
136 for x in $(RCLINKS); do ln -sf ../../../sbin/rc $(DESTDIR)/$(LIB)/rcscripts/bin/$$x; done
137 if test "$(HAVE_PAM)" != "" ; then \
138 install -m 0755 -d $(DESTDIR)/etc/pam.d ; \
139 install -m 0644 start-stop-daemon.pam $(DESTDIR)/etc/pam.d/start-stop-daemon ; \
140 fi
141
142 clean:
143 rm -f $(TARGET) $(BINLINKS) $(SBINLINKS) $(RCLINKS) $(RCPRIVLINKS)
144 rm -f *.o *~ *.core *.so .depend
145
146 -include .depend
147 .depend: $(wildcard *.c *.h)
148 $(CC) $(CPPFLAGS) -MM *.c > .depend
149
150 .PHONY: all clean install links

  ViewVC Help
Powered by ViewVC 1.1.20