Build chain tweaks and cleanup
This commit is contained in:
parent
6c36d3dd40
commit
fc54366eec
30
Makefile
30
Makefile
@ -3,25 +3,26 @@ $(error BUILDROOT IS NOT SET!)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
TARGET := x86_64-elf
|
TARGET := x86_64-elf
|
||||||
KERNELMAKE := TARGET=${TARGET} $(MAKE) -C src/kernel
|
MAKE.kernel := TARGET=${TARGET} $(MAKE) -C src/kernel
|
||||||
LIBMAKE := TARGET=${TARGET} $(MAKE) -C src/libmittos
|
MAKE.libmittos := TARGET=${TARGET} $(MAKE) -C src/libmittos
|
||||||
|
|
||||||
DIST := $(BUILDROOT)/mittos.iso
|
DIST := $(BUILDROOT)/mittos.iso
|
||||||
SYSROOT := $(BUILDROOT)/sysroot
|
SYSROOT := $(BUILDROOT)/sysroot
|
||||||
SYS_ITEMS := $(SYSROOT)/kernel $(SYSROOT)/usr/lib/libc.a $(SYSROOT)/usr/lib/libmittos.a
|
|
||||||
|
|
||||||
all: $(SYSROOT)/kernel $(SYS_ITEMS)
|
|
||||||
|
all: kernel
|
||||||
|
|
||||||
|
|
||||||
dist: $(DIST)
|
dist: $(DIST)
|
||||||
|
$(DIST): kernel
|
||||||
$(DIST): $(SYS_ITEMS)
|
|
||||||
$(BUILDROOT)/toolchain/setup-grub.sh
|
$(BUILDROOT)/toolchain/setup-grub.sh
|
||||||
grub-mkrescue -o $@ $(SYSROOT)
|
grub-mkrescue -o $@ $(SYSROOT)
|
||||||
|
|
||||||
|
|
||||||
kernel: $(SYSROOT)/kernel
|
kernel: $(SYSROOT)/kernel
|
||||||
$(SYSROOT)/kernel: $(SYSROOT)/usr/lib/libc.a $(SYSROOT)/usr/lib/libmittos.a FORCE
|
$(SYSROOT)/kernel: musllib libmittos FORCE
|
||||||
ifeq ($(shell make -sqC src/kernel install || echo 1), 1)
|
ifeq ($(shell $(MAKE.kernel) -sq install || echo 1), 1)
|
||||||
$(KERNELMAKE) install
|
$(MAKE.kernel) install
|
||||||
endif
|
endif
|
||||||
|
|
||||||
musllib: $(SYSROOT)/usr/lib/libc.a
|
musllib: $(SYSROOT)/usr/lib/libc.a
|
||||||
@ -30,17 +31,18 @@ $(SYSROOT)/usr/lib/libc.a:
|
|||||||
|
|
||||||
libmittos: $(SYSROOT)/usr/lib/libmittos.a
|
libmittos: $(SYSROOT)/usr/lib/libmittos.a
|
||||||
$(SYSROOT)/usr/lib/libmittos.a: FORCE
|
$(SYSROOT)/usr/lib/libmittos.a: FORCE
|
||||||
ifeq ($(shell make -sqC src/libmittos install || echo 1), 1)
|
ifeq ($(shell $(MAKE.libmittos) -sq install || echo 1), 1)
|
||||||
$(LIBMAKE) install
|
$(MAKE.libmittos) install
|
||||||
endif
|
endif
|
||||||
|
|
||||||
.PHONY: all dist sysroot FORCE
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(DIST)
|
rm -rf $(DIST)
|
||||||
$(KERNELMAKE) clean
|
$(MAKE.kernel) clean
|
||||||
$(LIBMAKE) clean
|
$(MAKE.libmittos) clean
|
||||||
|
|
||||||
distclean:
|
distclean:
|
||||||
$(MAKE) clean
|
$(MAKE) clean
|
||||||
rm -rf $(SYSROOT)
|
rm -rf $(SYSROOT)
|
||||||
|
|
||||||
|
.PHONY: all dist sysroot FORCE
|
@ -20,23 +20,27 @@ kernel: $(OBJ)
|
|||||||
%.o: %.S.py
|
%.o: %.S.py
|
||||||
python3 $^ | $(COMPILE.S) $(DEPFLAGS) -x assembler-with-cpp - -o $@
|
python3 $^ | $(COMPILE.S) $(DEPFLAGS) -x assembler-with-cpp - -o $@
|
||||||
|
|
||||||
|
|
||||||
# Automatic dependency tracking
|
# Automatic dependency tracking
|
||||||
DEP := $(OBJ:.o=.d)
|
DEP := $(OBJ:.o=.d)
|
||||||
DEPFLAGS = -MT $@ -MMD -MP -MF $*.d
|
DEPFLAGS = -MT $@ -MMD -MP -MF $*.d
|
||||||
$(OBJ): CPPFLAGS += $(DEPFLAGS)
|
$(OBJ): CPPFLAGS += $(DEPFLAGS)
|
||||||
%.d: ;
|
%.d: ;
|
||||||
|
|
||||||
|
|
||||||
|
# Installation
|
||||||
DESTDIR ?= $(BUILDROOT)/sysroot
|
DESTDIR ?= $(BUILDROOT)/sysroot
|
||||||
|
|
||||||
$(DESTDIR)$(PREFIX)/kernel: kernel
|
$(DESTDIR)/kernel: kernel
|
||||||
install -D $< $@
|
install -D $< $@
|
||||||
|
|
||||||
install: $(DESTDIR)$(PREFIX)/kernel
|
install: $(DESTDIR)/kernel
|
||||||
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(OBJ) $(DEP) kernel
|
rm -rf $(OBJ) $(DEP) kernel
|
||||||
|
|
||||||
.PHONY: install
|
.PHONY: install clean
|
||||||
|
|
||||||
# Include automatic dependency rules
|
# Include automatic dependency rules
|
||||||
include $(DEP)
|
include $(DEP)
|
@ -1,12 +1,9 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <multiboot.h>
|
||||||
#include <cpu.h>
|
#include <cpu.h>
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <terminal.h>
|
#include <terminal.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <multiboot.h>
|
|
||||||
#include <interrupts.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <proc.h>
|
#include <proc.h>
|
||||||
|
|
||||||
void TEMP_test_scheduler();
|
void TEMP_test_scheduler();
|
||||||
|
@ -6,7 +6,6 @@ CC := ${TARGET}-gcc
|
|||||||
|
|
||||||
SRC := $(shell find -type f -name '*.[cS]*')
|
SRC := $(shell find -type f -name '*.[cS]*')
|
||||||
OBJ := $(patsubst %, %.o, $(basename $(basename $(SRC))))
|
OBJ := $(patsubst %, %.o, $(basename $(basename $(SRC))))
|
||||||
|
|
||||||
HDR := $(shell find -type f -name '*.h')
|
HDR := $(shell find -type f -name '*.h')
|
||||||
|
|
||||||
CFLAGS := -Wall -Wextra -pedantic -ffreestanding -mcmodel=large -std=c2x
|
CFLAGS := -Wall -Wextra -pedantic -ffreestanding -mcmodel=large -std=c2x
|
||||||
@ -18,15 +17,19 @@ LDFLAGS := -nostdlib -r
|
|||||||
libmittos.a: $(OBJ)
|
libmittos.a: $(OBJ)
|
||||||
$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
|
$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
|
||||||
|
|
||||||
|
|
||||||
# Automatic dependency tracking
|
# Automatic dependency tracking
|
||||||
DEP := $(OBJ:.o=.d)
|
DEP := $(OBJ:.o=.d)
|
||||||
DEPFLAGS = -MT $@ -MMD -MP -MF $*.d
|
DEPFLAGS = -MT $@ -MMD -MP -MF $*.d
|
||||||
$(OBJ): CPPFLAGS += $(DEPFLAGS)
|
$(OBJ): CPPFLAGS += $(DEPFLAGS)
|
||||||
%.d: ;
|
%.d: ;
|
||||||
|
|
||||||
|
|
||||||
|
# Installation
|
||||||
DESTDIR ?= $(BUILDROOT)/sysroot
|
DESTDIR ?= $(BUILDROOT)/sysroot
|
||||||
LIBDIR := $(DESTDIR)/usr/lib
|
LIBDIR := $(DESTDIR)/usr/lib
|
||||||
INCDIR := $(DESTDIR)/usr/include/mittos
|
INCDIR := $(DESTDIR)/usr/include/mittos
|
||||||
|
|
||||||
$(LIBDIR)/libmittos.a: libmittos.a
|
$(LIBDIR)/libmittos.a: libmittos.a
|
||||||
install -D $< $@
|
install -D $< $@
|
||||||
|
|
||||||
@ -38,9 +41,11 @@ install: install-headers $(LIBDIR)/libmittos.a
|
|||||||
|
|
||||||
install-headers: $(HDR:./include/%=$(INCDIR)/%)
|
install-headers: $(HDR:./include/%=$(INCDIR)/%)
|
||||||
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(OBJ) $(DEP) libmittos.a
|
rm -rf $(OBJ) $(DEP) libmittos.a
|
||||||
|
|
||||||
.PHONY: install install-headers
|
.PHONY: install install-headers clean
|
||||||
|
|
||||||
# Include automatic dependency rules
|
# Include automatic dependency rules
|
||||||
include $(DEP)
|
include $(DEP)
|
@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
|
|
||||||
target=x86_64-elf
|
TARGET=x86_64-elf
|
||||||
SYSROOT=/opt/sysroot
|
SYSROOT=/opt/sysroot
|
||||||
|
|
||||||
# Pull or update musl libc
|
# Pull or update musl libc
|
||||||
@ -10,12 +10,14 @@ cd musl
|
|||||||
git reset --hard
|
git reset --hard
|
||||||
git pull
|
git pull
|
||||||
|
|
||||||
|
# Apply patches
|
||||||
[ -d /opt/src/patch-musl ] && rsync -a /opt/src/patch-musl/ /opt/external/musl/
|
[ -d /opt/src/patch-musl ] && rsync -a /opt/src/patch-musl/ /opt/external/musl/
|
||||||
|
|
||||||
|
# Build and install
|
||||||
mkdir -p /opt/external/build-musl && cd /opt/external/build-musl
|
mkdir -p /opt/external/build-musl && cd /opt/external/build-musl
|
||||||
rm -r *
|
rm -r *
|
||||||
../musl/configure \
|
../musl/configure \
|
||||||
--target=${target} \
|
--target=${TARGET} \
|
||||||
--prefix=${SYSROOT}/usr \
|
--prefix=${SYSROOT}/usr \
|
||||||
--disable-shared \
|
--disable-shared \
|
||||||
--enable-debug \
|
--enable-debug \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user