help-make
[Top][All Lists]
Advanced

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

Re: output of a command


From: Martin Knappe
Subject: Re: output of a command
Date: Sun, 22 Jul 2007 15:43:15 +0100
User-agent: Thunderbird 1.5.0.12 (X11/20070604)


Ultimately, make is just a tool for invoking commands -- specifically
shell commands.  So just break each of those steps down into a shell
script or shell fragment that does what you want.  Remember that if you
want to do more than one thing in a shell fragment, you need to specify
it as one line to make using continuation-\ since otherwise make invokes
each command in a new shell process.  And secondly remember that if you
want to reference a $var in the shell fragment you need to use $$ so
that it's not interpreted as a make variable.

Something like this (untested):

.SUFFIXES: .asm .o .bin
.PHONY: all

all: binarydisk.bin

%.bin: %.asm
        $(AS) $< -o $@

foo1.bin: foo1.asm

foo2.bin: foo2.asm foo1.bin
        $(AS) -DFOO=`stat -c %s $(word 2,$^)` $< -o $@
        # or:
        # env FOO=`stat -c %s $(word 2,$^)` $(AS) $< -o $@

sectorsize := 512

binarydisk.bin: foo1.bin foo2.bin
        len=`stat -c %s $(word 1,$^)`; \
        start=`expr $$len / $(sectorsize)`; \
        if [ `expr $$len % $(sectorsize)` != 0 ]; then \
          start=`expr $$start + 1`; \
        fi; \
        dd if=$(word 1,$^) of=$@ bs=$(sectorsize) && \
        dd if=$(word 2,$^) of=$@ bs=$(sectorsize) seek=$$start

Brian

I tried with your hints but it still doesnt work...I was trying to follow your example (leaving out all the cryptic stuff), this is how far I've got:

SECTOR_SIZE=512

all:
   make bootdisk.bin
bootdisk.bin: 512.bin
   -rm bootdisk.bin
   touch bootdisk.bin
   dd if=512.bin of=bootdisk.bin count=1 seek=0
dd if=gdt.bin of=bootdisk.bin count=1 seek=1 #"actually", count should be (GDT_SIZE)/(SECTOR_SIZE), GDT_SIZE is guaranteed to be a multiple of 512
512.bin: 512.asm gdt.bin
   -rm 512.bin
nasm -f bin 512.asm -o 512.bin -DGDT_SIZE=`stat -c %s gdt.bin` -DSECTOR_SIZE=512 #env variables GDT_SIZE and SECTOR_SIZE are both referenced from within 512.asm
gdt.bin: gdt.asm
   -rm gdt.bin
   nasm -f bin gdt.asm -o gdt.bin

This doesnt work (and you can probably see why). Can you please make the necessary corrections (as few as possible) and make it not too cryptic, so I can understand what is going on...or, if necessary, explain it a little bit...I've tried the make manual, really, but I get confused :-(




reply via email to

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