-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
118 lines (90 loc) · 2.91 KB
/
Makefile
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
VERSION=1.2pre
INSTALL_PREFIX ?= $(DESTDIR)
INSTALL_PREFIX ?= $(HOME)
CC := $(CROSS_COMPILE)$(CC)
LD := $(CROSS_COMPILE)$(LD)
CFLAGS = -Wall -W -g -O2 -I. -Iinclude/ -Wimplicit -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE
#CFLAGS += $(shell if $(CC) -m32 -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-m32"; fi)
CFLAGS += -Wdeclaration-after-statement
CFLAGS += -Wformat=2
CFLAGS += -Winit-self
CFLAGS += -Wlogical-op
CFLAGS += -Wnested-externs
CFLAGS += -Wpacked
CFLAGS += -Wshadow
CFLAGS += -Wstrict-aliasing=3
CFLAGS += -Wswitch-default
CFLAGS += -Wswitch-enum
CFLAGS += -Wundef
CFLAGS += -Wwrite-strings
# Only enabled during development.
CFLAGS += -Werror
V = @
Q = $(V:1=)
QUIET_CC = $(Q:@=@echo ' CC '$@;)
all: trinity
test:
@if [ ! -f config.h ]; then echo "[1;31mRun configure.sh first.[0m" ; exit; fi
MACHINE = $(shell $(CC) -dumpmachine)
SYSCALLS_ARCH = $(shell case "$(MACHINE)" in \
(sh*) echo syscalls/sh/*.c ;; \
(ia64*) echo syscalls/ia64/*.c ;; \
esac)
HEADERS = $(patsubst %.h,%.h,$(wildcard *.h)) $(patsubst %.h,%.h,$(wildcard syscalls/*.h)) $(patsubst %.h,%.h,$(wildcard ioctls/*.h))
SRCS = $(wildcard *.c) \
$(wildcard syscalls/*.c) \
$(SYSCALLS_ARCH) \
$(wildcard ioctls/*.c) \
$(wildcard net/*.c)
OBJS = $(patsubst %.c,%.o,$(wildcard *.c)) \
$(patsubst %.c,%.o,$(wildcard syscalls/*.c)) \
$(patsubst %.c,%.o,$(SYSCALLS_ARCH)) \
$(patsubst %.c,%.o,$(wildcard ioctls/*.c)) \
$(patsubst %.c,%.o,$(wildcard net/*.c))
DEPDIR= .deps
-include $(SRCS:%.c=$(DEPDIR)/%.d)
trinity: test $(OBJS) $(HEADERS)
$(QUIET_CC)$(CC) $(CFLAGS) -o trinity $(OBJS)
@mkdir -p tmp
df = $(DEPDIR)/$(*F)
# FIXME:
# Dependancy information for .c files in subdirs seems to be broken.
# Example: touch include/sanitise.h should cause syscalls/*.c to be rebuilt.
#
%.o : %.c
$(QUIET_CC)$(CC) $(CFLAGS) -o $@ -c $<
@gcc -MM $(CFLAGS) $*.c > $(df).d
@mv -f $(df).d $(df).d.tmp
@sed -e 's|.*:|$*.o:|' <$(df).d.tmp > $(df).d
@sed -e 's/.*://' -e 's/\\$$//' < $(df).d.tmp | fmt -1 | \
sed -e 's/^ *//' -e 's/$$/:/' >> $(df).d
@rm -f $(df).d.tmp
clean:
@rm -f $(OBJS)
@rm -f core.*
@rm -f trinity
@rm -f tags
@rm -f $(DEPDIR)/*.d
devel:
@perl -p -i -e 's/^#CFLAGS \+\= -Werror/CFLAGS += -Werror/' Makefile
@perl -p -i -e 's/DEVEL=0/DEVEL=1/' configure.sh
git commit Makefile -m "Enable -Werror"
release:
@perl -p -i -e 's/^CFLAGS \+\= -Werror/#CFLAGS += -Werror/' Makefile
@perl -p -i -e 's/DEVEL=1/DEVEL=0/' configure.sh
git commit Makefile -m "Disable -Werror"
tag:
git tag -a $(VERSION) -m "$(VERSION) release."
tarball:
git repack -a -d
git prune-packed
git archive --format=tar.gz --prefix=trinity-$(VERSION)/ HEAD > trinity-$(VERSION).tgz
install:
install -d -m 755 $(INSTALL_PREFIX)/bin
install trinity $(INSTALL_PREFIX)/bin
tags:
@ctags -R --exclude=tmp
mirror:
@git push --mirror [email protected]:kernelslacker/trinity.git
scan:
scan-build --use-analyzer=/usr/bin/clang make