/[baselayout]/trunk/src/Makefile
Gentoo

Diff of /trunk/src/Makefile

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 2834 Revision 2868
1# Copyright 1999-2007 Gentoo Foundation 1# Copyright 1999-2007 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3 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
4CC ?= gcc 15CC ?= gcc
16CFLAGS += -O2 -pipe
5 17
6CFLAGS ?= -Wall -O2 -pipe 18# GNU Make way of detecting gcc flags we can use
7
8check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \ 19check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
9 then echo "$(1)"; else echo "$(2)"; fi) 20 then echo "$(1)"; else echo "$(2)"; fi)
21
22# pmake check for extra cflags
23WEXTRA != for x in -Wdeclaration-after-statement -Wsequence-point -Wextra; do \
24 if $(CC) -Wdeclaration-after-statement -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
25 then echo -n "$$x "; fi \
26 done
10 27
11# Loads of nice flags to ensure our code is good 28# Loads of nice flags to ensure our code is good
12CFLAGS += -pedantic -std=c99 \ 29CFLAGS += -pedantic -std=c99 \
13 -Wall -Wunused -Wimplicit -Wshadow -Wformat=2 \ 30 -Wall -Wunused -Wimplicit -Wshadow -Wformat=2 \
14 -Wmissing-declarations -Wno-missing-prototypes -Wwrite-strings \ 31 -Wmissing-declarations -Wno-missing-prototypes -Wwrite-strings \
15 -Wbad-function-cast -Wnested-externs -Wcomment -Winline \ 32 -Wbad-function-cast -Wnested-externs -Wcomment -Winline \
16 -Wchar-subscripts -Wcast-align -Wno-format-nonliteral \ 33 -Wchar-subscripts -Wcast-align -Wno-format-nonliteral \
17 $(call check_gcc, -Wdeclaration-after-statement) \ 34 $(call check_gcc, -Wdeclaration-after-statement) \
18 $(call check_gcc, -Wsequence-point) \ 35 $(call check_gcc, -Wsequence-point) \
19 $(call check_gcc, -Wextra) 36 $(call check_gcc, -Wextra) $(WEXTRA)
20 37
21# For debugging. -Werror is pointless due to ISO C issues with dlsym 38# For debugging. -Werror is pointless due to ISO C issues with dlsym
22#CFLAGS += -ggdb 39#CFLAGS += -ggdb
23 40
24DESTDIR = 41DESTDIR =
25LIB = lib 42LIB = lib
43
44# Set PAM = pam for pam support
45PAM =
46
47# Load an optional OS Makefile
48_OS_SH = u=`uname -s`; case "$${u}" in *BSD|DragonFly) echo "BSD";; *) echo "$${u}";; esac
49_OS != $(_OS_SH)
50OS ?= $(_OS)$(shell $(_OS_SH))
51-include Makefile.$(OS)
52-include Makefile.$(PAM)
26 53
27LIBEINFOSOVER = 0 54LIBEINFOSOVER = 0
28LIBEINFOSO = libeinfo.so.$(LIBRCSOVER) 55LIBEINFOSO = libeinfo.so.$(LIBRCSOVER)
29LIBEINFOOBJS= libeinfo.o 56LIBEINFOOBJS= libeinfo.o
30 57
32LIBRCSO = librc.so.$(LIBRCSOVER) 59LIBRCSO = librc.so.$(LIBRCSOVER)
33LIBRCOBJS = librc.o librc-depend.o librc-daemon.o librc-misc.o librc-strlist.o 60LIBRCOBJS = librc.o librc-depend.o librc-daemon.o librc-misc.o librc-strlist.o
34 61
35RCOBJS = env-update.o fstabinfo.o mountinfo.o \ 62RCOBJS = env-update.o fstabinfo.o mountinfo.o \
36 rc-depend.o rc-plugin.o rc-status.o rc-update.o runscript.o \ 63 rc-depend.o rc-plugin.o rc-status.o rc-update.o runscript.o \
37 start-stop-daemon.o 64 start-stop-daemon.o rc.o
38 65
39LIB_TARGETS = $(LIBEINFOSO) $(LIBRCSO) 66LIB_TARGETS = $(LIBEINFOSO) $(LIBRCSO)
40SBIN_TARGETS = rc 67SBIN_TARGETS = rc
41SYS_WHITELIST = env_whitelist 68SYS_WHITELIST = env_whitelist
42 69
57 is_runlevel_start is_runlevel_stop service_started_daemon \ 84 is_runlevel_start is_runlevel_stop service_started_daemon \
58 fstabinfo mountinfo 85 fstabinfo mountinfo
59BINLINKS = rc-status 86BINLINKS = rc-status
60SBINLINKS = env-update rc-update runscript start-stop-daemon 87SBINLINKS = env-update rc-update runscript start-stop-daemon
61 88
62# Quick hack to make my life easier on BSD and Linux
63ifeq ($(OS),)
64OS=$(shell uname -s)
65ifneq ($(OS),Linux)
66OS=BSD
67endif
68endif
69
70ifeq ($(OS),Linux)
71LDLIBS_RC = -ldl
72LDLIBS_RS = -ldl
73# Shouldn't need this, but it's the easiest workaround for silly
74# Linux headers that don't work with -std=c99
75override CPPFLAGS += -D_GNU_SOURCE
76endif
77ifeq ($(OS),BSD)
78LDLIBS_LIBRC = -lkvm
79endif
80
81HAVE_PAM =
82ifdef HAVE_PAM
83CPPFLAGS_SSD = -DHAVE_PAM
84LDLIBS_SSD += -lpam
85endif
86
87# We also define _BSD_SOURCE so both Linux and the BSDs get a few 89# We also define _BSD_SOURCE so both Linux and the BSDs get a few
88# handy functions which makes our lives a lot easier 90# handy functions which makes our lives a lot easier
89override CPPFLAGS += -DLIB=\"$(LIB)\" 91CPPFLAGS += -DLIB=\"$(LIB)\"
90 92
91# IMPORTANT!!! 93# IMPORTANT!!!
92# Remove this when releasing as it's a security risk 94# Ensure that we don't ship with a .svn directory to avoid RPATH security
93# However, this does save us using libtool when we're testing 95# issues. However, this does ease development a little
94# NOTE: The toplevel Makefile for baselayout will automatically 96_SVN_LDFLAGS_SH = if test -d .svn; then echo "-Wl,-rpath ."; else echo ""; fi
95# disable then when doing `make dist` 97_SVN_LDFLAGS != $(_SVN_LDFLAGS_SH)
96ifneq ($(wildcard .svn),) 98LDFLAGS += $(_SVN_LDFLAGS)$(shell $(_SVN_LDFLAGS_SH))
97override LDFLAGS += -Wl,-rpath .
98endif
99 99
100all: $(TARGET) 100all: .depend $(TARGET)
101 101
102$(LIBEINFOOBJS): override CFLAGS += -fPIC 102$(LIBEINFOOBJS):
103$(LIBEINFOSO): LDLIBS = 103 $(CC) $(CPPFLAGS) $(CFLAGS) -fPIC -c $<
104$(LIBEINFOSO): $(LIBEINFOOBJS) 104$(LIBEINFOSO): $(LIBEINFOOBJS)
105 $(CC) -fPIC -shared -Wl,-soname,$(LIBEINFOSO) -o $(LIBEINFOSO) $(LIBEINFOOBJS) 105 $(CC) $(LDFLAGS) -fPIC -shared -Wl,-soname,$(LIBEINFOSO) -o $(LIBEINFOSO) $(LIBEINFOOBJS)
106 ln -sf $(LIBEINFOSO) libeinfo.so 106 ln -sf $(LIBEINFOSO) libeinfo.so
107 107
108$(LIBRCOBJS): override CFLAGS += -fPIC 108$(LIBRCOBJS):
109 $(CC) $(CPPFLAGS) $(CFLAGS) -fPIC -c $<
109$(LIBRCSO): $(LIBRCOBJS) 110$(LIBRCSO): $(LIBRCOBJS)
110 $(CC) -fPIC -shared -Wl,-soname,$(LIBRCSO) -o $(LIBRCSO) $(LDLIBS_LIBRC) $(LIBRCOBJS) 111 $(CC) $(LDFLAGS) -fPIC -shared -Wl,-soname,$(LIBRCSO) -o $(LIBRCSO) $(LDLIBS_LIBRC) $(LIBRCOBJS)
111 ln -sf $(LIBRCSO) librc.so 112 ln -sf $(LIBRCSO) librc.so
112 113
113rc: override CPPFLAGS += $(CPPFLAGS_SSD) 114$(RCOBJS):
114rc: override LDLIBS += $(LDLIBS_RC) $(LDLIBS_RS) $(LDLIBS_SSD) 115 $(CC) $(CPPFLAGS) $(CPPFLAGS_SSD) $(CFLAGS) -c $<
115rc: $(LIBEINFOSO) $(LIBRCSO) $(RCOBJS) rc.o 116rc: $(LIBEINFOSO) $(LIBRCSO) $(RCOBJS)
117 $(CC) $(LDFLAGS) -o rc $(RCOBJS) $(LIBRCSO) $(LIBEINFOSO) $(LDLIBS_SSD) $(LDLIBS_RC)
116 118
117links: rc 119links: rc
118 for x in $(BINLINKS) $(SBINLINKS) $(RCLINKS) $(RCPRIVLINKS); do ln -sf rc $$x; done 120 for x in $(BINLINKS) $(SBINLINKS) $(RCLINKS) $(RCPRIVLINKS); do ln -sf rc $$x; done
119 121
120install: $(TARGET) 122install: $(TARGET)
132 install -m 0644 $(SYS_WHITELIST) $(DESTDIR)/$(LIB)/rcscripts/conf.d 134 install -m 0644 $(SYS_WHITELIST) $(DESTDIR)/$(LIB)/rcscripts/conf.d
133 install -m 0755 -d $(DESTDIR)/$(LIB)/rcscripts/bin 135 install -m 0755 -d $(DESTDIR)/$(LIB)/rcscripts/bin
134 for x in $(BINLINKS); do ln -sf ../sbin/rc $(DESTDIR)/bin/$$x; done 136 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 137 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 138 for x in $(RCLINKS); do ln -sf ../../../sbin/rc $(DESTDIR)/$(LIB)/rcscripts/bin/$$x; done
137 if test "$(HAVE_PAM)" != "" ; then \ 139 if test "$(PAM)" != "pam" ; then \
138 install -m 0755 -d $(DESTDIR)/etc/pam.d ; \ 140 install -m 0755 -d $(DESTDIR)/etc/pam.d ; \
139 install -m 0644 start-stop-daemon.pam $(DESTDIR)/etc/pam.d/start-stop-daemon ; \ 141 install -m 0644 start-stop-daemon.pam $(DESTDIR)/etc/pam.d/start-stop-daemon ; \
140 fi 142 fi
141 143
142clean: 144clean:
143 rm -f $(TARGET) $(BINLINKS) $(SBINLINKS) $(RCLINKS) $(RCPRIVLINKS) 145 rm -f $(TARGET) $(BINLINKS) $(SBINLINKS) $(RCLINKS) $(RCPRIVLINKS)
144 rm -f *.o *~ *.core *.so .depend 146 rm -f *.o *~ *.core *.so .depend
145 147
146-include .depend 148-include .depend
149_DEPS != ls *.c *.h
147.depend: $(wildcard *.c *.h) 150.depend: $(_DEPS)$(wildcard *.c *.h)
148 $(CC) $(CPPFLAGS) -MM *.c > .depend 151 $(CC) $(CPPFLAGS) -MM *.c > .depend
149 152
150.PHONY: all clean install links 153.PHONY: all clean install links

Legend:
Removed from v.2834  
changed lines
  Added in v.2868

  ViewVC Help
Powered by ViewVC 1.1.20