Skip to content

Commit

Permalink
Switch to doing all the compile configuration in Makefile.inc.
Browse files Browse the repository at this point in the history
It was getting to be really bad to have each directory have its own
settings for the compilers.  Now everything should use the same
include file with CC, CXX, CFLAGS, CXXFLAGS, etc.  At least that will
be true for these Makefiles and will have to be done differently when
there are other build systems present.

#65
  • Loading branch information
schwehr committed Jul 19, 2015
1 parent 6fd734d commit aedb269
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 106 deletions.
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,22 @@ real-clean: clean
gsf:
(cd src/gsf && make libgsf.a)

gsf-obj:
(cd src/gsf && make obj)

gsf-test:
(cd src/gsf && make libgsf.a)
(cd tests/gsf && make test)

gsfxx:
(cd src/gsfxx && make libgsfxx.a)

gsfxx-obj:
(cd src/gsfxx && make obj)

gsfxx-test:
(cd src/gsfxx && make libgsfxx.a)
(cd tests/gsfxx && make test)

obj: gsf-obj gsfxx-obj

37 changes: 37 additions & 0 deletions Makefile.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# -*- makefile -*-

CC := clang
CXX := clang++

WARN :=
WARN := -Wall
WARN += -Wextra

ifdef ERROR
WARN += -Werror
endif

CFLAGS := ${WARN}

CXXFLAGS += -std=c++11
# CXXFLAGS += -pthread
CXXFLAGS += ${WARN}

DBG := -g
DBG += -O0

OPT := -O3
OPT += -funroll-loops
# Not supposed by clang.
# OPT += -fexpensive-optimizations
OPT += -ffast-math
OPT += -DNDEBUG

ifdef OPTIMIZE
CFLAGS += ${OPT}
CXXFLAGS += ${OPT}
else
CFLAGS += ${DBG}
CXXFLAGS += ${DBG}
endif

25 changes: 2 additions & 23 deletions src/bin/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

BIN := gsf_index

WARN := -Wall
WARN += -Wextra
# WARN += -Werror

DBG := -g3 -DDEBUG=1
DBG += -O0

OPT := -O3
OPT += -funroll-loops
OPT += -fexpensive-optimizations
OPT += -ffast-math
OPT += -DNDEBUG
include ../../Makefile.inc

CXXFLAGS := ${WARN}
CXXFLAGS += -std=c++11
BIN := gsf_index

CPPFLAGS := -I../gsf -I../gsfxx
LDFLAGS := -L../gsfxx

ifdef OPTIMIZE
CXXFLAGS += ${OPT}
else
CXXFLAGS += ${DBG}
endif


all: ${BIN}
@echo "Done"

Expand Down
30 changes: 3 additions & 27 deletions src/gsf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# CC := gcc-5

WARN := -Wall
WARN += -Wextra

ifdef ERROR
WARN += -Werror
endif

DBG := -g3
DBG += -O0

OPT := -O3
OPT += -funroll-loops
# Not supposed by clang.
# OPT += -fexpensive-optimizations
OPT += -ffast-math
OPT += -DNDEBUG

CFLAGS := ${WARN}

ifdef OPTIMIZE
CFLAGS += ${OPT}
else
CFLAGS += ${DBG}
endif

include ../../Makefile.inc

SRCS := $(wildcard *.c)
OBJS := ${SRCS:.c=.o}
Expand All @@ -50,6 +24,8 @@ ${LIB}: ${OBJS}

all: ${LIB}

obj: ${OBJS}

clean:
-rm -f *.o
-rm -f ${LIB}
Expand Down
28 changes: 3 additions & 25 deletions src/gsfxx/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.

WARN := -Wall
WARN += -Wextra

ifdef ERROR
WARN += -Werror
endif

DBG := -g3
DBG += -O0

OPT := -O3
OPT += -funroll-loops
OPT += -fexpensive-optimizations
OPT += -ffast-math
OPT += -DNDEBUG

CPPFLAGS := ${WARN}

ifdef OPTIMIZE
CPPFLAGS += ${OPT}
else
CPPFLAGS += ${DBG}
endif

CXXFLAGS += -std=c++11
include ../../Makefile.inc

SRCS := $(wildcard *.cc)
OBJS := ${SRCS:.cc=.o}
LIB := libgsfxx.a

all: ${LIB}

obj: ${OBJS}

clean:
-rm -f *.o
-rm -f ${LIB}
Expand Down
18 changes: 2 additions & 16 deletions tests/gsf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

include ../../Makefile.inc

TESTS := index_test
TESTS += read_gsf_2_9_test
TESTS += read_gsf_3_6_test
Expand Down Expand Up @@ -41,22 +43,6 @@ CPPFLAGS += -isystem $(GMOCK_DIR)/include
CPPFLAGS += -I../../src/gsf
CPPFLAGS += -I$(GTEST_DIR) -I$(GMOCK_DIR)

CXXFLAGS += -std=c++11
CXXFLAGS += -Wall -Wextra -pthread

DBG := -g
DBG += -O0

OPT := -O3
OPT += -funroll-loops -fexpensive-optimizations -ffast-math

ifdef OPTIMIZE
CXXFLAGS += ${OPT}
else
CXXFLAGS += ${DBG}
endif


GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \
$(GTEST_DIR)/include/gtest/internal/*.h

Expand Down
17 changes: 2 additions & 15 deletions tests/gsfxx/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

include ../../Makefile.inc

TESTS :=
TESTS += records_test
TESTS += util_test
Expand Down Expand Up @@ -40,21 +42,6 @@ CPPFLAGS += -isystem $(GMOCK_DIR)/include
CPPFLAGS += -I../../src/gsfxx
CPPFLAGS += -I$(GTEST_DIR) -I$(GMOCK_DIR)

CXXFLAGS += -std=c++11
CXXFLAGS += -Wall -Wextra -pthread

DBG := -g
DBG += -O0

OPT := -O3
OPT += -funroll-loops -fexpensive-optimizations -ffast-math

ifdef OPTIMIZE
CXXFLAGS += ${OPT}
else
CXXFLAGS += ${DBG}
endif

LDFLAGS := -L../../src/gsfxx -lgsfxx
# TODO(schwehr): Move the gtest build stuff to its own directory.
LDFLAGS += -L.
Expand Down

0 comments on commit aedb269

Please sign in to comment.