wangzhengquan
2020-10-13 0da7d09982d61ea6864cec53e2341b51b30cf208
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
# Common make definitions, customized for each platform
 
 
 
# Cross-compiler jos toolchain
#
# This Makefile will automatically use the cross-compiler toolchain
# installed as 'i386-jos-elf-*', if one exists.  If the host tools ('gcc',
# 'objdump', and so forth) compile for a 32-bit x86 ELF target, that will
# be detected as well.  If you have the right compiler toolchain installed
# using a different name, set GCCPREFIX explicitly in conf/env.mk
 
# try to infer the correct GCCPREFIX
ifndef GCCPREFIX
GCCPREFIX := $(shell if i386-jos-elf-objdump -i 2>&1 | grep '^elf32-i386$$' >/dev/null 2>&1; \
    then echo 'i386-jos-elf-'; \
    elif objdump -i 2>&1 | grep 'elf32-i386' >/dev/null 2>&1; \
    then echo ''; \
    else echo "***" 1>&2; \
    echo "*** Error: Couldn't find an i386-*-elf version of GCC/binutils." 1>&2; \
    echo "*** Is the directory with i386-jos-elf-gcc in your PATH?" 1>&2; \
    echo "*** If your i386-*-elf toolchain is installed with a command" 1>&2; \
    echo "*** prefix other than 'i386-jos-elf-', set your GCCPREFIX" 1>&2; \
    echo "*** environment variable to that prefix and run 'make' again." 1>&2; \
    echo "*** To turn off this error, run 'gmake GCCPREFIX= ...'." 1>&2; \
    echo "***" 1>&2; exit 1; fi)
endif
 
# Definitions required in all program directories to compile and link
# C programs using gcc.
DEBUG=y
CC = g++
# COMPILE.c = $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
# LINK.c = $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
 
# preprocessor options 
CPPFLAGS += $(INCLUDES) -std=c++11
# compilation options
CFLAGS += $(DEBUGFLAGS) -Wall -DLINUX -D_GNU_SOURCE $(EXTRA)
# linked options
LDFLAGS +=
 
 
LDDIR += -L$(ROOT)/lib
LDLIBS += $(RPATH) $(LDDIR) $(EXTRALIBS)
 
INCLUDES += -I. -I./include -I$(ROOT)/include
 
DEST=$(ROOT)/build
# DEST=.
 
ifeq ($(DEBUG),y)
  DEBUGFLAGS = -O -g # "-O" is needed to expand inlines
else
  DEBUGFLAGS = -O2
endif
 
 
 
RANLIB=echo
AR=ar
AWK=awk
NM    := $(GCCPREFIX)nm
 
# Common temp files to delete from each directory.
TEMPFILES=core core.* *.o temp.* *.out *.a *.so *.sym