0

I am trying to create a Makefile that compiles multiple C files for use in Minix. How would I change the Makefile so that it compiles multiple files at the same time? Below is the current state of my Makefile.

CFLAGS  = -D_POSIX_SOURCE
LDFLAGS =
CC      = cc
LD      = cc

PROG    = test

OBJS    = test.o

$(PROG): $(OBJS)
        $(LD) $(LDFLAGS) $(OBJS) -o $(PROG)

clean:
        rm -rf $(PROG) $(OBJS)

I thought I could just list the other programs after PROG and OBJS such as

PROG   = test test2

OBJS   = test.o test2.o

but that didn't work. Any ideas? Thanks in advance.

BRPocock
  • 13,638
  • 3
  • 31
  • 50
johns4ta
  • 886
  • 2
  • 12
  • 38

1 Answers1

1

Split it up this way:

PROG1 = test 
PROG2 = test2
OBJ1 = test.o
OBJ2 = test2.o


$(PROG1): $(OBJ1) 
          $(LD) $(LDFLAGS) $(OBJ1) -o $(PROG1)
$(PROG2): $(OBJ2) 
          $(LD) $(LDFLAGS) $(OBJ2) -o $(PROG2)

etc

Charlie Burns
  • 6,994
  • 20
  • 29