Re-organized the files for readability.
This commit is contained in:
parent
37bff866a8
commit
f0f1892c8c
31
Makefile
31
Makefile
|
@ -7,29 +7,12 @@ help: ## Print this help message
|
|||
sort -nr | head -1) && \
|
||||
perl -ne "m/^((\w|-)*):.*##\s*(.*)/ && print(sprintf(\"%s: %s\t%s\n\", \$$1, \" \"x($$M-length(\$$1)), \$$3))" Makefile
|
||||
|
||||
hello32: hello32.s ## Build the 32 bit version of Project 2
|
||||
nasm -f elf hello32.s
|
||||
ld -m elf_i386 -o hello32 hello32.o
|
||||
|
||||
hello64: hello64.s ## Build the 32 bit version of Project 2
|
||||
nasm -f elf64 hello64.s
|
||||
ld -o hello64 hello64.o
|
||||
|
||||
counted-hello32: counted-hello32.s ## Build the 32 bit version of Project 3
|
||||
nasm -f elf counted-hello32.s
|
||||
ld -m elf_i386 -o counted-hello32 counted-hello32.o
|
||||
|
||||
counted-hello64: counted-hello64.s ## Build the 32 bit version of Project 3
|
||||
nasm -f elf64 counted-hello64.s
|
||||
ld -o counted-hello64 counted-hello64.o
|
||||
|
||||
subroutine-hello32: subroutine-hello32.s ## Build the 32 bit version of Project 3
|
||||
nasm -f elf subroutine-hello32.s
|
||||
ld -m elf_i386 -o subroutine-hello32 subroutine-hello32.o
|
||||
|
||||
subroutine-hello64: subroutine-hello64.s ## Build the 32 bit version of Project 3
|
||||
nasm -f elf64 subroutine-hello64.s
|
||||
ld -o subroutine-hello64 subroutine-hello64.o
|
||||
all: ## Make everything in all trees
|
||||
cd x86 && make all
|
||||
cd x86_64 && make all
|
||||
|
||||
clean: ## Delete all built and intermediate features
|
||||
rm -f hello32 hello64 counted-hello32 counted-hello64 *.o
|
||||
cd x86 && make clean
|
||||
cd x86_64 && make clean
|
||||
|
||||
include ./makefiles/help.make
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
run-help: ## Print this help message
|
||||
@M=$$(perl -ne 'm/^((\w|-)*):.*##/ && print length($$1)."\n"' Makefile | \
|
||||
sort -nr | head -1) && \
|
||||
perl -ne "m/^((\w|-)*):.*##\s*(.*)/ && print(sprintf(\"%s: %s\t%s\n\", \$$1, \" \"x($$M-length(\$$1)), \$$3))" Makefile
|
|
@ -0,0 +1,31 @@
|
|||
NASM=nasm
|
||||
LD=ld
|
||||
COMPILE_32=elf
|
||||
|
||||
# LD often has several different linking modes. This sets the mode
|
||||
# explicitly, but if you're running on 32-bit Linux LD will use this
|
||||
# mode by default and the '-m' argument is unnecessary.
|
||||
LINK_32=elf_i386
|
||||
|
||||
default: help
|
||||
|
||||
all: hello strlen subroutines ## Build everything at once
|
||||
|
||||
%.o: %.s
|
||||
$(NASM) -f $(COMPILE_32) $<
|
||||
|
||||
hello: hello.o ## Build Lesson 2: Print string with known length, exit cleanly
|
||||
$(LD) -m $(LINK_32) -o $@ $<
|
||||
|
||||
strlen: strlen.o ## Build Lesson 2: Determine length programmatically
|
||||
$(LD) -m $(LINK_32) -o $@ $<
|
||||
|
||||
subroutines: subroutines.o ## Build Lesson 3: Separate strlen() and puts() into subroutine.
|
||||
$(LD) -m $(LINK_32) -o $@ $<
|
||||
|
||||
help: run-help ## Print this helpful message (default)
|
||||
|
||||
clean:
|
||||
rm -f hello strlen subroutines *.o
|
||||
|
||||
include ../makefiles/help.make
|
|
@ -0,0 +1,32 @@
|
|||
NASM=nasm
|
||||
LD=ld
|
||||
COMPILE_64=elf64
|
||||
|
||||
# LD often has several different linking modes. This sets the mode
|
||||
# explicitly, but if you're running on 64-bit Linux LD will use this
|
||||
# mode by default and the '-m' argument is unnecessary.
|
||||
LINK_64=elf_x86_64
|
||||
|
||||
default: help
|
||||
|
||||
all: hello strlen subroutines ## Build everything at once
|
||||
|
||||
%.o: %.s
|
||||
$(NASM) -f $(COMPILE_64) $<
|
||||
|
||||
hello: hello.o ## Build Lesson 2: Print string with known length, exit cleanly
|
||||
$(LD) -m $(LINK_64) -o $@ $<
|
||||
|
||||
strlen: strlen.o ## Build Lesson 2: Determine length programmatically
|
||||
$(LD) -m $(LINK_64) -o $@ $<
|
||||
|
||||
subroutines: subroutines.o ## Build Lesson 3: Separate strlen() and puts() into subroutine.
|
||||
$(LD) -m $(LINK_64) -o $@ $<
|
||||
|
||||
help: run-help ## Print this helpful message (default)
|
||||
|
||||
clean:
|
||||
rm -f hello strlen subroutines *.o
|
||||
|
||||
include ../makefiles/help.make
|
||||
|
Loading…
Reference in New Issue