NASM - The Netwide Assembler
NASM Forum => Using NASM => Topic started by: fixit on August 05, 2016, 10:00:46 PM
-
How do I run a makefile ?
I tried nasm makefile.
nasm: warning: file name already has no extension: output will be in `nasm.out'
makefile:1: error: parser: instruction expected
makefile:2: error: parser: instruction expected
makefile:3: error: parser: instruction expected
makefile:4: error: parser: instruction expected
makefile:5: error: symbol `nasm' redefined
makefile:5: error: parser: instruction expected
-
Heh, "might as well try to assemble a sonnet." Rather than run Nasm on your makefile, the "make" utility runs Nasm (and/or other tools) on assembly files specified in your makefile. By default, "make" looks for "makefile" or "Makefile" in the current directory. It is often spelled "Makefile" so it alphabetizes near the top of the source listing. Another name can be specified with the "-f" switch - "make -f mkfiles/myprog.mak" or whatever. The default target usually just builds the executable. The most famous target is probably "make install". "make clean" is another common target. The whole idea is to avoid running tools on files that haven't changed since the last build, saving time on a complex project. "man make" or "info make" will tell you more than you want to know. Wikipedia has a brief rundown:
https://en.wikipedia.org/wiki/Makefile
In short, just get into the directory and type "make".
Best,
Frank
-
This is an example from here.
https://forum.nasm.us/index.php?topic=2253.0
make
nasm -f elf editbin.asm
nasm -f elf cursor.asm
ld -s -o editbin editbin.o cursor.o
ld: i386 architecture of input file `editbin.o' is incompatible with i386:x86-64 output
ld: i386 architecture of input file `cursor.o' is incompatible with i386:x86-64 output
makefile:2: recipe for target 'editbin' failed
make: *** [editbin] Error 1
Am I getting this because I am using a 64 bit system ?
-
Yeah, probably. Try editing John's "makefile" like so:
editbin: editbin.o
ld -s -o -m elf_i386 editbin editbin.o cursor.o getkey.o
editbin.o: editbin.asm cursor.asm
nasm -f elf editbin.asm
nasm -f elf cursor.asm
nasm -f elf getkey.asm
No guarantee, I've got a 32-bit system too. I find makefiles tricky, since an "invisible" character - TAB - is a vital part of the syntax. Some editors silently replace TAB (ascii 9) with spaces (good ol' edit.com used to do it), causing "make" to barf with an unhelpful error message.
Best,
Frank
-
Thanks worked like a charm.
And program works well.
Fairly small editor though a com file would probably be smaller.