Makefile that gives two .exe

Hey everyone, I'm trying to do a makefile that spits out two .exe. The files that I have are stack.h, teststack.cpp, and main.cpp. The thing is that stack.h and teststack.cpp are a completely separate program from main.cpp, but I want to produce the .exe for these two programs with one make file. This is what I have:


all: teststack.cpp main.cpp

teststack.cpp: stack.h
g++ -o test teststack.cpp

main.cpp:
g++ -o app main.cpp


(the tabs are there, but they aren't marked inside the quotes).

This (obviously) doesn't work. It successfully gives me a 'test', but doesn't spit 'app'.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
PROG1 = prog1
PROG1_SRCS = teststack.cpp

PROG2 = prog2
PROG2_SRCS = main.cpp

all: $(PROG1) $(PROG2)

$(PROG1): $(PROG1_SRCS:.cpp=.o)
	$(LINK.cc) $^ -o $@

$(PROG2): $(PROG2_SRCS:.cpp=.o)
	$(LINK.cc) $^ -o $@

teststack.o: stack.h
Last edited on
Registered users can post here. Sign in or register to post.