blob: 1f372a68c3e05c248dce4c0523d94f0027266942 (
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
# Copyright 2003-2006 Ned Ludd <solar@linbsd.net>
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-projects/pax-utils/Makefile,v 1.76 2011/03/03 21:08:04 vapier 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)
####################################################################
# Avoid CC overhead when installing
ifneq ($(MAKECMDGOALS),install)
WFLAGS := -Wall -Wunused -Wimplicit -Wshadow -Wformat=2 \
-Wmissing-declarations -Wmissing-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, -Wstrict-overflow) \
$(call check-gcc, -Wextra)
endif
CFLAGS ?= -O2 -pipe
override CPPFLAGS += -D_GNU_SOURCE
LDFLAGS +=
LIBS :=
DESTDIR =
PREFIX := $(DESTDIR)/usr
STRIP := strip
MKDIR := mkdir -p
CP := cp
INS_EXE := install -m755
INS_DATA := install -m644
# Some fun settings
#CFLAGS += -DEBUG -g
#LDFLAGS += -pie
ifeq ($(USE_CAP),yes)
CPPFLAGS-pspax.c += -DWANT_SYSCAP
LIBS-pspax += -lcap
endif
ifdef PV
override CPPFLAGS += -DVERSION=\"$(PV)\"
endif
####################################################################
ELF_TARGETS = scanelf dumpelf $(shell echo | $(CC) -dM -E - | grep -q __svr4__ || echo pspax)
ELF_OBJS = paxelf.o
MACH_TARGETS = scanmacho
MACH_OBJS = paxmacho.o
COMMON_OBJS = paxinc.o xfuncs.o
TARGETS = $(ELF_TARGETS) $(MACH_TARGETS)
OBJS = $(ELF_OBJS) $(MACH_OBJS) $(COMMON_OBJS) $(TARGETS:%=%.o)
MPAGES = $(TARGETS:%=man/%.1)
SOURCES = $(OBJS:%.o=%.c)
all: $(OBJS) $(TARGETS)
@:
debug:
$(MAKE) CFLAGS="$(CFLAGS) -g3 -ggdb $(call check-gcc,-nopie)" clean all
@-/sbin/chpax -permsx $(ELF_TARGETS)
@-/sbin/paxctl -permsx $(ELF_TARGETS)
compile.c = $(CC) $(CFLAGS) $(CPPFLAGS) $(CPPFLAGS-$<) -o $@ -c $<
ifeq ($(V),)
Q := @
else
Q :=
endif
%.o: %.c
ifeq ($(V),)
@echo $(compile.c)
endif
$(Q)$(compile.c) $(WFLAGS)
$(ELF_TARGETS): %: $(ELF_OBJS) $(COMMON_OBJS) %.o
$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ $(LIBS) $(LIBS-$@)
$(MACH_TARGETS): %: $(MACH_OBJS) $(COMMON_OBJS) %.o
$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ $(LIBS) $(LIBS-$@)
%.so: %.c
$(CC) -shared -fPIC -o $@ $<
depend:
$(CC) $(CFLAGS) -MM $(SOURCES) > .depend
clean:
-rm -f $(OBJS) $(TARGETS)
distclean: clean
-rm -f *~ core *.o
-cd man && $(MAKE) clean
strip: all
$(STRIP) $(TARGETS)
strip-more:
$(STRIP) --strip-unneeded $(TARGETS)
install: all
$(MKDIR) $(PREFIX)/bin/ $(PREFIX)/share/man/man1/
for sh in *.sh ; do $(INS_EXE) $$sh $(PREFIX)/bin/$${sh%.sh} || exit $$? ; done
$(INS_EXE) $(TARGETS) $(PREFIX)/bin/
ifeq ($(S),)
$(MKDIR) $(PREFIX)/share/doc/pax-utils/
$(CP) README BUGS TODO $(PREFIX)/share/doc/pax-utils/
-$(INS_DATA) $(MPAGES) $(PREFIX)/share/man/man1/
else
$(INS_DATA) $(MPAGES) $(PREFIX)/share/man/man1/
endif
dist:
@if [ "$(PV)" = "" ] ; then \
echo "Please run 'make dist PV=<ver>'" ; \
exit 1 ; \
fi
rm -rf pax-utils-$(PV)
mkdir pax-utils-$(PV)
cp -a CVS pax-utils-$(PV)/
cd pax-utils-$(PV) && cvs up
echo "<releaseinfo>$(PV)</releaseinfo>" > pax-utils-$(PV)/man/fragment/version
$(MAKE) -C pax-utils-$(PV)/man
tar cf - pax-utils-$(PV) --exclude=CVS --exclude=.cvsignore | xz > pax-utils-$(PV).tar.xz
@printf "\n ..... Making sure clean cvs build works ..... \n\n"
unset CFLAGS; \
for t in all check clean debug check ; do \
$(MAKE) -C pax-utils-$(PV) $$t || exit $$? ; \
done
rm -rf pax-utils-$(PV)
du -b pax-utils-$(PV).tar.xz
-include .depend
check test:
$(MAKE) -C tests
.PHONY: all check clean dist install test
|