set mmap sizes to something more interesting
[trinity.git] / Makefile
bloba0d7dde7ecdf67203b17def8c47dc7e02a6b97c3
1 VERSION=1.3pre
3 INSTALL_PREFIX ?= $(DESTDIR)
4 INSTALL_PREFIX ?= $(HOME)
6 CC := gcc
7 CC := $(CROSS_COMPILE)$(CC)
8 LD := $(CROSS_COMPILE)$(LD)
10 CFLAGS := -Wall -W -g -O2 -I. -Iinclude/ -Wimplicit -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE
11 ifneq ($(SYSROOT),)
12 CFLAGS += --sysroot=$(SYSROOT)
13 endif
14 #CFLAGS += $(shell if $(CC) -m32 -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-m32"; fi)
15 CFLAGS += -Wdeclaration-after-statement
16 CFLAGS += -Wformat=2
17 CFLAGS += -Winit-self
18 CFLAGS += -Wlogical-op
19 CFLAGS += -Wnested-externs
20 CFLAGS += -Wpacked
21 CFLAGS += -Wshadow
22 CFLAGS += -Wstrict-aliasing=3
23 CFLAGS += -Wswitch-default
24 CFLAGS += -Wswitch-enum
25 CFLAGS += -Wundef
26 CFLAGS += -Wwrite-strings
27 CFLAGS += -Wstrict-prototypes -Wmissing-prototypes
29 # Only enabled during development.
30 CFLAGS += -Werror
32 V = @
33 Q = $(V:1=)
34 QUIET_CC = $(Q:@=@echo ' CC '$@;)
37 all: trinity
39 test:
40 @if [ ! -f config.h ]; then echo "\e[1;31mRun configure.sh first.\e[0m" ; exit; fi
43 MACHINE = $(shell $(CC) -dumpmachine)
44 SYSCALLS_ARCH = $(shell case "$(MACHINE)" in \
45 (sh*) echo syscalls/sh/*.c ;; \
46 (ia64*) echo syscalls/ia64/*.c ;; \
47 esac)
49 HEADERS = $(patsubst %.h,%.h,$(wildcard *.h)) $(patsubst %.h,%.h,$(wildcard syscalls/*.h)) $(patsubst %.h,%.h,$(wildcard ioctls/*.h))
51 SRCS = $(wildcard *.c) \
52 $(wildcard children/*.c) \
53 $(wildcard ioctls/*.c) \
54 $(wildcard net/*.c) \
55 $(wildcard syscalls/*.c) \
56 $(SYSCALLS_ARCH)
58 OBJS = $(sort $(patsubst %.c,%.o,$(wildcard *.c))) \
59 $(sort $(patsubst %.c,%.o,$(wildcard children/*.c))) \
60 $(sort $(patsubst %.c,%.o,$(wildcard ioctls/*.c))) \
61 $(sort $(patsubst %.c,%.o,$(wildcard net/*.c))) \
62 $(sort $(patsubst %.c,%.o,$(wildcard syscalls/*.c))) \
63 $(sort $(patsubst %.c,%.o,$(SYSCALLS_ARCH)))
65 DEPDIR= .deps
67 -include $(SRCS:%.c=$(DEPDIR)/%.d)
69 trinity: test $(OBJS) $(HEADERS)
70 $(QUIET_CC)$(CC) $(CFLAGS) -o trinity $(OBJS)
71 @mkdir -p tmp
73 df = $(DEPDIR)/$(*D)/$(*F)
75 %.o : %.c
76 $(QUIET_CC)$(CC) $(CFLAGS) -o $@ -c $<
77 @mkdir -p $(DEPDIR)/$(*D)
78 @gcc -MM $(CFLAGS) $*.c > $(df).d
79 @mv -f $(df).d $(df).d.tmp
80 @sed -e 's|.*:|$*.o:|' <$(df).d.tmp > $(df).d
81 @sed -e 's/.*://' -e 's/\\$$//' < $(df).d.tmp | fmt -1 | \
82 sed -e 's/^ *//' -e 's/$$/:/' >> $(df).d
83 @rm -f $(df).d.tmp
85 clean:
86 @rm -f $(OBJS)
87 @rm -f core.*
88 @rm -f trinity
89 @rm -f tags
90 @rm -rf $(DEPDIR)/*
92 devel:
93 @perl -p -i -e 's/^#CFLAGS \+\= -Werror/CFLAGS += -Werror/' Makefile
94 @perl -p -i -e 's/DEVEL=0/DEVEL=1/' configure.sh
95 git commit Makefile -m "Enable -Werror"
97 release:
98 @perl -p -i -e 's/^CFLAGS \+\= -Werror/#CFLAGS += -Werror/' Makefile
99 @perl -p -i -e 's/DEVEL=1/DEVEL=0/' configure.sh
100 git commit Makefile -m "Disable -Werror"
102 tag:
103 git tag -a $(VERSION) -m "$(VERSION) release."
105 tarball:
106 git repack -a -d
107 git prune-packed
108 git archive --format=tar.gz --prefix=trinity-$(VERSION)/ HEAD > trinity-$(VERSION).tgz
110 install: trinity
111 install -d -m 755 $(INSTALL_PREFIX)/bin
112 install trinity $(INSTALL_PREFIX)/bin
114 tags: $(SRCS)
115 @ctags -R --exclude=tmp
117 mirror:
118 @git push --mirror git@github.com:kernelslacker/trinity.git
120 scan:
121 scan-build --use-analyzer=/usr/bin/clang make
123 coverity:
124 rm -rf cov-int trinity-coverity.tgz
125 cov-build --dir cov-int make
126 tar czvf trinity-coverity.tgz cov-int