-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split out the kernel build to get smaller makefiles. Some configure simplifications.
- Loading branch information
Showing
5 changed files
with
148 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,9 @@ | ||
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" | ||
CWD=`pwd -P` | ||
if [ ! -f configure ]; then | ||
ln -sf "$SCRIPTPATH"/makefile makefile | ||
echo "srcdir = $SCRIPTPATH" >config.mak | ||
|
||
mkdir fdpp 2>/dev/null | ||
cd fdpp | ||
echo "srcdir = $SCRIPTPATH/fdpp" >config.mak | ||
mkdir thunk_gen 2>/dev/null | ||
cd thunk_gen | ||
echo "srcdir = $SCRIPTPATH/fdpp/thunk_gen" >config.mak | ||
ln -sf "$SCRIPTPATH"/fdpp/thunk_gen/makefile makefile | ||
"$SCRIPTPATH/fdpp"/configure | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" | ||
|
||
do_sub() { | ||
mkdir $1 2>/dev/null | ||
cd $1 | ||
echo "srcdir = $SCRIPTPATH/$1" >config.mak | ||
ln -sf "$SCRIPTPATH/$1"/makefile makefile | ||
cd .. | ||
} | ||
|
||
TOPDIR=`realpath "$SCRIPTPATH/.."` | ||
if [ ! -f configure ]; then | ||
ln -sf "$SCRIPTPATH"/makefile makefile | ||
echo "srcdir = $SCRIPTPATH" >config.mak | ||
mkdir thunk_gen 2>/dev/null | ||
cd thunk_gen | ||
echo "srcdir = $SCRIPTPATH/thunk_gen" >config.mak | ||
ln -sf "$SCRIPTPATH"/thunk_gen/makefile makefile | ||
|
||
do_sub thunk_gen | ||
do_sub kernel | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
T = .. | ||
-include config.mak | ||
-include $(T)/local.mak | ||
srcdir ?= $(CURDIR) | ||
|
||
include $(srcdir)/$(T)/defs.mak | ||
include $(srcdir)/$(T)/clang.mak | ||
|
||
TOP = $(abspath $(srcdir)/$(T)/..) | ||
HDR = $(TOP)/hdr | ||
SRC = $(TOP)/kernel | ||
PPINC = $(TOP)/include/fdpp | ||
AVER = $(shell echo FDPP_API_VER | cpp -include $(PPINC)/thunks.h - | tail -n 1) | ||
BVER = $(shell echo BPRM_VER | cpp -include $(PPINC)/bprm.h - | tail -n 1) | ||
TARGET=fdppkrnl.$(AVER).$(BVER) | ||
|
||
NASMFLAGS += -i$(SRC) -i$(HDR) -f elf32 | ||
|
||
ASMS = kernel.asm entry.asm io.asm console.asm serial.asm printer.asm \ | ||
execrh.asm nlssupt.asm procsupt.asm dosidle.asm int2f.asm \ | ||
nls_hc.asm intr.asm irqstack.asm \ | ||
cpu.asm | ||
DASMS = floppy.asm rdpcclk.asm wrpcclk.asm wratclk.asm | ||
OBJS = $(ASMS:.asm=.o) | ||
DOBJS = $(DASMS:.asm=.o) | ||
PPASMS = plt.S cdata.S | ||
PPOBJS = $(PPASMS:.S=.o) | ||
|
||
# *Explicit Rules* | ||
|
||
ALL = $(T)/$(TARGET).elf $(T)/$(TARGET).map | ||
|
||
all: $(ALL) | ||
|
||
want_loadaddr = 0 | ||
ifeq ($(want_loadaddr),1) | ||
LA = --defsym=loadaddr=0xfa100 | ||
else | ||
LA = --emit-relocs | ||
endif | ||
want_pie = 0 | ||
ifeq ($(want_pie),1) | ||
PF = -pie | ||
endif | ||
|
||
# New makes have a way to avoid parallel invocation with the use of &: | ||
# On old make you would write "%.elf %.map :" which is a bit silly | ||
# given the names are fixed. Also $(TARGET).% won't work that way at all: | ||
# you need to explicitly list all files that are created simultaneously, | ||
# and yet use pattern in all of them. | ||
DEPS_OF_ELF = $(srcdir)/$(T)/kernel.ld $(OBJS) $(PPOBJS) $(DOBJS) | ||
need = 4.3 | ||
ifneq ($(filter $(need),$(firstword $(sort $(MAKE_VERSION) $(need)))),) | ||
$(T)/$(TARGET).elf $(T)/$(TARGET).map &: $(DEPS_OF_ELF) | ||
else | ||
$(T)/%.elf $(T)/%.map : $(DEPS_OF_ELF) | ||
endif | ||
$(CROSS_LD) -melf_i386 -static -Map=$(T)/$(TARGET).map -o $(T)/$(TARGET).elf \ | ||
$(LA) $(PF) $(^:%.ld=-T%.ld) | ||
chmod -x $(T)/$(TARGET).elf | ||
|
||
clean: | ||
-$(RM) .tstamp *.inc *.o *.tmp $(GEN_ASMS) | ||
|
||
# *Individual File Dependencies* | ||
#apisupt.o: $(SRC)/apisupt.asm $(SRC)/segs.inc | ||
console.o: $(SRC)/console.asm $(SRC)/io.inc | ||
cpu.o: $(SRC)/cpu.asm $(SRC)/segs.inc | ||
dosidle.o: $(SRC)/dosidle.asm $(SRC)/segs.inc | ||
entry.o: $(SRC)/entry.asm $(SRC)/segs.inc $(HDR)/stacks.inc | ||
execrh.o: $(SRC)/execrh.asm $(SRC)/segs.inc | ||
int2f.o: $(SRC)/int2f.asm $(SRC)/segs.inc $(HDR)/stacks.inc | ||
intr.o: $(SRC)/intr.asm $(SRC)/segs.inc | ||
io.o: $(SRC)/io.asm $(SRC)/segs.inc $(HDR)/stacks.inc | ||
irqstack.o: $(SRC)/irqstack.asm $(SRC)/segs.inc | ||
kernel.o: $(SRC)/kernel.asm $(SRC)/segs.inc | ||
nls_hc.o: $(SRC)/nls_hc.asm $(SRC)/segs.inc | ||
nlssupt.o: $(SRC)/nlssupt.asm $(SRC)/segs.inc $(HDR)/stacks.inc | ||
printer.o: $(SRC)/printer.asm $(SRC)/io.inc | ||
procsupt.o: $(SRC)/procsupt.asm $(SRC)/segs.inc $(HDR)/stacks.inc | ||
serial.o: $(SRC)/serial.asm $(SRC)/io.inc | ||
|
||
GEN_ASMS = plt.asm cdata.asm | ||
GEN_TMP = thunk_calls.tmp plt.inc | ||
|
||
$(OBJS): %.o: $(SRC)/%.asm makefile | ||
$(NASM) $(NASMFLAGS) -o $@ $< | ||
|
||
$(DOBJS): %.o: $(SRC)/drivers/%.asm makefile | ||
$(NASM) $(NASMFLAGS) -o $@ $< | ||
|
||
$(PPOBJS): %.o: %.asm makefile | ||
$(NASM) $(NASMFLAGS) -o $@ $< | ||
|
||
plt.o: plt.asm plt.inc $(SRC)/segs.inc | ||
|
||
plt.asm: $(srcdir)/$(T)/plt.S $(SRC)/glob_asm.h $(TOP)/include/fdpp/bprm.h \ | ||
$(srcdir)/$(T)/thunks_priv.h $(srcdir)/makefile | ||
$(CPP) -iquote $(PPINC) -P $< >$@ || ($(RM) $@ ; false) | ||
|
||
GIT_DESCRIBE := $(shell git describe) | ||
|
||
cdata.asm: $(srcdir)/$(T)/cdata.S $(HDR)/version.h $(GIT_REV) $(srcdir)/makefile | ||
$(CPP) $(CPPFLAGS) -DKERNEL_VERSION="$(VERSION) [GIT: $(GIT_DESCRIBE)]" \ | ||
-P $< | sed 's/" "/","/g' >$@ | ||
|
||
thunk_calls.tmp: $(SRC)/proto.h | ||
srcdir=$(srcdir)/$(T)/parsers CPP="$(CPP)" \ | ||
$(srcdir)/$(T)/parsers/parse_decls.sh 1 $< >$@ || \ | ||
($(RM) $@ ; false) | ||
plt.inc: thunk_calls.tmp | ||
$(srcdir)/$(T)/parsers/parse_decls.sh 3 $< >$@ || \ | ||
($(RM) $@ ; false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters