diff --git a/Makefile b/Makefile index 22f5397..6381157 100644 --- a/Makefile +++ b/Makefile @@ -70,7 +70,7 @@ ifeq ($(UNAME_S),Linux) $(CXX) -g -shared -Wl,-soname,$(SONAME) -o $(OUTDIR)$(REALNAME) $(LDFLAGS) $(LDLIBS) $(addprefix $(BUILDDIR),$(OBJS)) endif -%.o: %.cpp %.d Makefile +%.o: %.cpp %.d $(CXX) $(CXXFLAGS) -MMD -MP -MT $@ -MF $*.d -c $< @mv $@ $*.d $(BUILDDIR) @@ -81,6 +81,7 @@ endif $(OUTDIR)$(STATICLIB): $(OBJS) ar r $(OUTDIR)$(STATICLIB) $(addprefix $(BUILDDIR),$(OBJS)) +ifeq ($(GENERATELIBHEADER),1) $(LIBNAME).hpp: $(HDRS) @echo updating build/$(LIBNAME).hpp @cp /dev/null build/$(LIBNAME).hpp @@ -88,6 +89,10 @@ $(LIBNAME).hpp: $(HDRS) do \ cat $$h >> build/$(LIBNAME).hpp; \ done +HEADERSRCDIR := build +else +HEADERSRCDIR := src +endif test: $(MAKE) -C tests && tests/tests @@ -96,11 +101,11 @@ clean: $(RM) build $(MAKE) -C tests clean -install: $(OUTDIR)$(REALNAME) $(LIBNAME).hpp +install: $(INSTALL) -d $(LIBDIR) $(INSTALL) -m 644 $(OUTDIR)$(REALNAME) $(LIBDIR) $(INSTALL) -d $(INCLUDEDIR) - $(INSTALL) -m 644 build/$(LIBNAME).hpp $(INCLUDEDIR) + $(INSTALL) -m 644 $(HEADERSRCDIR)/$(LIBNAME).hpp $(INCLUDEDIR) ifeq ($(UNAME_S),Darwin) cd $(LIBDIR) && ln -sf $(REALNAME) $(SONAME) endif