I want to have makefiles for both c and c++ in different file folder locations. The c makefile here was nice and easy (the file needs to be called Exercises.c for this makefile...I did not set it up so that I can rename it with an environment variable). My question is, how come the c++ makefile is more difficult. I could not make it very simple like the c makefile, I had to do it a lot differently. Is there an easier way to do the c++ makefile (the file for the c++ makefile needs to be called Exercises.cpp).
The C Makefile:
Code:
P=Exercises
OBJECTS=
CFLAGS= -g -Wall -o3 -std=gnu11
LDLIBS=
CC=gcc
$(P): $(OBJECTS)
The C++ Makefile
Code:
P=Exercises
OBJECTS=
CPPFLAGS=
CXXFLAGS=
LDLIBS=
CXX=g++
$(P): $(P).o
g++ -g -o $@ $(P).o
$(P).o : $(P).cpp
g++ -g -Wall -std=gnu++14 -c $(P).cpp
clean:
rm $(P).o $(P)