/[gentoo-projects]/portage-utils/Makefile
Gentoo

Contents of /portage-utils/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.74 - (show annotations) (download)
Mon Dec 19 04:59:53 2011 UTC (2 years, 7 months ago) by vapier
Branch: MAIN
Changes since 1.73: +4 -3 lines
fix typo in check-gcc usage so we actually add the extra warning flags

1 # Copyright 2005-2008 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-projects/portage-utils/Makefile,v 1.73 2011/12/12 21:16:23 vapier Exp $
4 ####################################################################
5
6 check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
7 then echo "$(1)"; else echo "$(2)"; fi)
8
9 ####################################################
10 WFLAGS := -Wall -Wunused -Wimplicit -Wshadow -Wformat=2 \
11 -Wmissing-declarations -Wno-missing-prototypes -Wwrite-strings \
12 -Wbad-function-cast -Wnested-externs -Wcomment -Winline \
13 -Wchar-subscripts -Wcast-align -Wno-format-nonliteral \
14 $(call check_gcc, -Wsequence-point) \
15 $(call check_gcc, -Wextra) \
16 $(call check_gcc, -Wno-sign-compare)
17
18 CFLAGS ?= -O2 -g -pipe
19 CFLAGS += -std=gnu99
20 CPPFLAGS ?=
21 #CFLAGS += -DEBUG -g
22 #CFLAGS += -Os -DOPTIMIZE_FOR_SIZE=2 -falign-functions=2 -falign-jumps=2 -falign-labels=2 -falign-loops=2
23 #LDFLAGS := -pie
24 LIBADD += $(shell echo | $(CC) -dM -E - | grep -q ' __FreeBSD__' && echo '-lkvm')
25 DESTDIR :=
26 PREFIX := $(DESTDIR)/usr
27 STRIP := strip
28 MKDIR := mkdir -p
29 CP := cp
30
31 ifndef V
32 Q = @
33 else
34 Q =
35 endif
36 ifdef PV
37 CPPFLAGS += -DVERSION=\"$(PV)\"
38 else
39 PV := cvs
40 endif
41 ifndef PF
42 PF := portage-utils-$(PV)
43 endif
44 DOCS := TODO README qsync
45
46 #ifdef PYTHON
47 #PYFLAGS ?= $(shell python-config) -DWANT_PYTHON -ldl -pthread -lutil /usr/lib/libpython2.4.so
48 ##PYFLAGS += -lpython2.4
49 #endif
50
51 #####################################################
52 APPLETS := $(shell sed -n '/^DECLARE_APPLET/s:.*(\(.*\))$$:\1:p' applets.h|sort)
53 SRC := $(APPLETS:%=%.c) main.c
54 APP_FLAGS := $(foreach a,$(APPLETS),-DAPPLET_$a)
55 CPPFLAGS += $(APP_FLAGS)
56
57 all: q
58 @true
59
60 debug:
61 $(MAKE) CFLAGS="$(CFLAGS) -O0 -DEBUG -g3 -ggdb -fno-pie" clean symlinks
62 @-scanelf -o /dev/null -BXxz permsx q
63
64 q: $(SRC) libq/*.c *.h libq/*.h
65 ifeq ($(subst s,,$(MAKEFLAGS)),$(MAKEFLAGS))
66 @printf ': %s ' $(APPLETS)
67 @echo ':'
68 ifndef V
69 @echo $(CC) $(CFLAGS) $(PYFLAGS) $(LDFLAGS) main.c -o q $(LIBADD)
70 endif
71 endif
72 $(Q)$(CC) $(WFLAGS) $(PYFLAGS) $(LDFLAGS) $(CFLAGS) $(CPPFLAGS) main.c -o q $(LIBADD)
73
74 .depend: $(SRC)
75 sed -n '/^DECLARE_APPLET/s:.*(\(.*\)).*:#include "\1.c":p' applets.h > include_applets.h
76 @#$(CC) $(CFLAGS) -MM $(SRC) > .depend
77 $(CC) $(CPPFLAGS) $(CFLAGS) -MM main.c > .depend
78
79 check: symlinks
80 $(MAKE) -C tests $@
81
82 dist:
83 ./make-tarball.sh $(PV)
84 distcheck: dist
85 rm -rf portage-utils-$(PV)
86 tar xf portage-utils-$(PV).tar.xz
87 $(MAKE) -C portage-utils-$(PV)
88 $(MAKE) -C portage-utils-$(PV) check
89 rm -rf portage-utils-$(PV)
90
91 clean:
92 -rm -f q $(APPLETS)
93 $(MAKE) -C tests clean
94 distclean: clean testclean
95 -rm -f *~ core .#*
96 -rm -f `find . -type l`
97
98 testclean:
99 cd tests && $(MAKE) clean
100
101 install: all
102 -$(MKDIR) $(PREFIX)/bin/
103 $(CP) q $(PREFIX)/bin/
104 if [ ! -d CVS ] ; then \
105 $(MKDIR) $(PREFIX)/share/man/man1/ ; \
106 for mpage in $(wildcard man/*.1) ; do \
107 [ -e $$mpage ] \
108 && cp $$mpage $(PREFIX)/share/man/man1/ || : ;\
109 done ; \
110 $(MKDIR) $(PREFIX)/share/doc/$(PF) ; \
111 for doc in $(DOCS) ; do \
112 cp $$doc $(PREFIX)/share/doc/$(PF)/ ; \
113 done ; \
114 fi
115 (cd $(PREFIX)/bin/ ; \
116 for applet in $(APPLETS); do \
117 [ ! -e "$$applet" ] && ln -s q $${applet} ; \
118 done \
119 )
120
121 man: q
122 cd man && ./mkman.sh
123
124 symlinks: all
125 ./q --install
126
127 -include .depend
128
129 .PHONY: all check clean debug dist distclean install man symlinks testclean
130
131 #
132 # All logic related to autotools is below here
133 #
134 GEN_MARK_START = \# @@@ GEN START @@@ \#
135 GEN_MARK_END = \# @@@ GEN START @@@ \#
136 EXTRA_DIST = \
137 $(SRC) \
138 qglsa.c \
139 $(wildcard libq/*.c *.h libq/*.h) \
140 $(shell find tests -type f '!' -ipath '*/CVS/*')
141 MAKE_MULTI_LINES = $(patsubst %,\\\\\n\t%,$(sort $(1)))
142 # 2nd level of indirection here is so the $(find) doesn't pick up
143 # files in EXTRA_DIST that get cleaned up ...
144 autotools-update: clean
145 $(MAKE) _autotools-update
146 _autotools-update:
147 sed -i '/^$(GEN_MARK_START)$$/,/^$(GEN_MARK_END)$$/d' Makefile.am
148 printf '%s\nq_CPPFLAGS += %b\ndist_man_MANS += %b\nAPPLETS += %b\nEXTRA_DIST += %b\n%s\n' \
149 "$(GEN_MARK_START)" \
150 "$(call MAKE_MULTI_LINES,$(APP_FLAGS))" \
151 "$(call MAKE_MULTI_LINES,$(wildcard man/*.1))" \
152 "$(call MAKE_MULTI_LINES,$(APPLETS))" \
153 "$(call MAKE_MULTI_LINES,$(EXTRA_DIST))" \
154 "$(GEN_MARK_END)" \
155 >> Makefile.am
156 autotools: autotools-update
157 ./autogen.sh --from=make
158
159 .PHONY: autotools autotools-update _autotools-update

  ViewVC Help
Powered by ViewVC 1.1.20