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

Makefile: Bring back -O3 in a downstream-compatible way

This commit brings back -O3 but in an overridable way. This should make
downstream distributions happy enough to accept it.

While at the subject, let's apply the same fixup logic to LDFLAGS, too.

This commit also properly gets rid of the implicit rules which collided
too easily with the depends.mk.

Signed-off-by: Kai Krakow <kai@kaishome.de>
This commit is contained in:
Kai Krakow 2018-11-08 01:56:19 +01:00
parent f2dec480a6
commit c69a954d8f
No known key found for this signature in database
GPG Key ID: 046FAC3028D76321
4 changed files with 30 additions and 26 deletions

View File

@ -22,6 +22,8 @@ CRUCIBLE_OBJS = \
include ../makeflags include ../makeflags
include ../Defines.mk include ../Defines.mk
BEES_LDFLAGS = $(LDFLAGS)
configure.h: configure.h.in configure.h: configure.h.in
$(TEMPLATE_COMPILER) $(TEMPLATE_COMPILER)
@ -29,7 +31,7 @@ configure.h: configure.h.in
mkdir -p $@ mkdir -p $@
.depends/%.dep: %.cc configure.h Makefile | .depends .depends/%.dep: %.cc configure.h Makefile | .depends
$(CXX) $(CXXFLAGS) -M -MF $@ -MT $(<:.cc=.o) $< $(CXX) $(BEES_CXXFLAGS) -M -MF $@ -MT $(<:.cc=.o) $<
depends.mk: $(CRUCIBLE_OBJS:%.o=.depends/%.dep) depends.mk: $(CRUCIBLE_OBJS:%.o=.depends/%.dep)
cat $^ > $@.new cat $^ > $@.new
@ -42,7 +44,7 @@ depends.mk: $(CRUCIBLE_OBJS:%.o=.depends/%.dep)
include depends.mk include depends.mk
%.o: %.cc ../makeflags %.o: %.cc ../makeflags
$(CXX) $(CXXFLAGS) -fPIC -o $@ -c $< $(CXX) $(BEES_CXXFLAGS) -fPIC -o $@ -c $<
libcrucible.so: $(CRUCIBLE_OBJS) .version.o libcrucible.so: $(CRUCIBLE_OBJS) .version.o
$(CXX) $(LDFLAGS) -fPIC -shared -Wl,-soname,$@ -o $@ $^ -luuid $(CXX) $(BEES_LDFLAGS) -fPIC -shared -Wl,-soname,$@ -o $@ $^ -luuid

View File

@ -1,11 +1,13 @@
# Default: # Default:
CCFLAGS = -Wall -Wextra -Werror -I../include -fpic -D_FILE_OFFSET_BITS=64 CCFLAGS = -Wall -Wextra -Werror -O3
# Optimized: # Optimized:
# CCFLAGS = -Wall -Wextra -Werror -O3 -march=native -I../include -fpic -D_FILE_OFFSET_BITS=64 # CCFLAGS = -Wall -Wextra -Werror -O3 -march=native
# Debug: # Debug:
# CCFLAGS = -Wall -Wextra -Werror -O0 -I../include -ggdb -fpic -D_FILE_OFFSET_BITS=64 # CCFLAGS = -Wall -Wextra -Werror -O0 -ggdb
CFLAGS += $(CCFLAGS) -std=c99 CCFLAGS += -I../include -fpic -D_FILE_OFFSET_BITS=64
CXXFLAGS += $(CCFLAGS) -std=c++11 -Wold-style-cast
BEES_CFLAGS = $(CCFLAGS) -std=c99 $(CFLAGS)
BEES_CXXFLAGS = $(CCFLAGS) -std=c++11 -Wold-style-cast $(CXXFLAGS)

View File

