/[baselayout]/trunk/src/Makefile
Gentoo

Contents of /trunk/src/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2897 - (hide annotations) (download)
Wed Sep 19 16:27:37 2007 UTC (7 years, 1 month ago) by uberlord
File size: 5858 byte(s)
    Added the checkown applet based on the work by Renato Caldas, #192682
    checkdir ensures that the specified files (or directories) are owned
    by the current user/group or as specified on the command line. You can
    optionally check permissions too.
1 uberlord 2547 # Copyright 1999-2007 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3    
4 uberlord 2868 # 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    
15 uberlord 2547 CC ?= gcc
16 uberlord 2868 CFLAGS += -O2 -pipe
17 uberlord 2875 LDFLAGS += -L.
18 uberlord 2547
19 uberlord 2868 # GNU Make way of detecting gcc flags we can use
20 uberlord 2638 check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
21     then echo "$(1)"; else echo "$(2)"; fi)
22    
23 uberlord 2868 # pmake check for extra cflags
24     WEXTRA != for x in -Wdeclaration-after-statement -Wsequence-point -Wextra; do \
25     if $(CC) -Wdeclaration-after-statement -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
26     then echo -n "$$x "; fi \
27     done
28    
29 uberlord 2561 # Loads of nice flags to ensure our code is good
30 uberlord 2805 CFLAGS += -pedantic -std=c99 \
31 uberlord 2548 -Wall -Wunused -Wimplicit -Wshadow -Wformat=2 \
32 uberlord 2547 -Wmissing-declarations -Wno-missing-prototypes -Wwrite-strings \
33     -Wbad-function-cast -Wnested-externs -Wcomment -Winline \
34 uberlord 2561 -Wchar-subscripts -Wcast-align -Wno-format-nonliteral \
35     $(call check_gcc, -Wdeclaration-after-statement) \
36     $(call check_gcc, -Wsequence-point) \
37 uberlord 2868 $(call check_gcc, -Wextra) $(WEXTRA)
38 uberlord 2547
39     # For debugging. -Werror is pointless due to ISO C issues with dlsym
40     #CFLAGS += -ggdb
41    
42     DESTDIR =
43     LIB = lib
44 uberlord 2895 RC_LIB = /$(LIB)/rc
45 uberlord 2547
46 uberlord 2868 # Set PAM = pam for pam support
47     PAM =
48    
49 uberlord 2547 LIBEINFOSOVER = 0
50     LIBEINFOSO = libeinfo.so.$(LIBRCSOVER)
51     LIBEINFOOBJS= libeinfo.o
52 uberlord 2876 LDLIBS_LIBEINFO = $(LDLIBS)
53 uberlord 2547
54     LIBRCSOVER = 0
55     LIBRCSO = librc.so.$(LIBRCSOVER)
56 uberlord 2801 LIBRCOBJS = librc.o librc-depend.o librc-daemon.o librc-misc.o librc-strlist.o
57 uberlord 2875 LDLIBS_LIBRC = -leinfo
58 uberlord 2547
59 uberlord 2897 RCOBJS = checkown.o env-update.o fstabinfo.o mountinfo.o \
60 uberlord 2814 rc-depend.o rc-plugin.o rc-status.o rc-update.o runscript.o \
61 uberlord 2868 start-stop-daemon.o rc.o
62 uberlord 2875 LDLIBS_RC = $(LDLIBS_LIBRC) -lrc
63 uberlord 2801
64 uberlord 2547 LIB_TARGETS = $(LIBEINFOSO) $(LIBRCSO)
65 uberlord 2799 SBIN_TARGETS = rc
66 uberlord 2547 SYS_WHITELIST = env_whitelist
67    
68 uberlord 2550 TARGET = $(LIB_TARGETS) $(BIN_TARGETS) $(SBIN_TARGETS) $(PRIV_BIN_TARGETS)
69 uberlord 2547
70     RCLINKS = einfon einfo ewarnn ewarn eerrorn eerror ebegin eend ewend \
71 uberlord 2834 eindent eoutdent esyslog eval_ecolors \
72 uberlord 2547 veinfo vewarn vebegin veend vewend veindent veoutdent \
73     service_starting service_inactive service_started \
74     service_stopping service_stopped \
75     service_inactive service_wasinactive \
76     service_coldplugged \
77     mark_service_starting mark_service_inactive mark_service_started \
78     mark_service_stopping mark_service_stopped \
79     mark_service_inactive mark_service_wasinactive \
80     mark_service_coldplugged \
81 uberlord 2799 get_options save_options rc-abort rc-depend \
82     is_runlevel_start is_runlevel_stop service_started_daemon \
83 uberlord 2897 checkown fstabinfo mountinfo
84 uberlord 2799 BINLINKS = rc-status
85     SBINLINKS = env-update rc-update runscript start-stop-daemon
86 uberlord 2547
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 uberlord 2868 CPPFLAGS += -DLIB=\"$(LIB)\"
90 uberlord 2547
91     # IMPORTANT!!!
92 uberlord 2868 # Ensure that we don't ship with a .svn directory to avoid RPATH security
93     # issues. However, this does ease development a little
94     _SVN_LDFLAGS_SH = if test -d .svn; then echo "-Wl,-rpath ."; else echo ""; fi
95     _SVN_LDFLAGS != $(_SVN_LDFLAGS_SH)
96     LDFLAGS += $(_SVN_LDFLAGS)$(shell $(_SVN_LDFLAGS_SH))
97 uberlord 2547
98 uberlord 2875 # Load an optional OS Makefile
99     _OS_SH = u=`uname -s`; case "$${u}" in *BSD|DragonFly) echo "BSD";; *) echo "$${u}";; esac
100     _OS != $(_OS_SH)
101     OS ?= $(_OS)$(shell $(_OS_SH))
102     -include Makefile.$(OS)
103     -include Makefile.$(PAM)
104    
105 uberlord 2868 all: .depend $(TARGET)
106 uberlord 2547
107 uberlord 2868 $(LIBEINFOOBJS):
108     $(CC) $(CPPFLAGS) $(CFLAGS) -fPIC -c $<
109 uberlord 2547 $(LIBEINFOSO): $(LIBEINFOOBJS)
110 uberlord 2876 $(CC) $(LDFLAGS) -fPIC -shared -Wl,-soname,$(LIBEINFOSO) -o $(LIBEINFOSO) $(LIBEINFOOBJS) $(LDLIBS) $(LDLIBS_LIBEINFO)
111 uberlord 2547 ln -sf $(LIBEINFOSO) libeinfo.so
112    
113 uberlord 2868 $(LIBRCOBJS):
114     $(CC) $(CPPFLAGS) $(CFLAGS) -fPIC -c $<
115 uberlord 2874 $(LIBRCSO): $(LIBRCOBJS) $(LIBEINFOSO)
116 uberlord 2876 $(CC) $(LDFLAGS) -fPIC -shared -Wl,-soname,$(LIBRCSO) -o $(LIBRCSO) $(LIBRCOBJS) $(LDLIBS) $(LDLIBS_LIBRC)
117 uberlord 2547 ln -sf $(LIBRCSO) librc.so
118    
119 uberlord 2868 $(RCOBJS):
120     $(CC) $(CPPFLAGS) $(CPPFLAGS_SSD) $(CFLAGS) -c $<
121     rc: $(LIBEINFOSO) $(LIBRCSO) $(RCOBJS)
122 uberlord 2876 $(CC) $(LDFLAGS) -o rc $(RCOBJS) $(LDLIBS) $(LDLIBS_RC)
123 uberlord 2547
124     links: rc
125 uberlord 2799 for x in $(BINLINKS) $(SBINLINKS) $(RCLINKS) $(RCPRIVLINKS); do ln -sf rc $$x; done
126 uberlord 2547
127     install: $(TARGET)
128     install -m 0755 -d $(DESTDIR)/$(LIB)
129     install -m 0755 $(LIB_TARGETS) $(DESTDIR)/$(LIB)
130 vapier 2592 ln -sf $(LIBEINFOSO) $(DESTDIR)/$(LIB)/libeinfo.so
131     ln -sf $(LIBRCSO) $(DESTDIR)/$(LIB)/librc.so
132 uberlord 2547 install -m 0755 -d $(DESTDIR)/usr/include
133     install -m 0644 einfo.h rc.h $(DESTDIR)/usr/include
134     install -m 0755 -d $(DESTDIR)/bin
135     install -m 0755 -d $(DESTDIR)/sbin
136     install -m 0755 $(SBIN_TARGETS) $(DESTDIR)/sbin
137 vapier 2590 ln -sf rc-update $(DESTDIR)/sbin/update-rc
138 uberlord 2895 install -m 0755 -d $(DESTDIR)/$(RC_LIB)/conf.d
139     install -m 0644 $(SYS_WHITELIST) $(DESTDIR)/$(RC_LIB)/conf.d
140     install -m 0755 -d $(DESTDIR)/$(RC_LIB)/bin
141 uberlord 2810 for x in $(BINLINKS); do ln -sf ../sbin/rc $(DESTDIR)/bin/$$x; done
142     for x in $(SBINLINKS); do ln -sf rc $(DESTDIR)/sbin/$$x; done
143 uberlord 2895 for x in $(RCLINKS); do ln -sf ../../../sbin/rc $(DESTDIR)/$(RC_LIB)/bin/$$x; done
144     if test "$(PAM)" = "pam" ; then \
145 uberlord 2547 install -m 0755 -d $(DESTDIR)/etc/pam.d ; \
146     install -m 0644 start-stop-daemon.pam $(DESTDIR)/etc/pam.d/start-stop-daemon ; \
147     fi
148    
149     clean:
150 uberlord 2799 rm -f $(TARGET) $(BINLINKS) $(SBINLINKS) $(RCLINKS) $(RCPRIVLINKS)
151 uberlord 2605 rm -f *.o *~ *.core *.so .depend
152 vapier 2594
153     -include .depend
154 uberlord 2868 _DEPS != ls *.c *.h
155     .depend: $(_DEPS)$(wildcard *.c *.h)
156 vapier 2594 $(CC) $(CPPFLAGS) -MM *.c > .depend
157    
158     .PHONY: all clean install links

  ViewVC Help
Powered by ViewVC 1.1.20