BarryServer : Git

All the code for all my projects
// BarryServer : Git / Orion / blob / 1628fcfdfdf2978ed9ccac96ee7d13bb3dc43a01 / Makefile

// Related

Orion

Barry Importing existing Orion kernel d41a53c (2 years, 4 months ago)
PRODUCT=orion

CC=i686-orion-gcc
CFLAGS=-ffreestanding -fno-pie #-I${SYSROOT}/usr/include/

AS=nasm
AFLAGS=-f elf32

LD=i686-orion-gcc
LFLAGS=-T linker.ld -ffreestanding -nostdlib

AS_SOURCES := $(shell find . -name '*.S')
OBJS = $(sort $(subst ./,build/,$(subst .S,.o,$(AS_SOURCES))))

C_SOURCES := $(shell find . -name '*.c')
OBJS += $(sort $(subst ./,build/,$(subst .c,.o,$(C_SOURCES))))

.PHONY: clean all install

all: $(PRODUCT)

clean:
	@echo "REMOVING OBJECT FILES"
	@mkdir -p build
	@rm -rf build
	@touch $(PRODUCT)
	@rm $(PRODUCT)

install: $(PRODUCT)
	@echo "INSTALLING $^"
	@install -Dm 755 $(PRODUCT) -t ${SYSROOT}/boot/

$(PRODUCT): $(OBJS)
	@echo "LINKING $@"
	@$(LD) -o $@ $^ $(LFLAGS)

build/%.o: %.c
	@echo "COMPILING $<"
	@mkdir -p $(@D)
	@$(CC) -c $< -o $@ $(CFLAGS)

build/%.o: %.S
	@echo "ASSEMBLING $<"
	@mkdir -p $(@D)
	@$(AS) $< -o $@ $(AFLAGS)