12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- #
- # Makefile
- #
- # Copyright (C) 2016 Aleksandar Andrejevic <theflash@sdf.lonestar.org>
- #
- # This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU Affero 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 Affero General Public License for more details.
- #
- # You should have received a copy of the GNU Affero General Public License
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
- #
- # Settings
- DEBUG = yes
- ACPICA = yes
- # Compilers and tools
- CC = i686-elf-gcc
- ASM = nasm
- LINK = i686-elf-ld
- # Directories
- SRCDIR = src
- OBJDIR = obj
- DEPDIR = dep
- LIBGCC_DIR = $(shell $(CC) -print-file-name=)
- # Flags
- CFLAGS = -Wall -Werror -Wno-strict-aliasing -ffreestanding -nostdlib -I include
- ASMFLAGS = -felf
- LDFLAGS = -T link.ld -L $(LIBGCC_DIR) -lgcc
- ifeq ($(DEBUG), yes)
- CFLAGS += -g
- else
- CFLAGS += -O3
- endif
- # Input and output files
- SOURCES = $(wildcard $(SRCDIR)/*.c)
- SOURCES += $(wildcard $(SRCDIR)/exec/*.c)
- SOURCES += $(shell find $(SRCDIR)/drivers -type f -name \*.c)
- SOURCES += $(wildcard $(SRCDIR)/*.asm)
- ifeq ($(ACPICA), yes)
- CFLAGS += -I include/acpica -D ACPICA
- SOURCES += $(shell find $(SRCDIR)/acpica -type f -name \*.c)
- endif
- DEPENDS = $(shell find $(DEPDIR) -type f -name \*.d)
- OBJECTS = $(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.o, $(patsubst $(SRCDIR)/%.asm, $(OBJDIR)/%.o, $(SOURCES)))
- .PHONY: all clean
- all: $(OBJDIR) $(DEPDIR) monolithium
- clean:
- find $(OBJDIR) -name \*.o -delete
- find $(DEPDIR) -name \*.d -delete
- rm monolithium
- -include $(DEPENDS)
- $(OBJDIR):
- mkdir -p $(OBJDIR)
- $(DEPDIR):
- mkdir -p $(DEPDIR)
- $(OBJDIR)/%.o: $(SRCDIR)/%.c Makefile
- mkdir -p $(dir $@)
- mkdir -p $(dir $(@:$(OBJDIR)/%.o=$(DEPDIR)/%.d))
- $(CC) $(CFLAGS) -MMD -MP -MF $(@:$(OBJDIR)/%.o=$(DEPDIR)/%.d) -o $@ -c $<
- $(OBJDIR)/%.o: $(SRCDIR)/%.asm
- mkdir -p $(dir $@)
- $(ASM) $(ASMFLAGS) -o $@ $<
- monolithium: $(OBJDIR)/boot/boot.o $(OBJECTS)
- $(LINK) -o $@ $(OBJECTS) $(LDFLAGS)
|