blob: 677ba9aa52f45b53807128343acf5b94895dd35c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
# Copyright 2005-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-projects/portage-utils/Makefile,v 1.53 2007/01/24 17:51:36 solar Exp $
####################################################################
check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
then echo "$(1)"; else echo "$(2)"; fi)
####################################################
WFLAGS := -Wall -Wunused -Wimplicit -Wshadow -Wformat=2 \
-Wmissing-declarations -Wno-missing-prototypes -Wwrite-strings \
-Wbad-function-cast -Wnested-externs -Wcomment -Winline \
-Wchar-subscripts -Wcast-align -Wno-format-nonliteral \
$(call check_gcc, -Wdeclaration-after-statement) \
$(call check-gcc, -Wsequence-point) \
$(call check-gcc, -Wextra)
CFLAGS ?= -O2 -pipe
CFLAGS += -funsigned-char
#CFLAGS += -DEBUG -g
#CFLAGS += -Os -DOPTIMIZE_FOR_SIZE=2 -falign-functions=2 -falign-jumps=2 -falign-labels=2 -falign-loops=2
#LDFLAGS := -pie
LDFLAGS += $(shell echo | $(CC) -dM -E - | grep -q ' __FreeBSD__' && echo '-lkvm')
DESTDIR :=
PREFIX := $(DESTDIR)/usr
STRIP := strip
MKDIR := mkdir -p
CP := cp
ifdef PV
HFLAGS += -DVERSION=\"$(PV)\"
else
PV := cvs
endif
ifndef PF
PF := portage-utils-$(PV)
endif
DOCS := TODO README qsync
ifdef PYTHON
PYFLAGS ?= $(shell python-config) -DWANT_PYTHON -ldl -pthread -lutil /usr/lib/libpython2.4.so
#PYFLAGS += -lpython2.4
endif
#####################################################
APPLETS := $(shell sed -n '/^DECLARE_APPLET/s:.*(\(.*\))$$:\1:p' applets.h|sort)
SRC := $(APPLETS:%=%.c) main.c
HFLAGS += $(foreach a,$(APPLETS),-DAPPLET_$a)
all: q
@true
debug:
$(MAKE) CFLAGS="$(CFLAGS) -DEBUG -g3 -ggdb -fno-pie" clean symlinks
@-/usr/bin/scanelf -o /dev/null -BXxz permsx q
q: $(SRC) libq/*.c *.h libq/*.h
ifeq ($(subst s,,$(MAKEFLAGS)),$(MAKEFLAGS))
@echo $(foreach a,$(APPLETS), : $a) :
@echo $(CC) $(CFLAGS) $(PYFLAGS) $(LDFLAGS) main.c -o q
endif
@$(CC) $(WFLAGS) $(PYFLAGS) $(LDFLAGS) $(CFLAGS) $(HFLAGS) main.c -o q
.depend: $(SRC)
sed -n '/^DECLARE_APPLET/s:.*(\(.*\)).*:#include "\1.c":p' applets.h > include_applets.h
@#$(CC) $(CFLAGS) -MM $(SRC) > .depend
$(CC) $(HFLAGS) $(CFLAGS) -MM main.c > .depend
check: symlinks
$(MAKE) -C tests $@
dist:
./make-tarball.sh $(PV)
distcheck: dist
set -e; \
dir=`mktemp distcheck.XXXXXX`; \
rm -f $$dir; \
mkdir $$dir; \
cd $$dir; \
tar jxf ../portage-utils-$(PV).tar.bz2; \
cd portage-utils-$(PV); \
$(MAKE); \
$(MAKE) check; \
cd ../..; \
rm -rf $$dir
clean:
-rm -f q
distclean: clean testclean
-rm -f *~ core
-rm -f `find . -type l`
testclean:
cd tests && $(MAKE) clean
install: all
-$(MKDIR) $(PREFIX)/bin/
$(CP) q $(PREFIX)/bin/
if [[ ! -d CVS ]] ; then \
$(MKDIR) $(PREFIX)/share/man/man1/ ; \
for mpage in $(wildcard man/*.1) ; do \
[ -e $$mpage ] \
&& cp $$mpage $(PREFIX)/share/man/man1/ || : ;\
done ; \
$(MKDIR) $(PREFIX)/share/doc/$(PF) ; \
for doc in $(DOCS) ; do \
cp $$doc $(PREFIX)/share/doc/$(PF)/ ; \
done ; \
fi
(cd $(PREFIX)/bin/ ; \
for applet in $(APPLETS); do \
[[ ! -e $$applet ]] && ln -s q $${applet} ; \
done \
)
man: q
cd man && ./mkman.sh
symlinks: all
./q --install
-include .depend
.PHONY: all check clean debug dist distclean install man symlinks testclean
|