help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: someone make me understand make please


From: Martin Knappe
Subject: Re: someone make me understand make please
Date: Sun, 05 Aug 2007 23:26:14 +0100
User-agent: Thunderbird 1.5.0.12 (X11/20070604)

Thanks! That did the trick. I still don't understand make though; I really would like too. Where are these things described? There are a couple make tutorials on the net, but as I see it, they all don't go beyond very simple things. Then there is this O'Reilly book about make, but I'm not sure if it's any good. The make manual is definitely not very instructive :-(
Know any good resource?

Thanks again

Martin

Paul Smith wrote:
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






reply via email to

[Prev in Thread] Current Thread [Next in Thread]