increasing the support of cross compiling
This commit is contained in:
parent
604670c981
commit
6bdff29b11
4 changed files with 43 additions and 54 deletions
|
@ -6,22 +6,30 @@ LWIPDIRS = lwip/src/api lwip/src/core lwip/src/core/ipv4 lwip/src/netif
|
|||
DRIVERDIRS = drivers/net drivers/char
|
||||
KERNDIRS = libkern kernel mm fs arch/$(ARCH)/kernel arch/$(ARCH)/mm $(LWIPDIRS) $(DRIVERDIRS)
|
||||
SUBDIRS = $(KERNDIRS)
|
||||
#OBJS = $(shell for i in $(KERNDIRS); do find $$i -name *.o; done)
|
||||
OBJCOPY = objcopy
|
||||
STRIP_DEBUG = --strip-debug
|
||||
KEEP_DEBUG = --only-keep-debug
|
||||
|
||||
CC_FOR_TARGET=gcc
|
||||
CXX_FOR_TARGET=g++
|
||||
GCC_FOR_TARGET=gcc
|
||||
AR_FOR_TARGET=ar
|
||||
AS_FOR_TARGET=as
|
||||
LD_FOR_TARGET=ld
|
||||
NM_FOR_TARGET=nm
|
||||
OBJDUMP_FOR_TARGET=objdump
|
||||
OBJCOPY_FOR_TARGET=objcopy
|
||||
RANLIB_FOR_TARGET=ranlib
|
||||
STRIP_FOR_TARGET=strip
|
||||
READELF_FOR_TARGET=readelf
|
||||
NASM = nasm
|
||||
|
||||
MAKE = make
|
||||
NASM = nasm
|
||||
NASMFLAGS = -felf32 -g
|
||||
INCLUDE = -I$(TOPDIR)/include -I$(TOPDIR)/arch/$(ARCH)/include -I$(TOPDIR)/lwip/src/include -I$(TOPDIR)/lwip/src/include/ipv4 -I$(TOPDIR)/drivers
|
||||
CC = gcc
|
||||
CFLAGS = -g -m32 -march=i586 -Wall -O2 -fno-zero-initialized-in-bss -fno-builtin -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc $(INCLUDE) -fno-stack-protector
|
||||
AR = ar
|
||||
ARFLAGS = rsv
|
||||
RM = rm -rf
|
||||
LD = ld
|
||||
LDFLAGS = -T link.ld -z max-page-size=4096 --defsym __BUILD_DATE=$(shell date +'%Y%m%d') --defsym __BUILD_TIME=$(shell date +'%H%M%S')
|
||||
STRIP_DEBUG = --strip-debug
|
||||
KEEP_DEBUG = --only-keep-debug
|
||||
|
||||
# Prettify output
|
||||
V = 0
|
||||
|
@ -34,31 +42,32 @@ default: all
|
|||
|
||||
all: newlib tools $(NAME)
|
||||
|
||||
#all:
|
||||
# for i in $(SUBDIRS); do $(MAKE) -C $$i all; done
|
||||
# $(MAKE) link
|
||||
|
||||
#link:
|
||||
# $(LD) $(LDFLAGS) -o $(NAME) $(OBJS)
|
||||
# $(OBJCOPY) $(KEEP_DEBUG) $(NAME) $(SYM_NAME)
|
||||
# $(OBJCOPY) $(STRIP_DEBUG) $(NAME)
|
||||
|
||||
newlib:
|
||||
$(MAKE) ARCH=$(ARCH) LDFLAGS="-m32" CFLAGS="-m32 -O2 -march=i586 -fno-stack-protector" NASMFLAGS="-felf32 -g" -C newlib
|
||||
$(MAKE) ARCH=$(ARCH) LDFLAGS="-m32" CFLAGS="-m32 -O2 -march=i586 -fno-stack-protector" NASMFLAGS="$(NASMFLAGS)" CC_FOR_TARGET=$(CC_FOR_TARGET) \
|
||||
CXX_FOR_TARGET=$(CXX_FOR_TARGET) \
|
||||
GCC_FOR_TARGET=$(GCC_FOR_TARGET) \
|
||||
AR_FOR_TARGET=$(AR_FOR_TARGET) \
|
||||
AS_FOR_TARGET=$(AS_FOR_TARGET) \
|
||||
LD_FOR_TARGET=$(LD_FOR_TARGET) \
|
||||
NM_FOR_TARGET=$(NM_FOR_TARGET) \
|
||||
OBJDUMP_FOR_TARGET=$(OBJDUMP_FOR_TARGET) \
|
||||
OBJCOPY_FOR_TARGET=$(OBJCOPY_FOR_TARGET) \
|
||||
RANLIB_FOR_TARGET=$(RANLIB_FOR_TARGET) \
|
||||
STRIP_FOR_TARGET=$(STRIP_FOR_TARGET) \
|
||||
READELF_FOR_TARGET=$(READELF_FOR_TARGET) -C newlib
|
||||
|
||||
tools:
|
||||
$(MAKE) -C tools
|
||||
|
||||
$(NAME):
|
||||
|
||||
$Q$(LD) $(LDFLAGS) -o $(NAME) $^
|
||||
$Q$(LD_FOR_TARGET) $(LDFLAGS) -o $(NAME) $^
|
||||
@echo [OBJCOPY] $(SYM_NAME)
|
||||
$Q$(OBJCOPY) $(KEEP_DEBUG) $(NAME) $(SYM_NAME)
|
||||
$Q$(OBJCOPY_FOR_TARGET) $(KEEP_DEBUG) $(NAME) $(SYM_NAME)
|
||||
@echo [OBJCOPY] $(NAME)
|
||||
$Q$(OBJCOPY) $(STRIP_DEBUG) $(NAME)
|
||||
$Q$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $(NAME)
|
||||
|
||||
qemu: newlib tools $(NAME)
|
||||
qemu -no-kvm -smp 2 -net nic,model=rtl8139 -net user,hostfwd=tcp::12345-:7 -net dump -kernel metalsvm.bin -initrd tools/initrd.img
|
||||
qemu -cpu pentium -smp 2 -net nic,model=rtl8139 -net user,hostfwd=tcp::12345-:7 -net dump -kernel metalsvm.bin -initrd tools/initrd.img
|
||||
|
||||
clean:
|
||||
$Q$(RM) $(NAME) $(SYM_NAME) *~
|
||||
|
@ -74,9 +83,9 @@ veryclean: clean
|
|||
|
||||
%.o : %.c
|
||||
@echo [CC] $@
|
||||
$Q$(CC) -c -D__KERNEL__ $(CFLAGS) -o $@ $<
|
||||
$Q$(CC_FOR_TARGET) -c -D__KERNEL__ $(CFLAGS) -o $@ $<
|
||||
@echo [DEP] $*.dep
|
||||
$Q$(CC) -MF $*.dep -MT $*.o -MM $(CFLAGS) $<
|
||||
$Q$(CC_FOR_TARGET) -MF $*.dep -MT $*.o -MM $(CFLAGS) $<
|
||||
|
||||
|
||||
%.o : %.asm
|
||||
|
|
|
@ -15,22 +15,6 @@ MKDIR = mkdir
|
|||
TMP = $(TOPDIR)/tmp
|
||||
OPT = --disable-shared --disable-multilib --enable-newlib-hw-fp
|
||||
|
||||
export CC_FOR_TARGET=gcc
|
||||
export CXX_FOR_TARGET=g++
|
||||
export GCC_FOR_TARGET=gcc
|
||||
export AR_FOR_TARGET=ar
|
||||
export AS_FOR_TARGET=as
|
||||
export LD_FOR_TARGET=ld
|
||||
export NM_FOR_TARGET=nm
|
||||
export OBJDUMP_FOR_TARGET=objdump
|
||||
export RANLIB_FOR_TARGET=ranlib
|
||||
export STRIP_FOR_TARGET=strip
|
||||
export READELF_FOR_TARGET=readelf
|
||||
export CFLAGS
|
||||
export CXXFLAGS=$(CFLAGS)
|
||||
export CPPFLAGS=$(CFLAGS)
|
||||
export NASMFLAGS
|
||||
|
||||
default: $(ARCH)
|
||||
$(MAKE) -C examples depend
|
||||
$(MAKE) CFLAGS+="-nostdinc -Wall -fno-builtin -I$(NEWLIB)/include -I../../include -I../../arch/$(ARCH)/include" LDFLAGS+="-nostdlib -L$(NEWLIB)/lib" -C examples
|
||||
|
|
|
@ -1,38 +1,34 @@
|
|||
ARCH = x86
|
||||
NEWLIB = ../x86/i586-metalsvm-elf32
|
||||
MAKE = make
|
||||
CC = gcc
|
||||
CFLAGS = -g -m32 -O2 -nostdinc -Wall -fno-builtin -I$(NEWLIB)/include -I../../include -I../../arch/$(ARCH)/include -fno-stack-protector
|
||||
LDFLAGS = -m32 -nostdlib -L$(NEWLIB)/lib
|
||||
OBJCOPY = objcopy
|
||||
STRIP_DEBUG = --strip-debug
|
||||
KEEP_DEBUG = --only-keep-debug
|
||||
|
||||
# other implicit rules
|
||||
%.o : %.c
|
||||
$(CC) -c $(CFLAGS) -o $@ $<
|
||||
$(CC_FOR_TARGET) -c $(CFLAGS) -o $@ $<
|
||||
|
||||
default: all
|
||||
|
||||
all: hello tests
|
||||
|
||||
tests: tests.o
|
||||
$(CC) -T link.ld -o $@ $(LDFLAGS) $<
|
||||
$(OBJCOPY) $(KEEP_DEBUG) $@ $@.sym
|
||||
$(OBJCOPY) $(STRIP_DEBUG) $@
|
||||
$(CC_FOR_TARGET) -T link.ld -o $@ $(LDFLAGS) $<
|
||||
$(OBJCOPY_FOR_TARGET) $(KEEP_DEBUG) $@ $@.sym
|
||||
$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@
|
||||
chmod a-x $@.sym
|
||||
|
||||
hello: hello.o
|
||||
$(CC) -T link.ld -o $@ $(LDFLAGS) $<
|
||||
$(OBJCOPY) $(KEEP_DEBUG) $@ $@.sym
|
||||
$(OBJCOPY) $(STRIP_DEBUG) $@
|
||||
$(CC_FOR_TARGET) -T link.ld -o $@ $(LDFLAGS) $<
|
||||
$(OBJCOPY_FOR_TARGET) $(KEEP_DEBUG) $@ $@.sym
|
||||
$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@
|
||||
chmod a-x $@.sym
|
||||
|
||||
clean:
|
||||
$(RM) hello tests *.sym *.o *~
|
||||
|
||||
depend:
|
||||
$(CC) -MM $(CFLAGS) *.c > Makefile.dep
|
||||
$(CC_FOR_TARGET) -MM $(CFLAGS) *.c > Makefile.dep
|
||||
|
||||
-include Makefile.dep
|
||||
# DO NOT DELETE
|
||||
|
|
|
@ -6,7 +6,7 @@ LDFLGAS =
|
|||
DEFINES=
|
||||
NASM = nasm
|
||||
NASMFLAGS = -fbin
|
||||
EXECFILES = $(shell find ../newlib/examples -executable -type f)
|
||||
EXECFILES = $(shell find ../newlib/examples -perm -o+r+x -type f)
|
||||
|
||||
# other implicit rules
|
||||
%.o : %.c
|
||||
|
|
Loading…
Add table
Reference in a new issue