Modernized Makefile
This commit is contained in:
parent
c9efb327c0
commit
192640552e
9
Makefile
9
Makefile
@ -30,7 +30,6 @@ DOCDIR ?= $(DATADIR)/$(LIBNAME)/doc
|
|||||||
|
|
||||||
SRCS := $(notdir $(wildcard src/*.cpp))
|
SRCS := $(notdir $(wildcard src/*.cpp))
|
||||||
OBJS := $(SRCS:.cpp=.o)
|
OBJS := $(SRCS:.cpp=.o)
|
||||||
DEPS := $(SRCS:.cpp=.d)
|
|
||||||
HDRS ?= $(wildcard src/*.hpp)
|
HDRS ?= $(wildcard src/*.hpp)
|
||||||
|
|
||||||
CXX ?= g++
|
CXX ?= g++
|
||||||
@ -59,7 +58,7 @@ all: prebuild $(OUTDIR)$(REALNAME) $(OUTDIR)$(STATICLIB)
|
|||||||
prebuild:
|
prebuild:
|
||||||
@mkdir -p $(BUILDDIR) $(OUTDIR)
|
@mkdir -p $(BUILDDIR) $(OUTDIR)
|
||||||
|
|
||||||
$(OUTDIR)$(REALNAME): $(OBJS) $(DEPS)
|
$(OUTDIR)$(REALNAME): $(OBJS)
|
||||||
ifeq ($(UNAME_S),Darwin)
|
ifeq ($(UNAME_S),Darwin)
|
||||||
$(CXX) -dynamiclib -o $(OUTDIR)$(REALNAME) -current_version $(MAJOR) -compatibility_version $(MINOR) $(LDFLAGS) $(LDLIBS) $(addprefix $(BUILDDIR),$(OBJS))
|
$(CXX) -dynamiclib -o $(OUTDIR)$(REALNAME) -current_version $(MAJOR) -compatibility_version $(MINOR) $(LDFLAGS) $(LDLIBS) $(addprefix $(BUILDDIR),$(OBJS))
|
||||||
endif
|
endif
|
||||||
@ -70,13 +69,11 @@ ifeq ($(UNAME_S),Linux)
|
|||||||
$(CXX) -g -shared -Wl,-soname,$(SONAME) -o $(OUTDIR)$(REALNAME) $(LDFLAGS) $(LDLIBS) $(addprefix $(BUILDDIR),$(OBJS))
|
$(CXX) -g -shared -Wl,-soname,$(SONAME) -o $(OUTDIR)$(REALNAME) $(LDFLAGS) $(LDLIBS) $(addprefix $(BUILDDIR),$(OBJS))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
%.o: %.cpp %.d
|
%.o %.d: %.cpp
|
||||||
$(CXX) $(CXXFLAGS) -MMD -MP -MT $@ -MF $*.d -c $<
|
$(CXX) $(CXXFLAGS) -MMD -MP -MT $@ -MF $*.d -c $<
|
||||||
@mv $@ $*.d $(BUILDDIR)
|
@mv $@ $*.d $(BUILDDIR)
|
||||||
|
|
||||||
-include $(BUILDDIR)*.d
|
-include $(BUILDDIR)$(SRCS:.cpp=.d)
|
||||||
|
|
||||||
%.d: ;
|
|
||||||
|
|
||||||
$(OUTDIR)$(STATICLIB): $(OBJS)
|
$(OUTDIR)$(STATICLIB): $(OBJS)
|
||||||
ar r $(OUTDIR)$(STATICLIB) $(addprefix $(BUILDDIR),$(OBJS))
|
ar r $(OUTDIR)$(STATICLIB) $(addprefix $(BUILDDIR),$(OBJS))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user