ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/gclib/gclib/Makefile
Revision: 18
Committed: Mon Jul 18 21:00:21 2011 UTC (8 years ago) by gpertea
File size: 1492 byte(s)
Log Message:
added a few more source files, test code

Line File contents
1 THISCODEDIR := .
2 SEARCHDIRS := -I${THISCODEDIR}
3
4 SYSTYPE := $(shell uname)
5
6 MACHTYPE := $(shell uname -m)
7 ifeq ($(MACHTYPE), i686)
8 MARCH = -march=i686
9 else
10 MARCH =
11 endif
12
13 CC := g++
14
15 BASEFLAGS := -Wall -Wextra ${SEARCHDIRS} $(MARCH) -D_FILE_OFFSET_BITS=64 \
16 -D_LARGEFILE_SOURCE -D_REENTRANT -fno-exceptions -fno-rtti
17
18 #add the link-time optimization flag if gcc version > 4.5
19 GCC_VERSION:=$(subst ., ,$(shell gcc -dumpversion))
20 GCC_MAJOR:=$(word 1,$(GCC_VERSION))
21 GCC_MINOR:=$(word 2,$(GCC_VERSION))
22 #GCC_SUB:=$(word 3,$(GCC_VERSION))
23 GCC_SUB:=x
24
25 GCC45OPTS :=
26 GCC45OPTMAIN :=
27
28 ifeq ($(findstring debug,$(MAKECMDGOALS)),)
29 CFLAGS := -O2 -DNDEBUG $(BASEFLAGS)
30 LDFLAGS :=
31 ifeq ($(shell expr $(GCC_MAJOR).$(GCC_MINOR) '>=' 4.5),1)
32 CFLAGS += -flto
33 GCC45OPTS := -flto
34 GCC45OPTMAIN := -fwhole-program
35 endif
36 else
37 CFLAGS := -g -DDEBUG $(BASEFLAGS)
38 LDFLAGS := -g
39 endif
40
41 %.o : %.cpp
42 ${CC} ${CFLAGS} -c $< -o $@
43
44 # C/C++ linker
45
46 LINKER := g++
47 LIBS :=
48 OBJS := GBase.o GStr.o GArgs.o
49
50 .PHONY : all
51 all: gtest
52
53 version: ; @echo "GCC Version is: "$(GCC_MAJOR)":"$(GCC_MINOR)":"$(GCC_SUB)
54 @echo "> GCC Opt. string is: "$(GCC45OPTS)
55 debug: gtest
56 $(OBJS) : GBase.h GArgs.h
57 gtest.o : GBase.h GArgs.h
58 GArgs.o : GArgs.h
59 gtest: $(OBJS) gtest.o
60 ${LINKER} ${LDFLAGS} $(GCC45OPTS) $(GCC45OPTMAIN) -o $@ ${filter-out %.a %.so, $^} ${LIBS}
61
62 # target for removing all object files
63
64 .PHONY : clean
65 clean::
66 @${RM} gtest gtest.o gtest.exe $(OBJS)
67 @${RM} core.*