Dev-Tools/Makefile/Makefile

41 lines
922 B
Makefile

# Preproc options
# -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)
bin = main
cxxbin = cxxmain
sources = $(wildcard *.c)
objects = $(sources:%.c=%.o)
depends = $(sources:%.c=%.d)
# 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) $(bin) $(objects) $(depends) $(cxxbin) $(cxx_objects) $(cxx_depends)
ifneq ($(MAKECMDGOALS),clean)
-include $(depends)
-include $(cxx_depends)
endif