summaryrefslogtreecommitdiff
blob: d9fbf17f45dd2f6bbbc33ca07ce7a2ef2b98dbc9 (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
include config.mak

DESTDIR :=

.PHONY: arch_clean clean

#make sure env CFLAGS variable is not used
CFLAGS =

libgcc := $(shell $(CC) --print-libgcc-file-name)

libcflat := test/lib/libcflat.a
cflatobjs := \
	test/lib/panic.o \
	test/lib/printf.o \
	test/lib/string.o

#include architecure specific make rules
include config-$(ARCH).mak

# cc-option
# Usage: OP_CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0)

cc-option = $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null \
              > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)

CFLAGS += -O1
CFLAGS += $(autodepend-flags) -g -fomit-frame-pointer -Wall
CFLAGS += $(call cc-option, -fno-stack-protector, "")
CFLAGS += $(call cc-option, -fno-stack-protector-all, "")
CFLAGS += -I../include
CFLAGS += -I ../libkvm

LDFLAGS += $(CFLAGS) -L ../libkvm

CXXFLAGS = $(autodepend-flags)

autodepend-flags = -MMD -MF $(dir $*).$(notdir $*).d

LDFLAGS += -pthread -lrt

kvmtrace_objs= kvmtrace.o

kvmctl: $(kvmctl_objs)
	$(CC) $(LDFLAGS) $^ -o $@

kvmtrace: $(kvmtrace_objs)
	$(CC) $(LDFLAGS) $^ -o $@

$(libcflat): $(cflatobjs)
	$(AR) rcs $@ $^

%.o: %.S
	$(CC) $(CFLAGS) -c -nostdlib -o $@ $^

-include .*.d

clean: arch_clean
	$(RM) kvmctl kvmtrace *.o *.a .*.d $(libcflat) $(cflatobjs)