-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
166 lines (132 loc) · 3.19 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
MAKEFLAGS := -r -R --no-print-directory
ifeq ($(strip $(V)),)
E = @echo
Q = @
else
E = @\#
Q =
endif
FIND := find
CSCOPE := cscope
TAGS := ctags
RM := rm -f
CP := cp
LD := ld
CC := gcc
CD := cd
ECHO := echo
NM := nm
AWK := awk
SH := bash
MAKE := make
OBJCOPY := objcopy
MKDIR := mkdir
LN := ln
ESED := esed
SED := sed
CAT := cat
#
# Fetch ARCH from the uname if not yet set
#
ARCH ?= $(shell uname -m | sed \
-e s/i.86/i386/ \
-e s/sun4u/sparc64/ \
-e s/arm.*/arm/ \
-e s/sa110/arm/ \
-e s/s390x/s390/ \
-e s/parisc64/parisc/ \
-e s/ppc.*/powerpc/ \
-e s/mips.*/mips/ \
-e s/sh[234].*/sh/)
ifeq ($(ARCH),x86_64)
ARCH := x86
DEFINES := -DCONFIG_X86_64 -DARCH="\"$(ARCH)\""
LDARCH := i386:x86-64
endif
ifneq ($(ARCH),x86)
$(error "The architecture $(ARCH) isn't supported"))
endif
cflags-y += -iquote src/include
cflags-y += -fno-strict-aliasing
cflags-y += -I/usr/include
export cflags-y
VERSION_MAJOR := 0
VERSION_MINOR := 1
VERSION_SUBLEVEL := 0
VERSION_EXTRA :=
VERSION_NAME :=
export VERSION_MAJOR VERSION_MINOR VERSION_SUBLEVEL VERSION_EXTRA VERSION_NAME
include scripts/Makefile.version
include scripts/Makefile.config
LIBS := -lrt
DEFINES += -D_FILE_OFFSET_BITS=64
DEFINES += -D_GNU_SOURCE
WARNINGS := -Wall
ifneq ($(WERROR),0)
WARNINGS += -Werror
endif
ifeq ($(DEBUG),1)
DEFINES += -DCR_DEBUG
CFLAGS += -O0 -ggdb3
else
CFLAGS += -O2
endif
CFLAGS += $(WARNINGS) $(DEFINES)
export E Q CC ECHO MAKE CFLAGS LIBS ARCH DEFINES MAKEFLAGS
export SH RM OBJCOPY LDARCH LD CP MKDIR CD LN
export ESED SED CAT
include scripts/Makefile.rules
build := -r -R --no-print-directory -f scripts/Makefile.build makefile=Makefile obj
run := -r -R --no-print-directory
PROGRAM := compel
.PHONY: all clean tags docs
cflags-y += -iquote src/include
cflags-y += -iquote src/lib/arch/$(ARCH)/include
export cflags-y
#
# First order targets, usually pregenerated
EARLY-GEN := $(VERSION_HEADER) config
include Makefile.headers
include Makefile.plugins
include Makefile.devel
#
# The library command line tool is using
src/lib/%: $(EARLY-GEN)
$(Q) $(MAKE) $(build)=src/lib $@
src/lib/built-in.o: $(EARLY-GEN)
$(Q) $(MAKE) $(build)=src/lib all
#
# Source command line tool
src/%: $(EARLY-GEN)
$(Q) $(MAKE) $(build)=src $@
src/built-in.o: src $(EARLY-GEN)
$(Q) $(MAKE) $(build)=src all
$(all-plugins): | plugins-headers-prepare
$(PROGRAM): | src/lib/libcompel.so $(all-plugins)
$(PROGRAM): src/built-in.o
$(E) " LINK " $@
$(Q) $(CC) $(CFLAGS) $^ $(LIBS) -Lsrc/lib -lcompel -ldl -o $@
all: $(PROGRAM)
docs:
$(Q) $(MAKE) -s -C Documentation all
tags:
$(E) " GEN " $@
$(Q) $(RM) tags
$(Q) $(FIND) -L . -name '*.[hcS]' ! -path './.*' -print | xargs ctags -a
clean: clean-plugins clean-plugins-headers-prepared
$(Q) $(MAKE) $(build)=src clean
$(Q) $(MAKE) $(build)=src/lib clean
$(Q) $(MAKE) -s -C Documentation clean
$(Q) $(MAKE) -s -f test/Makefile clean
$(Q) $(RM) $(PROGRAM)
$(Q) $(RM) $(CONFIG)
$(Q) $(RM) $(VERSION_HEADER)
#
# Note we install development files into default
# directory here, so clean it up manually then!
test: | $(all-plugins)
test: | install-devel
test: $(PROGRAM)
$(Q) $(MAKE) -f test/Makefile all
.PHONY: test
.DEFAULT_GOAL := all