2018-03-08 15:56:23 +00:00
|
|
|
# Copyright (C) 2018 Ortega Froysa, Nicolás <nortega@themusicinnoise.net>
|
|
|
|
# Author: Ortega Froysa, Nicolás <nortega@themusicinnoise.net>
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2018-03-08 15:53:29 +00:00
|
|
|
# General options
|
|
|
|
TARGET=i686
|
|
|
|
ARCH=$(shell echo $(TARGET) | sed s/i.86/x86/)
|
|
|
|
# Assembly options
|
2018-03-14 18:07:46 +00:00
|
|
|
AS=i686-elf-as
|
|
|
|
AFLAGS=
|
2018-03-08 15:53:29 +00:00
|
|
|
# C options
|
2018-03-14 18:07:46 +00:00
|
|
|
CC=i686-elf-gcc
|
2018-03-08 15:53:29 +00:00
|
|
|
CFLAGS?=-O0 -g
|
2018-03-14 18:07:46 +00:00
|
|
|
CFLAGS:=$(CFLAGS) -std=gnu99 -ffreestanding -Wall -Wextra -Isrc/
|
2018-03-08 15:53:29 +00:00
|
|
|
# Linker options
|
|
|
|
LDFLAGS?=-O0
|
2018-03-14 18:07:46 +00:00
|
|
|
LDFLAGS:=$(LDFLAGS) -ffreestanding -nostdlib
|
|
|
|
LIBS=-lgcc
|
2018-03-08 15:53:29 +00:00
|
|
|
|
|
|
|
# Binary variables
|
|
|
|
OBJS=src/kernel/arch/$(ARCH)/boot.o src/kernel/kernel.o src/kernel/arch/$(ARCH)/tty.o
|
|
|
|
|
2018-03-11 16:47:43 +00:00
|
|
|
colonel.bin: $(OBJS)
|
2018-03-08 15:53:29 +00:00
|
|
|
$(CC) -T src/kernel/arch/$(ARCH)/linker.ld -o $@ $(LDFLAGS) $^ $(LIBS)
|
|
|
|
|
|
|
|
%.o: %.c
|
|
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
|
|
|
|
%.o: %.s
|
|
|
|
$(AS) $(AFLAGS) $< -o $@
|
|
|
|
|
|
|
|
.PHONY: all build-iso clean clean-all
|
2018-03-11 16:47:43 +00:00
|
|
|
all: colonel.bin
|
2018-03-08 15:53:29 +00:00
|
|
|
|
2018-03-11 16:47:43 +00:00
|
|
|
build-iso: colonel.iso
|
2018-03-08 15:53:29 +00:00
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -f $(OBJS)
|
|
|
|
rm -rf isodir
|
|
|
|
|
|
|
|
clean-all: clean
|
|
|
|
rm -f *.iso *.bin
|
|
|
|
|
2018-03-11 16:47:43 +00:00
|
|
|
colonel.iso: colonel.bin
|
2018-03-08 15:53:29 +00:00
|
|
|
mkdir -p isodir/boot/grub/
|
|
|
|
cp configs/grub.cfg isodir/boot/grub/
|
|
|
|
cp $< isodir/boot/
|
|
|
|
grub-mkrescue -o $@ isodir
|