# 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
|