/[baselayout]/trunk/src/Makefile
Gentoo

Contents of /trunk/src/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2814 - (hide annotations) (download)
Sat Aug 4 15:05:12 2007 UTC (7 years, 1 month ago) by uberlord
File size: 4984 byte(s)
Fix rc-update, #187487 and release rc2.
1 uberlord 2547 # 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 uberlord 2561
8 uberlord 2638 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 uberlord 2561 # Loads of nice flags to ensure our code is good
12 uberlord 2805 CFLAGS += -pedantic -std=c99 \
13 uberlord 2548 -Wall -Wunused -Wimplicit -Wshadow -Wformat=2 \
14 uberlord 2547 -Wmissing-declarations -Wno-missing-prototypes -Wwrite-strings \
15     -Wbad-function-cast -Wnested-externs -Wcomment -Winline \
16 uberlord 2561 -Wchar-subscripts -Wcast-align -Wno-format-nonliteral \
17     $(call check_gcc, -Wdeclaration-after-statement) \
18     $(call check_gcc, -Wsequence-point) \
19 uberlord 2573 $(call check_gcc, -Wextra)
20 uberlord 2547
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 uberlord 2801 LIBRCOBJS = librc.o librc-depend.o librc-daemon.o librc-misc.o librc-strlist.o
34 uberlord 2547
35 uberlord 2801 RCOBJS = env-update.o fstabinfo.o mountinfo.o \
36 uberlord 2814 rc-depend.o rc-plugin.o rc-status.o rc-update.o runscript.o \
37     start-stop-daemon.o
38 uberlord 2801
39 uberlord 2547 LIB_TARGETS = $(LIBEINFOSO) $(LIBRCSO)
40 uberlord 2799 SBIN_TARGETS = rc
41 uberlord 2547 SYS_WHITELIST = env_whitelist
42    
43 uberlord 2550 TARGET = $(LIB_TARGETS) $(BIN_TARGETS) $(SBIN_TARGETS) $(PRIV_BIN_TARGETS)
44 uberlord 2547
45     RCLINKS = einfon einfo ewarnn ewarn eerrorn eerror ebegin eend ewend \
46 uberlord 2768 eindent eoutdent eval_ecolors \
47 uberlord 2547 veinfo vewarn vebegin veend vewend veindent veoutdent \
48     service_starting service_inactive service_started \
49     service_stopping service_stopped \
50     service_inactive service_wasinactive \
51     service_coldplugged \
52     mark_service_starting mark_service_inactive mark_service_started \
53     mark_service_stopping mark_service_stopped \
54     mark_service_inactive mark_service_wasinactive \
55     mark_service_coldplugged \
56 uberlord 2799 get_options save_options rc-abort rc-depend \
57     is_runlevel_start is_runlevel_stop service_started_daemon \
58     fstabinfo mountinfo
59     BINLINKS = rc-status
60     SBINLINKS = env-update rc-update runscript start-stop-daemon
61 uberlord 2547
62     # Quick hack to make my life easier on BSD and Linux
63     ifeq ($(OS),)
64     OS=$(shell uname -s)
65     ifneq ($(OS),Linux)
66     OS=BSD
67     endif
68     endif
69    
70     ifeq ($(OS),Linux)
71     LDLIBS_RC = -ldl
72     LDLIBS_RS = -ldl
73 uberlord 2708 LDLIBS_SSD = -lrt
74 uberlord 2547 # Shouldn't need this, but it's the easiest workaround for silly
75     # Linux headers that don't work with -std=c99
76 vapier 2593 override CPPFLAGS += -D_GNU_SOURCE
77 uberlord 2547 endif
78     ifeq ($(OS),BSD)
79 uberlord 2698 LDLIBS_LIBRC = -lkvm
80 uberlord 2547 endif
81    
82     HAVE_PAM =
83     ifdef HAVE_PAM
84 vapier 2593 CPPFLAGS_SSD = -DHAVE_PAM
85 uberlord 2708 LDLIBS_SSD += -lpam
86 uberlord 2547 endif
87    
88     # We also define _BSD_SOURCE so both Linux and the BSDs get a few
89     # handy functions which makes our lives a lot easier
90 vapier 2593 override CPPFLAGS += -DLIB=\"$(LIB)\"
91 uberlord 2547
92     # IMPORTANT!!!
93     # Remove this when releasing as it's a security risk
94     # However, this does save us using libtool when we're testing
95     # NOTE: The toplevel Makefile for baselayout will automatically
96     # disable then when doing `make dist`
97 vapier 2593 ifneq ($(wildcard .svn),)
98 uberlord 2563 override LDFLAGS += -Wl,-rpath .
99 vapier 2593 endif
100 uberlord 2547
101     all: $(TARGET)
102    
103 uberlord 2804 $(LIBEINFOOBJS): override CFLAGS += -fPIC
104 uberlord 2547 $(LIBEINFOSO): LDLIBS =
105     $(LIBEINFOSO): $(LIBEINFOOBJS)
106     $(CC) -fPIC -shared -Wl,-soname,$(LIBEINFOSO) -o $(LIBEINFOSO) $(LIBEINFOOBJS)
107     ln -sf $(LIBEINFOSO) libeinfo.so
108    
109 uberlord 2804 $(LIBRCOBJS): override CFLAGS += -fPIC
110 uberlord 2547 $(LIBRCSO): $(LIBRCOBJS)
111 uberlord 2698 $(CC) -fPIC -shared -Wl,-soname,$(LIBRCSO) -o $(LIBRCSO) $(LDLIBS_LIBRC) $(LIBRCOBJS)
112 uberlord 2547 ln -sf $(LIBRCSO) librc.so
113    
114 uberlord 2804 rc: override CPPFLAGS += $(CPPFLAGS_SSD)
115     rc: override LDLIBS += $(LDLIBS_RC) $(LDLIBS_RS) $(LDLIBS_SSD)
116 uberlord 2801 rc: $(LIBEINFOSO) $(LIBRCSO) $(RCOBJS) rc.o
117 uberlord 2547
118     links: rc
119 uberlord 2799 for x in $(BINLINKS) $(SBINLINKS) $(RCLINKS) $(RCPRIVLINKS); do ln -sf rc $$x; done
120 uberlord 2547
121     install: $(TARGET)
122     install -m 0755 -d $(DESTDIR)/$(LIB)
123     install -m 0755 $(LIB_TARGETS) $(DESTDIR)/$(LIB)
124 vapier 2592 ln -sf $(LIBEINFOSO) $(DESTDIR)/$(LIB)/libeinfo.so
125     ln -sf $(LIBRCSO) $(DESTDIR)/$(LIB)/librc.so
126 uberlord 2547 install -m 0755 -d $(DESTDIR)/usr/include
127     install -m 0644 einfo.h rc.h $(DESTDIR)/usr/include
128     install -m 0755 -d $(DESTDIR)/bin
129     install -m 0755 -d $(DESTDIR)/sbin
130     install -m 0755 $(SBIN_TARGETS) $(DESTDIR)/sbin
131 vapier 2590 ln -sf rc-update $(DESTDIR)/sbin/update-rc
132 uberlord 2547 install -m 0755 -d $(DESTDIR)/$(LIB)/rcscripts/conf.d
133     install -m 0644 $(SYS_WHITELIST) $(DESTDIR)/$(LIB)/rcscripts/conf.d
134     install -m 0755 -d $(DESTDIR)/$(LIB)/rcscripts/bin
135 uberlord 2810 for x in $(BINLINKS); do ln -sf ../sbin/rc $(DESTDIR)/bin/$$x; done
136     for x in $(SBINLINKS); do ln -sf rc $(DESTDIR)/sbin/$$x; done
137     for x in $(RCLINKS); do ln -sf ../../../sbin/rc $(DESTDIR)/$(LIB)/rcscripts/bin/$$x; done
138 uberlord 2547 if test "$(HAVE_PAM)" != "" ; then \
139     install -m 0755 -d $(DESTDIR)/etc/pam.d ; \
140     install -m 0644 start-stop-daemon.pam $(DESTDIR)/etc/pam.d/start-stop-daemon ; \
141     fi
142    
143     clean:
144 uberlord 2799 rm -f $(TARGET) $(BINLINKS) $(SBINLINKS) $(RCLINKS) $(RCPRIVLINKS)
145 uberlord 2605 rm -f *.o *~ *.core *.so .depend
146 vapier 2594
147     -include .depend
148 vapier 2595 .depend: $(wildcard *.c *.h)
149 vapier 2594 $(CC) $(CPPFLAGS) -MM *.c > .depend
150    
151     .PHONY: all clean install links

  ViewVC Help
Powered by ViewVC 1.1.20