Modernized Makefile
This commit is contained in:
parent
287a36b31a
commit
c367b9bb3e
12
Makefile
12
Makefile
@ -22,6 +22,7 @@ BUILDDIR := build/intermediates/
|
||||
PREFIX ?= /usr/local
|
||||
BINDIR ?= $(PREFIX)/bin
|
||||
CONFIGDIR ?= $(PREFIX)/etc
|
||||
CONFIG := debug
|
||||
INCLUDEDIR ?= $(PREFIX)/include
|
||||
LIBDIR ?= $(PREFIX)/lib
|
||||
DATADIR ?= $(PREFIX)/share
|
||||
@ -35,10 +36,9 @@ HDRS := $(wildcard src/*.hpp)
|
||||
|
||||
CXX ?= g++
|
||||
|
||||
CXXFLAGS += -Wshadow -Wall -Wpedantic -Wextra -g -fno-strict-aliasing -std=c++17 -fPIC
|
||||
CXXFLAGS += -Wshadow -Wall -Wpedantic -Wextra -g -std=c++17 -fPIC
|
||||
ifeq ($(DEBUG),1)
|
||||
CXXFLAGS += -D DEBUG -O0
|
||||
CONFIG := debug
|
||||
else
|
||||
CXXFLAGS += -D NDEBUG -O3
|
||||
CONFIG := release
|
||||
@ -59,7 +59,7 @@ all: prebuild $(OUTDIR)$(REALNAME) $(OUTDIR)$(STATICLIB)
|
||||
prebuild:
|
||||
@mkdir -p $(BUILDDIR) $(OUTDIR)
|
||||
|
||||
$(OUTDIR)$(REALNAME): $(OBJS) $(DEPS)
|
||||
$(OUTDIR)$(REALNAME): $(OBJS)
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
$(CXX) -dynamiclib -o $(OUTDIR)$(REALNAME) -current_version $(MAJOR) -compatibility_version $(MINOR) $(LDFLAGS) $(LDLIBS) $(addprefix $(BUILDDIR),$(OBJS))
|
||||
endif
|
||||
@ -70,13 +70,11 @@ ifeq ($(UNAME_S),Linux)
|
||||
$(CXX) -g -shared -Wl,-soname,$(SONAME) -o $(OUTDIR)$(REALNAME) $(LDFLAGS) $(LDLIBS) $(addprefix $(BUILDDIR),$(OBJS))
|
||||
endif
|
||||
|
||||
%.o: %.cpp %.d
|
||||
%.o %.d: %.cpp
|
||||
$(CXX) $(CXXFLAGS) -MMD -MP -MT $@ -MF $*.d -c $<
|
||||
@mv $@ $*.d $(BUILDDIR)
|
||||
|
||||
-include $(BUILDDIR)*.d
|
||||
|
||||
%.d: ;
|
||||
-include $(BUILDDIR)$(DEPS)
|
||||
|
||||
$(OUTDIR)$(STATICLIB): $(OBJS)
|
||||
ar r $(OUTDIR)$(STATICLIB) $(addprefix $(BUILDDIR),$(OBJS))
|
||||
|
Loading…
x
Reference in New Issue
Block a user