Commit 3fcfdb67 authored by Mathieu Maret's avatar Mathieu Maret

Makefile: C++ compilation

parent 3f6fd7dd
# Preproc options
# -MMD is used to generate .d files for header dependencies
# -MMD is used to generate .d files for user header dependencies (use -MD for system and user header instead)
CPPFLAGS = -MMD
# main compilation
CFLAGS ?= -Werror -Wall #$(pkg-config --cflags sdl)
# C++ flags
CXXFLAGS =
#Linker flags
LDFLAGS =
#Linker path
LDLIBS = #$(pkg-config --libs sdl)
program = test
bin = main
cxxbin = cxxmain
sources = $(wildcard *.c)
objects = $(sources:%.c=%.o)
depends = $(sources:%.c=%.d)
$(program): $(objects)
# Do not have same file prefix between C and C++ (e.g. main.c and main.cpp)
cxx_sources = $(wildcard *.cpp)
cxx_objects = $(cxx_sources:%.cpp=%.o)
cxx_depends = $(cxx_sources:%.cpp=%.d)
$(bin): $(objects)
$(cxxbin) : $(cxx_objects)
# C++ compilation (Use implicit LINK.CC)
$(cxxbin):
$(LINK.cc) $^ $(LDLIBS) -o $@
.PHONY: clean
clean:
$(RM) $(program) $(objects) $(depends)
$(RM) $(bin) $(objects) $(depends) $(cxxbin) $(cxx_objects) $(cxx_depends)
ifneq ($(MAKECMDGOALS),clean)
-include $(depends)
-include $(cxx_depends)
endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment