1 |
williamc |
1.1 |
# Some Pre-Defined Rules For Building Stuff
|
2 |
|
|
#
|
3 |
williamc |
1.5 |
#include compilers.mk
|
4 |
williamc |
1.2 |
lib : dependencies.mk
|
5 |
|
|
bin : dependencies.mk
|
6 |
williamc |
1.1 |
|
7 |
|
|
#------------------------------------------------
|
8 |
|
|
# Default Behaviours - interpreted from makefile
|
9 |
|
|
#------------------------------------------------
|
10 |
williamc |
1.6 |
# -- storage of binaries
|
11 |
|
|
binarystore:=$(LOCALTOP)/$(INTbin)
|
12 |
|
|
VPATH+=:$(LOCALTOP)/$(INTbin):$(RELEASETOP)/$(INTbin)
|
13 |
williamc |
1.1 |
|
14 |
|
|
# -- storage of libraries
|
15 |
|
|
librarystore:=$(LOCALTOP)/$(INTlib)
|
16 |
|
|
vpath %.$(SharedSuffix) $(librarystore):$(RELEASETOP)/$(INTlib)
|
17 |
|
|
vpath %.$(ArchiveSuffix) $(librarystore):$(RELEASETOP)/$(INTlib)
|
18 |
|
|
|
19 |
|
|
# -- library names
|
20 |
|
|
|
21 |
|
|
ifdef libname
|
22 |
|
|
ifndef arlibname
|
23 |
|
|
arlibname=$(libname)
|
24 |
|
|
endif
|
25 |
|
|
ifndef shlibname
|
26 |
|
|
shlibname=$(libname)
|
27 |
|
|
endif
|
28 |
|
|
endif
|
29 |
|
|
|
30 |
|
|
# -- Libray type defaults
|
31 |
|
|
|
32 |
|
|
ifdef DefaultShared
|
33 |
|
|
lib : $(shlibname).$(SharedSuffix)
|
34 |
|
|
MakeLib=yes
|
35 |
|
|
endif
|
36 |
|
|
ifdef DefaultDebugShared
|
37 |
|
|
lib : $(shlibname)_d.$(SharedSuffix)
|
38 |
|
|
MakeLib=yes
|
39 |
|
|
endif
|
40 |
|
|
ifdef DefaultArchive
|
41 |
|
|
lib : $(arlibname).$(ArchiveSuffix)
|
42 |
|
|
MakeLib=yes
|
43 |
|
|
endif
|
44 |
|
|
ifdef DefaultDebugArchive
|
45 |
|
|
lib : $(arlibname)_d.$(ArchiveSuffix)
|
46 |
|
|
MakeLib=yes
|
47 |
|
|
endif
|
48 |
|
|
|
49 |
|
|
ifdef MakeLib
|
50 |
|
|
all: lib
|
51 |
|
|
endif
|
52 |
|
|
|
53 |
|
|
#------------------------------------------------
|
54 |
|
|
# Set up some system variables
|
55 |
|
|
# - all begin with S
|
56 |
|
|
#------------------------------------------------
|
57 |
|
|
|
58 |
|
|
Sarchivelibobjs:=$(addsuffix .o,$(archivefiles))
|
59 |
|
|
Sarchivelibdebugobjs:=$(addsuffix _d.o,$(archivefiles))
|
60 |
|
|
Ssharedlibobjs:=$(addsuffix _pic.o,$(sharedfiles))
|
61 |
|
|
Ssharedlibdebugobjs:=$(addsuffix _picd.o,$(sharedfiles))
|
62 |
|
|
|
63 |
williamc |
1.7 |
# binary target files
|
64 |
|
|
Sbinaryobjects:=$(addsuffix .o,$(binfiles))
|
65 |
|
|
|
66 |
williamc |
1.1 |
#------------------------------------------------
|
67 |
|
|
# Rules Start Here
|
68 |
|
|
#------------------------------------------------
|
69 |
|
|
|
70 |
|
|
# Implicit Rules first
|
71 |
|
|
# -- Standard Shared Objects
|
72 |
|
|
%_pic.o : %.cpp
|
73 |
|
|
$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(SharedCCObjectFlags) $< -o $@
|
74 |
|
|
%_pic.o : %.C
|
75 |
|
|
$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(SharedCCObjectFlags) $< -o $@
|
76 |
|
|
%_pic.o : %.cc
|
77 |
|
|
$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(SharedCCObjectFlags) $< -o $@
|
78 |
|
|
%_pic.o : %.F
|
79 |
|
|
$(FC) -c $(CPPFLAGS) $(FFLAGS) $(SharedFCObjectFlags) $< -o $@
|
80 |
|
|
%_pic.o : %.f
|
81 |
|
|
$(FC) -c $(CPPFLAGS) $(FFLAGS) $(SharedFCObjectFlags) $< -o $@
|
82 |
|
|
|
83 |
|
|
# -- Debug Shared Objects
|
84 |
|
|
%_picd.o : %.cc
|
85 |
|
|
$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CXXDebugFlag) $(SharedCCObjectFlags) $< -o $@
|
86 |
|
|
|
87 |
|
|
%_picd.o : %.C
|
88 |
|
|
$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CXXDebugFlag) $(SharedCCObjectFlags) $< -o $@
|
89 |
|
|
|
90 |
|
|
%_picd.o : %.cpp
|
91 |
|
|
$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CXXDebugFlag) $(SharedCCObjectFlags) $< -o $@
|
92 |
|
|
|
93 |
|
|
%_picd.o : %.F
|
94 |
|
|
$(FC) -c $(CPPFLAGS) $(FFLAGS) $(FCDebugFlag) $(SharedFCObjectFlags) $< -o $@
|
95 |
|
|
|
96 |
|
|
%_picd.o : %.f
|
97 |
|
|
$(FC) -c $(CPPFLAGS) $(FFLAGS) $(FCDebugFlag) $(SharedFCObjectFlags) $< -o $@
|
98 |
|
|
# -- Standard Archive Libs
|
99 |
|
|
# Already built in
|
100 |
|
|
|
101 |
|
|
# -- Debug Archive Libs
|
102 |
|
|
%_d.o : %.cpp
|
103 |
|
|
$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CXXDebugFlag) $< -o $@
|
104 |
|
|
|
105 |
|
|
%_d.o : %.cc
|
106 |
|
|
$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CXXDebugFlag) $< -o $@
|
107 |
|
|
|
108 |
|
|
%_d.o : %.C
|
109 |
|
|
$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CXXDebugFlag) $< -o $@
|
110 |
|
|
|
111 |
|
|
%_d.o : %.F
|
112 |
|
|
$(FC) -c $(CPPFLAGS) $(FFLAGS) $(FCDebugFlag) $< -o $@
|
113 |
|
|
|
114 |
|
|
%_d.o : %.f
|
115 |
|
|
$(FC) -c $(CPPFLAGS) $(FFLAGS) $(FCDebugFlag) $< -o $@
|
116 |
williamc |
1.6 |
|
117 |
williamc |
1.7 |
# -------------------------------------------------------------------------
|
118 |
williamc |
1.6 |
|
119 |
williamc |
1.7 |
# -- Debug Exexcutables
|
120 |
williamc |
1.6 |
|
121 |
williamc |
1.10 |
lib_d:=$(shell $(TOOL_HOME)/LibTypeExpand "_d" $(lib))
|
122 |
|
|
LDLIBS_D=$(addprefix -l,$(lib_d))
|
123 |
|
|
|
124 |
williamc |
1.9 |
%_d.exe :
|
125 |
williamc |
1.11 |
$(CXX) $(CXXFLAGS) $(CXXDebugFlag) $(LDFLAGS) $< -o $@ $(LDLIBS_D)
|
126 |
|
|
|
127 |
|
|
# -- Executables
|
128 |
|
|
%.exe : %.o
|
129 |
|
|
$(CXX) $(CXXFLAGS) $(LDFLAGS) $< -o $@ $(LDLIBS)
|
130 |
williamc |
1.6 |
|
131 |
williamc |
1.7 |
realbins:=$(filter $(bintargets),$(notdir $(wildcard $(LOCALTOP)/$(INTbin)/*)))
|
132 |
|
|
clean ::
|
133 |
|
|
@if [ "$(realbins)" != "" ] ; then \
|
134 |
|
|
echo Removing executables : $(realbins); \
|
135 |
|
|
rm $(LOCALTOP)/$(INTbin)/$(realbins); \
|
136 |
|
|
fi;
|
137 |
williamc |
1.6 |
|
138 |
williamc |
1.7 |
# -------------------------------------------------------------------------
|
139 |
williamc |
1.1 |
|
140 |
|
|
# Some nice generic target names for the user
|
141 |
|
|
|
142 |
|
|
shared : $(shlibname).$(SharedSuffix)
|
143 |
|
|
shared_debug : $(shlibname)_d.$(SharedSuffix)
|
144 |
|
|
archive : $(arlibname).$(ArchiveSuffix)
|
145 |
|
|
archive_debug : $(arlibname)_d.$(ArchiveSuffix)
|
146 |
|
|
|
147 |
|
|
# Now more specific rules
|
148 |
|
|
|
149 |
|
|
# -- Standard Shared Objects Libs
|
150 |
williamc |
1.3 |
$(shlibname)_pic.$(SharedSuffix) : $(Ssharedlibobjs)
|
151 |
williamc |
1.1 |
$(SharedCCTool)
|
152 |
williamc |
1.3 |
|
153 |
|
|
$(shlibname).$(SharedSuffix) : $(shlibname)_pic.$(SharedSuffix)
|
154 |
|
|
@mv $< $(librarystore)/$@
|
155 |
williamc |
1.1 |
|
156 |
|
|
# -- Debug Shared Objects Libs
|
157 |
williamc |
1.3 |
$(shlibname)_picd.$(SharedSuffix) : $(Ssharedlibdebugobjs)
|
158 |
williamc |
1.1 |
$(SharedCCTool)
|
159 |
williamc |
1.3 |
|
160 |
williamc |
1.4 |
$(shlibname)_d.$(SharedSuffix) : $(Ssharedlibdebugobjs)
|
161 |
williamc |
1.3 |
@mv $< $(librarystore)/$@
|
162 |
williamc |
1.1 |
|
163 |
|
|
# -- Standard Archive Libs
|
164 |
|
|
$(arlibname).$(ArchiveSuffix) : $(Sarchivelibobjs)
|
165 |
|
|
$(ArchiveCCTool)
|
166 |
williamc |
1.8 |
@mv $@ $(librarystore)/$@
|
167 |
williamc |
1.1 |
|
168 |
|
|
# -- Debug Archive Libs
|
169 |
|
|
$(arlibname)_d.$(ArchiveSuffix) : $(Sarchivelibdebugobjs)
|
170 |
|
|
$(ArchiveCCTool)
|
171 |
williamc |
1.7 |
@mv $@ $(librarystore)/$@
|
172 |
williamc |
1.2 |
|
173 |
|
|
# -- Dependencies
|
174 |
|
|
dependencies.mk: $(files)
|
175 |
|
|
@$(DependencyCCTool)
|
176 |
|
|
@$(TOOL_HOME)/DependencyMangler $@
|