-1
all: elfparser

elfparser: disasm.o elf-parser.o elf-parser-main.o elf-program_read.o srec.o
    gcc -o elfparser disasm.o elf-parser.o elf-parser-main.o elf-program_read.o srec.o

elf-parser-main.o: elf-parser-main.c
    gcc -c -o elf-parser-main.o elf-parser-main.c

disasm.o: disasm.c
    gcc -c -o disasm.c

elf-parser.o: elf-parser.c
    gcc -c -o elf-parser.c

elf-program_read.o: elf-program_read.c
    gcc -c -o elf-program_read.c
    
srec.o: srec.c
    gcc -c -o srec.c

clean:
    rm -rf *o elfparser
Ahmed Masud
  • 21,655
  • 3
  • 33
  • 58
  • `tab`s and `new lines` matter in a Makefile. I will edit your question, also, your make file has other problems when generating .o files. – Ahmed Masud Oct 11 '21 at 16:55
  • This can't be the identical makefile as the one where you got this error because there's no error on line 6 here, as the question title states. However this error is the single most common problem people have writing makefiles: any search for this error message on the internets will give you lots of information about what's wrong... – MadScientist Oct 11 '21 at 18:08

1 Answers1

0

This question is already VERY NICELY although slightly differently answered here

Here is a slightly better approach:


BIN=elfparser
SRC=disasm.c elf-parser.c elf-parser-main.c elf-program_read.c srec.c

# OBJ filenames are created from SRC filenames by replacing .c with .o
OBJ=$(SRC:%.c=%.o)

CC=gcc
CFLAGS=-O2 -g

default: $(BIN)

# To create the binary, build all objects first
$(BIN): $(OBJ)
        $(CC) -o $@ $(OBJ) 

# How to generate a .o from a .c rule:
%.o: %.c
        $(CC) $(CFLAGS) $(INCLUDES) -o $@ -c %< 


If you decide to cut and paste this code remember that the lines that are under the rules (i.e. commands that run in the shell to do the work) HAVE TO HAVE A <TAB> (not spaces) before them.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Ahmed Masud
  • 21,655
  • 3
  • 33
  • 58