1
0
mirror of https://github.com/Zygo/bees.git synced 2025-05-18 05:45:45 +02:00

Merge remote-tracking branch 'kakra/proposal/prepare-for-more-libs'

This commit is contained in:
Zygo Blaxell 2018-01-20 14:23:55 -05:00
commit 5533d09b3d
5 changed files with 57 additions and 43 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
*.[ao] *.[ao]
*.bak *.bak
*.new *.new
*.dep
*.so* *.so*
Doxyfile Doxyfile
README.html README.html

View File

@ -29,7 +29,7 @@ test: lib src
$(MAKE) -C test $(MAKE) -C test
scripts/%: scripts/%.in scripts/%: scripts/%.in
sed -e's#@LIBEXEC_PREFIX@#$(LIBEXEC_PREFIX)#' -e's#@PREFIX@#$(PREFIX)#' "$<" >"$@" sed -e's#@LIBEXEC_PREFIX@#$(LIBEXEC_PREFIX)#' -e's#@PREFIX@#$(PREFIX)#' $< >$@
scripts: scripts/beesd scripts/beesd@.service scripts: scripts/beesd scripts/beesd@.service

View File

@ -1,8 +1,9 @@
TAG := $(shell git describe --always --dirty || echo UNKNOWN) TAG := $(shell git describe --always --dirty || echo UNKNOWN)
default: libcrucible.so default: libcrucible.so
%.so: Makefile
OBJS = \ CRUCIBLE_OBJS = \
chatter.o \ chatter.o \
cleanup.o \ cleanup.o \
crc64.o \ crc64.o \
@ -19,20 +20,26 @@ OBJS = \
uuid.o \ uuid.o \
.version.o \ .version.o \
libcrucible.so: $(CRUCIBLE_OBJS) -luuid
include ../makeflags include ../makeflags
depends.mk: *.cc .depends/%.dep: %.cc Makefile
for x in *.cc; do $(CXX) $(CXXFLAGS) -M "$$x"; done > depends.mk.new @mkdir -p .depends
mv -fv depends.mk.new depends.mk $(CXX) $(CXXFLAGS) -M -MF $@ -MT $(<:.cc=.o) $<
depends.mk: $(CRUCIBLE_OBJS:%.o=.depends/%.dep)
cat $^ > $@.new
mv -f $@.new $@
.version.cc: Makefile ../makeflags *.cc ../include/crucible/*.h .version.cc: Makefile ../makeflags *.cc ../include/crucible/*.h
echo "namespace crucible { const char *VERSION = \"$(TAG)\"; }" > .version.new.cc echo "namespace crucible { const char *VERSION = \"$(TAG)\"; }" > $@.new
mv -f .version.new.cc .version.cc mv -f $@.new $@
-include depends.mk include depends.mk
%.o: %.cc ../include/crucible/%.h %.o: %.cc ../makeflags
$(CXX) $(CXXFLAGS) -fPIC -o $@ -c $< $(CXX) $(CXXFLAGS) -fPIC -o $@ -c $<
libcrucible.so: $(OBJS) Makefile %.so:
$(CXX) $(LDFLAGS) -fPIC -o $@ $(OBJS) -shared -Wl,-soname,$@ -luuid $(CXX) $(LDFLAGS) -fPIC -shared -Wl,-soname,$@ -o $@ $^

View File

@ -3,30 +3,13 @@ PROGRAMS = \
../bin/fiemap \ ../bin/fiemap \
../bin/fiewalk \ ../bin/fiewalk \
all: $(PROGRAMS) depends.mk all: $(PROGRAMS)
include ../makeflags include ../makeflags
LIBS = -lcrucible -lpthread LIBS = -lcrucible -lpthread
LDFLAGS = -L../lib LDFLAGS = -L../lib
depends.mk: Makefile *.cc
for x in *.cc; do $(CXX) $(CXXFLAGS) -M "$$x"; done > depends.mk.new
mv -fv depends.mk.new depends.mk
bees-version.c: Makefile *.cc *.h
echo "const char *BEES_VERSION = \"$(shell git describe --always --dirty || echo UNKNOWN)\";" > bees-version.new.c
mv -f bees-version.new.c bees-version.c
-include depends.mk
%.o: %.cc %.h
$(CXX) $(CXXFLAGS) -o "$@" -c "$<"
../bin/%: %.o
@echo Implicit bin rule "$<" '->' "$@"
$(CXX) $(CXXFLAGS) -o "$@" "$<" $(LDFLAGS) $(LIBS)
BEES_OBJS = \ BEES_OBJS = \
bees.o \ bees.o \
bees-context.o \ bees-context.o \
@ -35,11 +18,30 @@ BEES_OBJS = \
bees-roots.o \ bees-roots.o \
bees-thread.o \ bees-thread.o \
bees-types.o \ bees-types.o \
bees-version.o \
../bin/bees: $(BEES_OBJS) bees-version.c: bees.h $(BEES_OBJS:.o=.cc) Makefile
$(CXX) $(CXXFLAGS) -o "$@" $(BEES_OBJS) $(LDFLAGS) $(LIBS) echo "const char *BEES_VERSION = \"$(shell git describe --always --dirty || echo UNKNOWN)\";" > bees-version.new.c
mv -f bees-version.new.c bees-version.c
.depends/%.dep: %.cc Makefile
@mkdir -p .depends
$(CXX) $(CXXFLAGS) -M -MF $@ -MT $(<:.cc=.o) $<
depends.mk: $(BEES_OBJS:%.o=.depends/%.dep)
cat $^ > $@.new
mv -f $@.new $@
include depends.mk
%.o: %.cc %.h
$(CXX) $(CXXFLAGS) -o $@ -c $<
../bin/%: %.o
@echo Implicit bin rule "$<" '->' "$@"
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $< $(LIBS)
../bin/bees: $(BEES_OBJS) bees-version.o
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
clean: clean:
-rm -fv bees-version.h rm -fv *.o bees-version.c
-rm -fv *.o bees-version.c

View File

@ -17,19 +17,23 @@ include ../makeflags
LIBS = -lcrucible -lpthread LIBS = -lcrucible -lpthread
LDFLAGS = -L../lib -Wl,-rpath=$(shell realpath ../lib) LDFLAGS = -L../lib -Wl,-rpath=$(shell realpath ../lib)
depends.mk: *.cc .depends/%.dep: %.cc tests.h Makefile
for x in *.cc; do $(CXX) $(CXXFLAGS) -M "$$x"; done > depends.mk.new @mkdir -p .depends
mv -fv depends.mk.new depends.mk $(CXX) $(CXXFLAGS) -M -MF $@ -MT $(<:.cc=.o) $<
-include depends.mk depends.mk: $(PROGRAMS:%=.depends/%.dep)
cat $^ > $@.new
mv -f $@.new $@
include depends.mk
%.o: %.cc %.h ../makeflags %.o: %.cc %.h ../makeflags
-echo "Implicit rule %.o: %.cc" >&2 @echo "Implicit rule %.o: %.cc"
$(CXX) $(CXXFLAGS) -o "$@" -c "$<" $(CXX) $(CXXFLAGS) -o $@ -c $<
%: %.o ../makeflags %: %.o ../makeflags
-echo "Implicit rule %: %.o" >&2 @echo "Implicit rule %: %.o"
$(CXX) $(CXXFLAGS) -o "$@" "$<" $(LDFLAGS) $(LIBS) $(CXX) $(CXXFLAGS) $(LDFLAGS) $(LIBS) -o $@ $<
clean: clean:
-rm -fv *.o rm -fv *.o