forked from thorfdbg/difftest_ng
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.template
230 lines (190 loc) · 7.43 KB
/
Makefile.template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
#! make
##
## $Id: Makefile.template,v 1.10 2020/09/15 10:20:28 thor Exp $
##
## This makefile template is included by all sub-directories
## to shorten the apropriate sub-makefiles to the minimum
##
## difftest_ng is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## difftest_ng is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with difftest_ng. If not, see <http://www.gnu.org/licenses/>.
##
.PHONY: subclean subfinal subprofile suball subvalgrind subvalfinal subcoverage subzip sublib sublibdebug clean
#####################################################################
##
## Compiler settings
##
## A somewhat hacky solution: If this makefile gets
## called directly, assume we have been invoked from
## a recursive directory make file.
ifndef COMPILER_SETTINGS
AUTOMAKEFILE = $(shell pwd)/../automakefile
COMPILER_SETTINGS = $(shell pwd)/../Makefile_Settings.$(SETTINGS)
endif
-include $(AUTOMAKEFILE)
include $(COMPILER_SETTINGS)
##
## Potentially include addon-settings.
ifeq ($(HAVE_ADDONS),yes)
include $(dir $(COMPILER_SETTINGS))/addons.$(HWTYPE)/Makefile_Settings.$(SETTINGS)
endif
##
##
#####################################################################
##
## Compiler independent commands.
##
ECHO = echo
ZIP = zip
ZIPASCII = zip -l
VALGRIND = -DUSE_VALGRIND=1
AR = ar
AROPTS = -sr
CAT = cat
AUTOCONF = autoconf
AUTOHEADER = autoheader
##
## Definitions for the headers, object codes, sources,....
##
HEADERS = $(foreach file,$(FILES),$(file).hpp)
SOURCES = $(foreach file,$(FILES),$(file).cpp)
ASMSOURCES = $(foreach file,$(ASMFILES),$(file)_$(HWTYPE).S)
SUBHEADERS = $(foreach file,$(FILES),$(DIRNAME)/$(file).hpp)
SUBSOURCES = $(foreach file,$(FILES),$(DIRNAME)/$(file).cpp)
SUBASMSOURCES = $(foreach file,$(ASMFILES),$(DIRNAME)/$(file)_$(HWTYPE).S)
SUBDIST = $(foreach file,$(XDIST),$(DIRNAME)/$(file))
OBJECTS = $(foreach file,$(FILES),$(file).o)
ASMOBJECTS = $(foreach file,$(ASMFILES),$(file)_$(HWTYPE).o)
XHEADERS = $(foreach file,$(XFILES),$(file).hpp)
XSOURCES = $(foreach file,$(XFILES),$(file).cpp)
SUBXHEADERS = $(foreach file,$(XFILES),$(DIRNAME)/$(file).hpp)
SUBXSOURCES = $(foreach file,$(XFILES),$(DIRNAME)/$(file).cpp)
XOBJECTS = $(foreach file,$(XFILES),$(file).o)
LIBNAME = lib$(DIRNAME).a
SLIBNAME = lib_$(DIRNAME).a
##
## Definitions for directories. These are required since
## directories are global.
##
DIRS = cmd diff img interface tools tiff std
INCLUDEOPTS = -I ..
##
## Automatic dependency checking for the GNU environment
##
-include $(OBJECTS:.o=.d) $(CMDOBJ:.o=.d)
%.d: %.cpp
@ $(SHELL) -ec 'gcc $(INCLUDEOPTS) $(DEFINES) $(ADDOPTS) -MM $< \
| sed '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' > $@; \
[ -s $@ ] || rm -f $@'
##
## Default rules for creating files, and assembly...
##
%.o: %.cpp %.hpp
@ $(ECHO) "Compiling" $(DIRNAME)/$*.cpp
@ $(CXX) $(MAKEOBJS) $(INCLUDEOPTS) $(CFLAGS) $(GSL_CFLAGS) $(PNG_CFLAGS) $(EXR_CFLAGS) $(PTHREADCFLAGS) $(ADDFLAGS) $*.cpp
%.o: %.cpp
@ $(ECHO) "Compiling" $(DIRNAME)/$*.cpp
@ $(CXX) $(MAKEOBJS) $(INCLUDEOPTS) $(CFLAGS) $(GSL_CFLAGS) $(PNG_CFLAGS) $(EXR_CFLAGS) $(PTHREADCFLAGS) $(ADDFLAGS) $*.cpp
%.s: %.cpp %.hpp
@ $(ECHO) "Compiling" $(DIRNAME)/$*.cpp
@ $(CXX) $(INCLUDEOPTS) $(CFLAGS) $(GSL_CFLAGS) $(PNG_CFLAGS) $(EXR_CFLAGS) $(PTHREADCFLAGS) $(ADDFLAGS) $(OPTIMIZER) $(TOASM) $*.cpp
%.s: %.cpp
@ $(ECHO) "Compiling" $(DIRNAME)/$*.cpp
@ $(CXX) $(INCLUDEOPTS) $(CFLAGS) $(GSL_CFLAGS) $(PNG_CFLAGS) $(EXR_CFLAGS) $(PTHREADCFLAGS) $(ADDFLAGS) $(OPTIMIZER) $(TOASM) $*.cpp
%.o: %.S
@ $(ECHO) "Assembling" $(DIRNAME)/$*.S
@ $(AS) $(INCLUDEOPTS) $(ASFLAGS) $*.S
##
## The object list for this subdirectory
##
ifeq ($(HAVE_ADDONS),yes)
SUBOBJECTLIST = $(foreach object,$(OBJECTS) $(ASMOBJECTS),$(DIRNAME)/$(object))
else
SUBOBJECTLIST = $(foreach object,$(OBJECTS),$(DIRNAME)/$(object))
endif
SUBXOBJECTLIST = $(foreach object,$(XOBJECTS),$(DIRNAME)/$(object))
##
## Various targets
##
clean : subclean
subclean :
@ rm -rf $(OBJECTS) $(ASMOBJECTS) $(OBJECTS:.o=.s) $(CMDOBJ:.o=.s) $(OBJECTS:.o=.d) $(CMDOBJ:.o=.d) \
$(OBJECTS:.o=.il) $(CMDOBJ:.o=.il) *.a *.rpo *.list
@ rm -rf $(XOBJECTS) $(XOBJECTS:.o=.s) $(XOBJECTS:.o=.d) \
$(XOBJECTS:.o=.il) $(XCMDOBJ:.o=.il)
suball : $(OBJECTS) $(XOBJECTS) $(ASMOBJECTS)
@ $(AR) $(AROPTS) $(LIBNAME) $(OBJECTS) $(XOBJECTS) $(ASMOBJECTS)
@ $(ECHO) >objects.list $(SUBOBJECTLIST) $(SUBXOBJECTLIST)
subliball : $(OBJECTS) $(ASMOBJECTS)
@ $(AR) $(AROPTS) $(SLIBNAME) $(OBJECTS) $(ASMOBJECTS)
@ $(ECHO) >libobjects.list $(SUBOBJECTLIST)
subdebug :
@ $(MAKE) -f $(MAKEFILE) suball SUPER="../" \
ADDFLAGS="$(DEBUGGER)" ADDLIBS="$(DBLIBS)"
subverbose :
@ $(MAKE) -f $(MAKEFILE) suball SUPER="../" \
ADDFLAGS="$(VERBOSE)" ADDLIBS="$(DBLIBS)"
subfinal :
@ $(MAKE) -f $(MAKEFILE) suball SUPER="../" \
ADDFLAGS="$(OPTIMIZER)" ADDLIBS=""
substatic :
@ $(MAKE) -f $(MAKEFILE) suball SUPER="../" \
ADDFLAGS="-static $(OPTIMIZER)" ADDLIBS=""
subglobal :
@ $(MAKE) -f $(MAKEFILE) suball \
ADDFLAGS="$(OPTIMIZER) $(GLOBFLAGS)" ADDLIBS=""
subprofgen :
@ $(MAKE) -f $(MAKEFILE) suball \
ADDFLAGS="$(OPTIMIZER) $(PROFGEN)" ADDLIBS=""
subprofuse :
@ $(MAKE) -f $(MAKEFILE) suball \
ADDFLAGS="$(OPTIMIZER) $(GLOBFLAGS) $(PROFUSE)" ADDLIBS=""
subprofile :
@ $(MAKE) -f $(MAKEFILE) suball SUPER="../" \
ADDFLAGS="$(OPTIMIZER) $(PROFILER)" ADDLIBS="$(LDPROF)"
subvalgrind :
@ $(MAKE) -f $(MAKEFILE) suball SUPER="../" \
ADDFLAGS="$(DEBUGGER) $(VALGRIND)" ADDLIBS="$(LDPROF)"
subvalfinal :
@ $(MAKE) -f $(MAKEFILE) suball SUPER="../" \
ADDFLAGS="$(DEBUGINFO) $(VALGRIND) $(OPTIMIZER)" ADDLIBS="$(LDPROF)"
subcoverage :
@ $(MAKE) -f $(MAKEFILE) suball SUPER="../" \
ADDFLAGS="$(DEBUGGER) $(COVERAGE)" ADDLIBS="$(LDPROF)"
sublib :
@ $(MAKE) -f $(MAKEFILE) subliball SUPER="../" \
ADDFLAGS="$(OPTIMIZER) $(LIB_OPTS)" ADDLIBS=""
sublibdebug :
@ $(MAKE) -f $(MAKEFILE) subliball SUPER="../" \
ADDFLAGS="$(DEBUGGER) $(LIB_OPTS)" ADDLIBS=""
#
# The next adds the .cpp and .hpp files into the
# sources expanding TABs to spaces. This is a wierd hack
# since we must make "zip" believe that it operates on the
# same local directory.
subzip : $(SOURCES) $(HEADERS) $(XHEADERS) $(XSOURCES)
@ echo "Adding" $(SUBSOURCES) $(SUBHEADERS) $(SUBXSOURCES) $(SUBXHEADERS) \
$(DIRNAME)/Makefile /tmp/$(DIRNAME)
@ rm -rf /tmp/__out__
@ rm -rf /tmp/$(DIRNAME)
@ mkdir /tmp/$(DIRNAME)
@ cd .. && cp $(SUBSOURCES) $(SUBHEADERS) $(SUBXSOURCES) $(SUBXHEADERS) $(SUBDIST) \
$(DIRNAME)/Makefile /tmp/$(DIRNAME)
@ cd .. && for i in $(DIRNAME)/Makefile.*[!~];do if test -f $$i; then cp $$i /tmp/$(DIRNAME); fi; done
@ find /tmp/$(DIRNAME) -name "*.hpp" -exec echo pr -e -t {} \>/tmp/__out__ \&\& cp /tmp/__out__ {} \; | sh
@ find /tmp/$(DIRNAME) -name "*.cpp" -exec echo pr -e -t {} \>/tmp/__out__ \&\& cp /tmp/__out__ {} \; | sh
@ find /tmp/$(DIRNAME) -name "*.asm" -exec echo pr -e -t {} \>/tmp/__out__ \&\& cp /tmp/__out__ {} \; | sh
@ rm -rf /tmp/__out__
@ cd /tmp && $(ZIP) -r $(shell pwd)/../Distrib.zip \
$(SUBSOURCES) $(SUBHEADERS) $(SUBXSOURCES) $(SUBXHEADERS) \
$(SUBDIST) $(DIRNAME)/Makefile*
@ rm -rf /tmp/$(DIRNAME)