[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: someone make me understand make please
From: |
Paul Smith |
Subject: |
Re: someone make me understand make please |
Date: |
Sun, 05 Aug 2007 17:17:28 -0400 |
On Sun, 2007-08-05 at 21:35 +0100, Martin Knappe wrote:
> To be honest, I've tried so many combinations of $, `` and stuff that I
> just didn't know which of all the version (that didn't work out) I
> should have posted :-) They all had different bugs..
> Yeah, sorry, 512.bin depends on boot.bin, not on boot.bin.bin (typo)
> Couldnt you just tell me how YOU would write the Makefile to do what I
> want so I can see clearer ,please?
Please reply to the list, not to me privately: if you send it to the
list others besides me can help, plus other people reading the archives
can see the entire thread.
This is how I would write it:
# How we compute the size of the boot file
BOOT_SIZE = `stat -c %s boot.bin`
512.bin: 512.asm Makefile boot.bin
-rm $@
BOOT_SIZE=$(BOOT_SIZE) nasm -f bin $< -o $@
boot.bin: main.o video.o utilities.o Makefile
ld $(filter %.o,$^) -e start -N -M > boot.mem -o $@ --oformat
binary -T script
ndisasm -b 32 $@ > boot.ndisasm
size=$(BOOT_SIZE); blocks=`expr $$size / 512`; \
dd if=/dev/null of=gdt.bin seek=`expr $$blocks + 1`
count=1
If you know for a fact that your /bin/sh will be POSIX compliant, and
will grok the POSIX $(...) alternative to ``, then you can simplify
things a bit:
# How we compute the size of the boot file
BOOT_SIZE = $$(stat -c %s boot.bin)
512.bin: 512.asm Makefile boot.bin
-rm $@
BOOT_SIZE=$(BOOT_SIZE) nasm -f bin $< -o $@
boot.bin: main.o video.o utilities.o Makefile
ld $(filter %.o,$^) -e start -N -M > boot.mem -o $@ --oformat
binary -T script
ndisasm -b 32 $@ > boot.ndisasm
dd if=/dev/null of=gdt.bin seek=$$(expr $$(expr $(BOOT_SIZE) /
512) + 1) count=1
And, if you know that your /bin/sh will be a POSIX shell, and will grok
the POSIX $(( ... )) math expression, you can do even better:
# How we compute the size of the boot file
BOOT_SIZE = $$(stat -c %s boot.bin)
512.bin: 512.asm Makefile boot.bin
-rm $@
BOOT_SIZE=$(BOOT_SIZE) nasm -f bin $< -o $@
boot.bin: main.o video.o utilities.o Makefile
ld $(filter %.o,$^) -e start -N -M > boot.mem -o $@ --oformat
binary -T script
ndisasm -b 32 $@ > boot.ndisasm
dd if=/dev/null of=gdt.bin seek=$$(( ($(BOOT_SIZE) / 512) + 1
)) count=1
--
-------------------------------------------------------------------------------
Paul D. Smith <address@hidden> Find some GNU make tips at:
http://www.gnu.org http://make.paulandlesley.org
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist