Hey i want to compile one c file first and then the assembly and safe both object files in one directory to link them. But my makefile just use one rule.
IDIR = headers/syscalls
CL=clang
NASM = nasm
CFLAGS=-g -Wall -fsanitize=address
LDFLAGS=-g -Wall -fsanitize=address
HFLAGS= -I$(IDIR)
ODIR=src/obj
_DEPS = myunistd.h mystddef.h
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))
_OBJ = demoSys.o myunistd.o
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
$(ODIR)/demoSys.o: src/demoSys.c $(DEPS)
$(CL) -c -o $@ $< $(HFLAGS)
$(ODIR)/myunistd.o: src/myunistd.s
$(NASM) -f elf64 -o $@ $<
exe: $(OBJ)
$(CL) -o $@ $^
.Phony: clean
clean:
rm -f $(ODIR)/*.o *~ core $(INCDIR)/*~
that is my makefile
Thank you for any help