Skip to content

Refactor makefile #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# The MIT License (MIT)
#
#
# Copyright (c) 2014 Kashyap
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand All @@ -23,6 +23,7 @@
include Rules.inc

all:
make SOURCE_ROOT=$$PWD -C boot/x86_64/
make SOURCE_ROOT=$$PWD -C kernel
make SOURCE_ROOT=$$PWD -C staging

Expand Down
6 changes: 5 additions & 1 deletion Rules.inc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

LD=ld
AR=ar
GCC=gcc
OBJCOPY=objcopy

QEMU=qemu-system-x86_64 -kernel staging/kernel.sys -serial stdio -vnc :1 -no-reboot -d int -s
LINUX_TARGET=x86_64-unknown-linux-gnu
MAC_TARGET=x86_64-apple-darwin
Expand All @@ -31,11 +34,12 @@ RUST_DIR=$(LINUX_RUST_DIR)
OBJDUMP=objdump
RUSTC=LD_LIBRARY_PATH=$(LINUX_RUST_DIR)/lib $(LINUX_RUST_DIR)/bin/rustc


OS=$(shell uname)
ifeq ($(OS), Darwin)
LD=$(LINKEDITOR)
AR=$(ARCHIVE)
GCC=$(CC)
OBJCOPY=$(OBJCPY)
LD_LIBRARY_PATH=DYLD_LIBRARY_PATH
QEMU=qemu-system-x86_64 -kernel staging/kernel.sys -serial stdio -no-reboot -d int
RUST_DIR=$(MAC_RUST_DIR)
Expand Down
25 changes: 14 additions & 11 deletions boot/x86_64/Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
all:
gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -MD -ggdb -fno-omit-frame-pointer -ffreestanding -fno-common -nostdlib -Iinclude -gdwarf-2 -m64 -DX64 -mcmodel=kernel -mtls-direct-seg-refs -mno-red-zone -O0 -fno-stack-protector -nostdinc -I. -o initcode.o -c initcode64.S
ld -m elf_x86_64 -nodefaultlibs -N -e start -Ttext 0 -o initcode.out initcode.o
objcopy -S -O binary initcode.out initcode
gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -MD -ggdb -fno-omit-frame-pointer -ffreestanding -fno-common -nostdlib -Iinclude -gdwarf-2 -m64 -DX64 -mcmodel=kernel -mtls-direct-seg-refs -mno-red-zone -O0 -fno-stack-protector -fno-pic -nostdinc -I. -o entryother.o -c entryother.S
ld -m elf_x86_64 -nodefaultlibs -N -e start -Ttext 0x7000 -o bootblockother.o entryother.o
objcopy -S -O binary -j .text bootblockother.o entryother
gcc -gdwarf-2 -Wa,-divide -Iinclude -m64 -DX64 -mcmodel=kernel -mtls-direct-seg-refs -mno-red-zone -c -o entry64.o entry64.S
gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -MD -ggdb -fno-omit-frame-pointer -ffreestanding -fno-common -nostdlib -Iinclude -gdwarf-2 -m64 -DX64 -mcmodel=kernel -mtls-direct-seg-refs -mno-red-zone -O0 -fno-stack-protector -c -o main.o main.c
#ld -m elf_x86_64 -nodefaultlibs -T kernel64.ld -o kernel.elf entry64.o main.o -b binary initcode entryother
include $(SOURCE_ROOT)/Rules.inc

GCCOPTS=-fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -MD -ggdb -fno-omit-frame-pointer \
-ffreestanding -fno-common -nostdlib -Iinclude -gdwarf-2 -m64 -DX64 -mcmodel=kernel \
-mtls-direct-seg-refs -mno-red-zone -O0 -fno-stack-protector -nostdinc -I.

all:
$(GCC) $(GCCOPTS) -o initcode.o -c initcode64.S
$(LD) -m elf_x86_64 -nodefaultlibs -N -e start -Ttext 0 -o initcode.out initcode.o
$(OBJCOPY) -S -O binary initcode.out initcode
$(GCC) $(GCCOPTS) -o entryother.o -c entryother.S
$(LD) -m elf_x86_64 -nodefaultlibs -N -e start -Ttext 0x7000 -o bootblockother.o entryother.o
$(OBJCOPY) -S -O binary -j .text bootblockother.o entryother
$(GCC) -gdwarf-2 -Wa,-divide -Iinclude -m64 -DX64 -mcmodel=kernel -mtls-direct-seg-refs -mno-red-zone -c -o entry64.o entry64.S
$(GCC) $(GCCOPTS) -c -o main.o main.c

clean:
rm -f initcode.o initcode.out initcode entryother.o entryother bootblockother.o entry64.o main.o kernel.elf *.d


run:
qemu-system-x86_64 -kernel kernel.elf -vnc :1 -no-reboot -d int -serial stdio
Binary file removed boot/x86_64/entry64.o
Binary file not shown.
Binary file removed boot/x86_64/main.o
Binary file not shown.