ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/gclib/gclib/Makefile
Revision: 310
Committed: Fri Mar 22 20:06:27 2013 UTC (6 years, 3 months ago) by gpertea
File size: 2164 byte(s)
Log Message:
sync with igm repo

Line User Rev File contents
1 gpertea 18 THISCODEDIR := .
2     SEARCHDIRS := -I${THISCODEDIR}
3    
4     SYSTYPE := $(shell uname)
5    
6 gpertea 156 # A simple hack to check if we are on Windows or not (i.e. are we using mingw32-make?)
7     ifeq ($(findstring mingw32, $(MAKE)), mingw32)
8     WINDOWS=1
9     endif
10    
11    
12     # Compiler settings
13     TLIBS =
14     LDFLAGS =
15     # Non-windows systems need pthread
16     ifndef WINDOWS
17     TLIBS += -lpthread
18     endif
19    
20     # MinGW32 GCC 4.5 link problem fix
21     ifdef WINDOWS
22     ifeq ($(findstring 4.5.,$(shell g++ -dumpversion)), 4.5.)
23     LDFLAGS += -static-libstdc++ -static-libgcc
24     endif
25     endif
26    
27     # Misc. system commands
28     ifdef WINDOWS
29     RM = del /Q
30 gpertea 18 else
31 gpertea 156 RM = rm -f
32     endif
33 gpertea 18
34 gpertea 156 # File endings
35     ifdef WINDOWS
36     EXE = .exe
37     else
38     EXE =
39     endif
40    
41 gpertea 18 CC := g++
42    
43 gpertea 156 BASEFLAGS := -Wall -Wextra ${SEARCHDIRS} $(MARCH) \
44     -D_REENTRANT -fno-exceptions -fno-rtti
45 gpertea 18
46     #add the link-time optimization flag if gcc version > 4.5
47     GCC_VERSION:=$(subst ., ,$(shell gcc -dumpversion))
48     GCC_MAJOR:=$(word 1,$(GCC_VERSION))
49     GCC_MINOR:=$(word 2,$(GCC_VERSION))
50     #GCC_SUB:=$(word 3,$(GCC_VERSION))
51     GCC_SUB:=x
52    
53     GCC45OPTS :=
54     GCC45OPTMAIN :=
55    
56 gpertea 310 ifeq ($(findstring nodebug,$(MAKECMDGOALS)),)
57     CFLAGS := -g -DDEBUG $(BASEFLAGS)
58     LDFLAGS += -g
59     else
60 gpertea 18 CFLAGS := -O2 -DNDEBUG $(BASEFLAGS)
61     ifeq ($(shell expr $(GCC_MAJOR).$(GCC_MINOR) '>=' 4.5),1)
62     CFLAGS += -flto
63     GCC45OPTS := -flto
64     GCC45OPTMAIN := -fwhole-program
65     endif
66     endif
67    
68     %.o : %.cpp
69     ${CC} ${CFLAGS} -c $< -o $@
70    
71     # C/C++ linker
72    
73     LINKER := g++
74     LIBS :=
75     OBJS := GBase.o GStr.o GArgs.o
76    
77     .PHONY : all
78 gpertea 156 all: gtest threads
79 gpertea 18
80     version: ; @echo "GCC Version is: "$(GCC_MAJOR)":"$(GCC_MINOR)":"$(GCC_SUB)
81     @echo "> GCC Opt. string is: "$(GCC45OPTS)
82 gpertea 156 debug: gtest threads
83 gpertea 310 nodebug: gtest threads
84     gtest.o : GBase.h GArgs.h GVec.hh GList.hh GBitVec.h
85 gpertea 18 GArgs.o : GArgs.h
86     gtest: $(OBJS) gtest.o
87     ${LINKER} ${LDFLAGS} $(GCC45OPTS) $(GCC45OPTMAIN) -o $@ ${filter-out %.a %.so, $^} ${LIBS}
88 gpertea 156 threads: GThreads.o threads.o
89     ${LINKER} ${LDFLAGS} $(GCC45OPTS) $(GCC45OPTMAIN) -o $@ ${filter-out %.a %.so, $^} ${TLIBS} ${LIBS}
90     GThreads.o: GThreads.h GThreads.cpp
91     threads.o : GThreads.h GThreads.cpp
92 gpertea 18 # target for removing all object files
93    
94     .PHONY : clean
95     clean::
96 gpertea 156 @${RM} $(OBJS) gtest.o GThreads.o threads.o threads$(EXE) gtest$(EXE)
97 gpertea 18 @${RM} core.*