/[baselayout]/trunk/src/Makefile
Gentoo

Contents of /trunk/src/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.20