From a9d826c3175227a08f503056d791f36f85928e06 Mon Sep 17 00:00:00 2001 From: Jenny Curle Date: Mon, 1 Apr 2019 01:40:42 +0000 Subject: [PATCH] Hardcode target in makefile --- makefile | 188 +++++++++++++++++++++++++++---------------------------- 1 file changed, 94 insertions(+), 94 deletions(-) diff --git a/makefile b/makefile index 8796645..9d0aa01 100755 --- a/makefile +++ b/makefile @@ -1,94 +1,94 @@ -DEFAULT_HOST!=../default-host.sh -HOST?=DEFAULT_HOST -HOSTARCH!=../target_to_arch.sh $(HOST) - -CFLAGS?= -O2 -g -CPPFLAGS?= -LDFLAGS?= -LIBS?= - -DESTDIR?= -PREFIX?=/usr/local -EXEC_PREFIX?=$(PREFIX) -BOOTDIR?=$(EXEC_PREFIX)/boot -INCLUDEDIR?=$(PREFIX)/include - -CFLAGS:=$(CFLAGS) -ffreestanding -Wall -Wextra -CPPFLAGS:=$(CPPFLAGS) -D__is_kernel -Iinclude -LDFLAGS:=$(LDFLAGS) -LIBS:=$(LIBS) -nostdlib -lk -lgcc - -ARCHDIR=arch/$(HOSTARCH) - -include $(ARCHDIR)/make.config - -CFLAGS:=$(CFLAGS) $(KERNEL_ARCH_CFLAGS) -CPPFLAGS:=$(CPPFLAGS) $(KERNEL_ARCH_CPPFLAGS) -LDFLAGS:=$(LDFLAGS) $(KERNEL_ARCH_LDFLAGS) -LIBS:=$(LIBS) $(KERNEL_ARCH_LIBS) - -KERNEL_OBJS=\ -$(KERNEL_ARCH_OBJS)\ -kernel/kernel.o - -OBJS=\ -$(ARCHDIR)/crti.o \ -$(ARCHDIR)/crtbegin.o \ -$(KERNEL_OBJS) \ -$(ARCHDIR)/crtend.o \ -$(ARCHDIR)/crtn.o - -LINK_LIST=\ -$(LDFLAGS) \ -$(ARCHDIR)/crti.o \ -$(ARCHDIR)/crtbegin.o \ -$(KERNEL_OBJS) \ -$(LIBS) \ -$(ARCHDIR)/crtend.o \ -$(ARCHDIR)/crtn.o - -.PHONY: all clean install install-headers install-kernel -.SUFFIXES: .o .c .s - -all: red.kernel - -red.kernel: $(OBJS) $(ARCHDIR)/linker.ld - $(CC) -T $(ARCHDIR)/linker.ld -o $@ $(CFLAGS) $(LINK_LIST) - -$(ARCHDIR)/crtbegin.o $(ARCHDIR)/crtend.o: - OBJ=`$(CC) $(CFLAGS) $(LDFLAGS) -print-file-name=$(@F)` && cp "$$OBJ" $@ - -.c.o: - $(CC) -MD -c $< -o $@ -std=gnull $(CFLAGS) $(CPPFLAGS) -.s.o: - $(CC) -MD -c $< -o $@ $(CFLAGS) $(CPPFLAGS) - -clean: - rm -f red.kernel - rm -f $(OBJS) *.0 */*.o */*/*.o - rm -f $(OBJS:.o=.d) *.d */*.d */*/*.d - -install: install-headers install-kernel gen-iso - -install-headers: - mkdir -p $(DESTDIR)$(INCLUDEDIR) - cp -R --preserve=timestamps include/. $(DESTDIR)$(INCLUDEDIR)/. - -install-kernel: red.kernel - mkdir -p $(DESTDIR)$(BOOTDIR) - cp red.kernel $(DESTDIR)$(BOOTDIR) - -gen-iso: - rm -f red.iso \ - cp red.kernel iso/boot/kernel.elf \ - genisoimage -R\ - -b boot/grub/stage2_eltorito\ - -no-emul-boot\ - -A ProjectRED\ - -input-charset utf8\ - -quiet - -boot-info-table\ - -o red.iso\ - iso - --include $(OBJS:.o=.d) +DEFAULT_HOST!=i686-elf +HOST?=DEFAULT_HOST +HOSTARCH!=i386 + +CFLAGS?= -O2 -g +CPPFLAGS?= +LDFLAGS?= +LIBS?= + +DESTDIR?= +PREFIX?=/usr/local +EXEC_PREFIX?=$(PREFIX) +BOOTDIR?=$(EXEC_PREFIX)/boot +INCLUDEDIR?=$(PREFIX)/include + +CFLAGS:=$(CFLAGS) -ffreestanding -Wall -Wextra +CPPFLAGS:=$(CPPFLAGS) -D__is_kernel -Iinclude +LDFLAGS:=$(LDFLAGS) +LIBS:=$(LIBS) -nostdlib -lk -lgcc + +ARCHDIR=arch/$(HOSTARCH) + +include $(ARCHDIR)/make.config + +CFLAGS:=$(CFLAGS) $(KERNEL_ARCH_CFLAGS) +CPPFLAGS:=$(CPPFLAGS) $(KERNEL_ARCH_CPPFLAGS) +LDFLAGS:=$(LDFLAGS) $(KERNEL_ARCH_LDFLAGS) +LIBS:=$(LIBS) $(KERNEL_ARCH_LIBS) + +KERNEL_OBJS=\ +$(KERNEL_ARCH_OBJS)\ +kernel/kernel.o + +OBJS=\ +$(ARCHDIR)/crti.o \ +$(ARCHDIR)/crtbegin.o \ +$(KERNEL_OBJS) \ +$(ARCHDIR)/crtend.o \ +$(ARCHDIR)/crtn.o + +LINK_LIST=\ +$(LDFLAGS) \ +$(ARCHDIR)/crti.o \ +$(ARCHDIR)/crtbegin.o \ +$(KERNEL_OBJS) \ +$(LIBS) \ +$(ARCHDIR)/crtend.o \ +$(ARCHDIR)/crtn.o + +.PHONY: all clean install install-headers install-kernel +.SUFFIXES: .o .c .s + +all: red.kernel + +red.kernel: $(OBJS) $(ARCHDIR)/linker.ld + $(CC) -T $(ARCHDIR)/linker.ld -o $@ $(CFLAGS) $(LINK_LIST) + +$(ARCHDIR)/crtbegin.o $(ARCHDIR)/crtend.o: + OBJ=`$(CC) $(CFLAGS) $(LDFLAGS) -print-file-name=$(@F)` && cp "$$OBJ" $@ + +.c.o: + $(CC) -MD -c $< -o $@ -std=gnull $(CFLAGS) $(CPPFLAGS) +.s.o: + $(CC) -MD -c $< -o $@ $(CFLAGS) $(CPPFLAGS) + +clean: + rm -f red.kernel + rm -f $(OBJS) *.0 */*.o */*/*.o + rm -f $(OBJS:.o=.d) *.d */*.d */*/*.d + +install: install-headers install-kernel gen-iso + +install-headers: + mkdir -p $(DESTDIR)$(INCLUDEDIR) + cp -R --preserve=timestamps include/. $(DESTDIR)$(INCLUDEDIR)/. + +install-kernel: red.kernel + mkdir -p $(DESTDIR)$(BOOTDIR) + cp red.kernel $(DESTDIR)$(BOOTDIR) + +gen-iso: + rm -f red.iso \ + cp red.kernel iso/boot/kernel.elf \ + genisoimage -R\ + -b boot/grub/stage2_eltorito\ + -no-emul-boot\ + -A ProjectRED\ + -input-charset utf8\ + -quiet + -boot-info-table\ + -o red.iso\ + iso + +-include $(OBJS:.o=.d)