/[baselayout]/trunk/src/Makefile
Gentoo

Contents of /trunk/src/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2708 - (hide annotations) (download)
Wed May 16 11:05:42 2007 UTC (7 years, 3 months ago) by uberlord
File size: 5235 byte(s)
Stop using getimeofday for timeouts incase the clock changes.
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 uberlord 2708 LDLIBS_SSD = -lrt
69 uberlord 2547 # Shouldn't need this, but it's the easiest workaround for silly
70     # Linux headers that don't work with -std=c99
71 vapier 2593 override CPPFLAGS += -D_GNU_SOURCE
72 uberlord 2547 endif
73     ifeq ($(OS),BSD)
74 uberlord 2698 LDLIBS_LIBRC = -lkvm
75 uberlord 2547 endif
76    
77     HAVE_PAM =
78     ifdef HAVE_PAM
79 vapier 2593 CPPFLAGS_SSD = -DHAVE_PAM
80 uberlord 2708 LDLIBS_SSD += -lpam
81 uberlord 2547 endif
82    
83     # We also define _BSD_SOURCE so both Linux and the BSDs get a few
84     # handy functions which makes our lives a lot easier
85 vapier 2593 override CPPFLAGS += -DLIB=\"$(LIB)\"
86 uberlord 2547
87     # IMPORTANT!!!
88     # Remove this when releasing as it's a security risk
89     # However, this does save us using libtool when we're testing
90     # NOTE: The toplevel Makefile for baselayout will automatically
91     # disable then when doing `make dist`
92 vapier 2593 ifneq ($(wildcard .svn),)
93 uberlord 2563 override LDFLAGS += -Wl,-rpath .
94 vapier 2593 endif
95 uberlord 2547
96     all: $(TARGET)
97    
98     $(LIBEINFOOBJS): CFLAGS += -fPIC
99     $(LIBEINFOSO): LDLIBS =
100     $(LIBEINFOSO): $(LIBEINFOOBJS)
101     $(CC) -fPIC -shared -Wl,-soname,$(LIBEINFOSO) -o $(LIBEINFOSO) $(LIBEINFOOBJS)
102     ln -sf $(LIBEINFOSO) libeinfo.so
103    
104     $(LIBRCOBJS): CFLAGS += -fPIC
105     $(LIBRCSO): $(LIBRCOBJS)
106 uberlord 2698 $(CC) -fPIC -shared -Wl,-soname,$(LIBRCSO) -o $(LIBRCSO) $(LDLIBS_LIBRC) $(LIBRCOBJS)
107 uberlord 2547 ln -sf $(LIBRCSO) librc.so
108    
109     env-update: $(LIBEINFOSO) $(LIBRCSO) env-update.o
110    
111     fstabinfo: $(LIBEINFOSO) fstabinfo.o
112    
113     mountinfo: $(LIBEINFOSO) $(LIBRCSO) mountinfo.o
114    
115     rc-depend: $(LIBEINFOSO) $(LIBRCSO) rc-depend.o
116    
117     rc-status: $(LIBEINFOSO) $(LIBRCSO) rc-status.o
118    
119     rc-update: $(LIBEINFOSO) $(LIBRCSO) rc-update.o
120    
121     rc: LDLIBS += $(LDLIBS_RC)
122     rc: $(LIBEINFOSO) $(LIBRCSO) rc-plugin.o rc.o
123    
124     runscript: LDLIBS += $(LDLIBS_RS)
125     runscript: $(LIBEINFOSO) $(LIBRCSO) rc-plugin.o runscript.o
126    
127 vapier 2593 start-stop-daemon: CPPFLAGS += $(CPPFLAGS_SSD)
128 uberlord 2547 start-stop-daemon: LDLIBS += $(LDLIBS_SSD)
129     start-stop-daemon: $(LIBEINFOSO) $(LIBRCSO) start-stop-daemon.o
130    
131     links: rc
132     for x in $(RCLINKS) $(RCPRIVLINKS); do ln -sf rc $$x; done
133    
134     install: $(TARGET)
135     install -m 0755 -d $(DESTDIR)/$(LIB)
136     install -m 0755 $(LIB_TARGETS) $(DESTDIR)/$(LIB)
137 vapier 2592 ln -sf $(LIBEINFOSO) $(DESTDIR)/$(LIB)/libeinfo.so
138     ln -sf $(LIBRCSO) $(DESTDIR)/$(LIB)/librc.so
139 uberlord 2547 install -m 0755 -d $(DESTDIR)/usr/include
140     install -m 0644 einfo.h rc.h $(DESTDIR)/usr/include
141     install -m 0755 -d $(DESTDIR)/bin
142     install -m 0755 $(BIN_TARGETS) $(DESTDIR)/bin
143     install -m 0755 -d $(DESTDIR)/sbin
144     install -m 0755 $(SBIN_TARGETS) $(DESTDIR)/sbin
145 vapier 2590 ln -sf rc-update $(DESTDIR)/sbin/update-rc
146 uberlord 2547 install -m 0755 -d $(DESTDIR)/$(LIB)/rcscripts/conf.d
147     install -m 0644 $(SYS_WHITELIST) $(DESTDIR)/$(LIB)/rcscripts/conf.d
148     install -m 0755 -d $(DESTDIR)/$(LIB)/rcscripts/bin
149 uberlord 2550 install -m 0755 $(PRIV_BIN_TARGETS) $(DESTDIR)/$(LIB)/rcscripts/bin
150 uberlord 2547 for x in $(RCLINKS); do ln -sf $(DESTDIR)/sbin/rc $(DESTDIR)/$(LIB)/rcscripts/bin/$$x; done
151     if test "$(HAVE_PAM)" != "" ; then \
152     install -m 0755 -d $(DESTDIR)/etc/pam.d ; \
153     install -m 0644 start-stop-daemon.pam $(DESTDIR)/etc/pam.d/start-stop-daemon ; \
154     fi
155    
156     clean:
157     rm -f $(TARGET) $(RCLINKS) $(RCPRIVLINKS)
158 uberlord 2605 rm -f *.o *~ *.core *.so .depend
159 vapier 2594
160     -include .depend
161 vapier 2595 .depend: $(wildcard *.c *.h)
162 vapier 2594 $(CC) $(CPPFLAGS) -MM *.c > .depend
163    
164     .PHONY: all clean install links

  ViewVC Help
Powered by ViewVC 1.1.20