From 86d5df015d83b0c8ed38e8ee9267367c00c8b107 Mon Sep 17 00:00:00 2001 From: Yanyan Jiang Date: Sun, 21 May 2017 11:48:42 -0400 Subject: [PATCH] new makefile works --- Makefile | 4 ++-- Makefile.app | 5 ++--- Makefile.check | 5 +++-- Makefile.lib | 1 - am/Makefile | 2 +- am/arch/mips32-minimal/img/build | 2 +- am/arch/mips32-npc/img/build | 2 +- am/arch/x86-qemu/img/build | 8 ++++---- apps/litenes/Makefile | 3 +++ 9 files changed, 17 insertions(+), 15 deletions(-) create mode 100644 apps/litenes/Makefile diff --git a/Makefile b/Makefile index 0a0c13a0..98d537b9 100644 --- a/Makefile +++ b/Makefile @@ -5,8 +5,8 @@ AM_HOME ?= $(shell pwd) .PHONY: all clean all: - @cd am && build ARCH=$(ARCH) - @cd klib && build ARCH=$(ARCH) + @cd am && make ARCH=$(ARCH) + @cd klib && make ARCH=$(ARCH) clean: @cd am && make clean diff --git a/Makefile.app b/Makefile.app index ded385e9..585ef708 100644 --- a/Makefile.app +++ b/Makefile.app @@ -1,4 +1,4 @@ -.DEFAULTGOAL = app +.DEFAULT_GOAL = app $(info Building $(NAME) [$(ARCH)]) include $(AM_HOME)/Makefile.check @@ -15,8 +15,7 @@ include $(AM_HOME)/Makefile.compile .PHONY: app clean app: $(OBJS) @cd $(AM_HOME) && make ARCH=$(ARCH) - @$(AM_HOME)/am/arch/$(ARHC)/img/build $(BINARY) $(AM_HOME)/am/build/am-$(ARCH).a $(AM_HOME)/klib/build/klib-$(ARCH).a $(OBJS) - @echo "Hello" + @$(AM_HOME)/am/arch/$(ARCH)/img/build $(BINARY) $(AM_HOME)/am/build/am-$(ARCH).a $(AM_HOME)/klib/build/klib-$(ARCH).a $(OBJS) clean: rm -rf $(APP_DIR)/build/ diff --git a/Makefile.check b/Makefile.check index 42c3d526..1791c997 100644 --- a/Makefile.check +++ b/Makefile.check @@ -1,4 +1,5 @@ +ifneq ($(MAKECMDGOALS),clean) ifndef ARCH -$(error "ARCH must be defined") +$(error variable ARCH must be defined) +endif endif - diff --git a/Makefile.lib b/Makefile.lib index f2d99634..30d0230a 100644 --- a/Makefile.lib +++ b/Makefile.lib @@ -14,7 +14,6 @@ include $(AM_HOME)/Makefile.compile .PHONY: lib lib: $(ARCHIVE) - @echo "Done" $(ARCHIVE): $(OBJS) ar rcs $(ARCHIVE) $(OBJS) diff --git a/am/Makefile b/am/Makefile index 4ae71330..9dbb61c4 100644 --- a/am/Makefile +++ b/am/Makefile @@ -1,3 +1,3 @@ NAME = am -SRCS = $(shell find -L ./arch/$(ARCH)/ -name "*.c" -o -name "*.cpp" -o -name "*.S") +SRCS = $(shell find -L ./arch/$(ARCH)/src/ -name "*.c" -o -name "*.cpp" -o -name "*.S") include $(AM_HOME)/Makefile.lib diff --git a/am/arch/mips32-minimal/img/build b/am/arch/mips32-minimal/img/build index 416cb4ac..004675e4 100755 --- a/am/arch/mips32-minimal/img/build +++ b/am/arch/mips32-minimal/img/build @@ -1,6 +1,6 @@ #!/bin/bash -DIR=./am/arch/mips32-minimal/img +DIR=${AM_HOME}/am/arch/mips32-minimal/img DEST=$1 shift diff --git a/am/arch/mips32-npc/img/build b/am/arch/mips32-npc/img/build index f086a238..1088bb08 100755 --- a/am/arch/mips32-npc/img/build +++ b/am/arch/mips32-npc/img/build @@ -1,6 +1,6 @@ #!/bin/bash -DIR=./am/arch/mips32-npc/img +DIR=${AM_HOME}/am/arch/mips32-npc/img DEST=$1 shift diff --git a/am/arch/x86-qemu/img/build b/am/arch/x86-qemu/img/build index 70ced3b2..e7d9ff46 100755 --- a/am/arch/x86-qemu/img/build +++ b/am/arch/x86-qemu/img/build @@ -1,10 +1,10 @@ #!/bin/bash -DIR=./am/arch/x86-qemu/img +DIR=${AM_HOME}/am/arch/x86-qemu/img DEST=$1 shift -ld -melf_i386 -Ttext 0x00100000 -o ./build/kernel.o --start-group $@ --end-group -bash -c "cd $DIR/boot && make" -cat "$DIR/boot/mbr" ./build/kernel.o > ${DEST} +ld -melf_i386 -Ttext 0x00100000 -o ${DEST}.o --start-group $@ --end-group && \ +bash -c "cd $DIR/boot && make" && \ +cat "$DIR/boot/mbr" ${DEST}.o > ${DEST} diff --git a/apps/litenes/Makefile b/apps/litenes/Makefile new file mode 100644 index 00000000..46e55365 --- /dev/null +++ b/apps/litenes/Makefile @@ -0,0 +1,3 @@ +NAME = litenes +SRCS = $(shell find -L ./src/ -name "*.c" -o -name "*.cpp" -o -name "*.S") +include $(AM_HOME)/Makefile.app