@ -1,14 +1,14 @@
BEES = ../bin/bees
PROGRAMS = \ PROGRAMS = \
../bin/bees \
../bin/fiemap \ ../bin/fiemap \
../bin/fiewalk \ ../bin/fiewalk \
all: $(PROGRAMS) all: $(BEES) $(PROGRAMS)
include ../makeflags include ../makeflags
LIBS = -lcrucible -lpthread LIBS = -lcrucible -lpthread
LDFLAGS = -L../lib BEES_LDFLAGS = -L../lib $(LDFLAGS)
BEES_OBJS = \ BEES_OBJS = \
bees.o \ bees.o \
@ -27,7 +27,7 @@ bees-version.c: bees.h $(BEES_OBJS:.o=.cc) Makefile
mkdir -p $@ mkdir -p $@
.depends/%.dep: %.cc Makefile | .depends .depends/%.dep: %.cc Makefile | .depends
$(CXX) $(CXXFLAGS) -M -MF $@ -MT $(<:.cc=.o) $< $(CXX) $(BEES_CXXFLAGS) -M -MF $@ -MT $(<:.cc=.o) $<
depends.mk: $(BEES_OBJS:%.o=.depends/%.dep) depends.mk: $(BEES_OBJS:%.o=.depends/%.dep)
cat $^ > $@.new cat $^ > $@.new
@ -35,15 +35,17 @@ depends.mk: $(BEES_OBJS:%.o=.depends/%.dep)
include depends.mk include depends.mk
%.o: %.cc %.h $(BEES_OBJS) fiemap.o fiewalk.o: %.o: %.cc
$(CXX) $(CXXFLAGS) -o $@ -c $< $(CXX) $(BEES_CXXFLAGS) -o $@ -c $<
../bin/%: %.o $(PROGRAMS): ../bin/%: %.o
@echo Implicit bin rule "$<" '->' "$@" $(CXX) $(BEES_CXXFLAGS) $(BEES_LDFLAGS) -o $@ $< $(LIBS)
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $< $(LIBS)
../bin/bees: $(BEES_OBJS) bees-version.o bees-version.o: %.o: %.c
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) $(CC) $(BEES_CFLAGS) -o $@ -c $<
$(BEES): $(BEES_OBJS) bees-version.o
$(CXX) $(BEES_CXXFLAGS) $(BEES_LDFLAGS) -o $@ $^ $(LIBS)
clean: clean:
rm -fv *.o bees-version.c rm -fv *.o bees-version.c

View File

@ -16,13 +16,13 @@ FORCE:
include ../makeflags include ../makeflags
LIBS = -lcrucible -lpthread LIBS = -lcrucible -lpthread
LDFLAGS = -L../lib -Wl,-rpath=$(shell realpath ../lib) BEES_LDFLAGS = -L../lib -Wl,-rpath=$(abspath ../lib) $(LDFLAGS)
.depends: .depends:
mkdir -p $@ mkdir -p $@
.depends/%.dep: %.cc tests.h Makefile | .depends .depends/%.dep: %.cc tests.h Makefile | .depends
$(CXX) $(CXXFLAGS) -M -MF $@ -MT $(<:.cc=.o) $< $(CXX) $(BEES_CXXFLAGS) -M -MF $@ -MT $(<:.cc=.o) $<
depends.mk: $(PROGRAMS:%=.depends/%.dep) depends.mk: $(PROGRAMS:%=.depends/%.dep)
cat $^ > $@.new cat $^ > $@.new
@ -30,13 +30,11 @@ depends.mk: $(PROGRAMS:%=.depends/%.dep)
include depends.mk include depends.mk
%.o: %.cc %.h ../makeflags Makefile $(PROGRAMS:%=%.o): %.o: %.cc ../makeflags Makefile
@echo "Implicit rule %.o: %.cc" $(CXX) $(BEES_CXXFLAGS) -o $@ -c $<
$(CXX) $(CXXFLAGS) -o $@ -c $<
$(PROGRAMS): %: %.o ../makeflags Makefile $(PROGRAMS): %: %.o ../makeflags Makefile
@echo "Implicit rule %: %.o" $(CXX) $(BEES_CXXFLAGS) $(BEES_LDFLAGS) -o $@ $< $(LIBS)
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $< $(LIBS)
%.txt: % Makefile FORCE %.txt: % Makefile FORCE
./$< >$@ 2>&1 || (RC=$$?; cat $@; exit $$RC) ./$< >$@ 2>&1 || (RC=$$?; cat $@; exit $$RC)