3131# 09/30/07 adding ubgears, GRAPHIC_TESTS switch
3232# 10/14/07 adding large.txt
3333# 01/13/11 added support for parallel compilation
34+ # 01/07/16 [refer to version control commit messages and
35+ # cease using two-digit years in date formats]
3436# #############################################################################
3537
3638# #############################################################################
3941
4042SHELL = /bin/sh
4143
42- # GRAPHICS TESTS: Uncomment the definition of "GRAPHIC_TESTS" to enable
44+ # GRAPHIC TESTS: Uncomment the definition of "GRAPHIC_TESTS" to enable
4345# the building of the graphics benchmarks. This will require the
44- # X11 libraries on your system.
46+ # X11 libraries on your system. (e.g. libX11-devel mesa-libGL-devel)
4547#
4648# Comment the line out to disable these tests.
4749# GRAPHIC_TESTS = defined
@@ -71,14 +73,33 @@ CC=gcc
7173# -m386 -malign-loops=1 -malign-jumps=1 -malign-functions=1
7274
7375# # For Solaris 2, or general-purpose GCC 2.7.x
74- OPTON = -O2 -fomit-frame-pointer -fforce-addr -ffast-math -Wall
76+ # OPTON = -O2 -fomit-frame-pointer -fforce-addr -ffast-math -Wall
7577
7678# # For Digital Unix v4.x, with DEC cc v5.x
7779# OPTON = -O4
7880# CFLAGS = -DTIME -std1 -verbose -w0
7981
82+ # # gcc optimization flags
83+ # # (-ffast-math) disables strict IEEE or ISO rules/specifications for math funcs
84+ OPTON = -O3 -ffast-math
85+
86+ # # OS detection. Comment out if gmake syntax not supported by other 'make'.
87+ OSNAME: =$(shell uname -s)
88+
89+ ifeq ($(OSNAME ) ,Linux)
90+ OPTON += -march=native -mtune=native
91+ endif
92+ ifeq ($(OSNAME ) ,Darwin)
93+ # (adjust flags or comment out this section for older versions of XCode or OS X)
94+ # (-mmacosx-versin-min= requires at least that version of SDK be installed)
95+ OPTON += -march=native -mmacosx-version-min=10.10
96+ # http://stackoverflow.com/questions/9840207/how-to-use-avx-pclmulqdq-on-mac-os-x-lion/19342603#19342603
97+ CFLAGS += -Wa,-q
98+ endif
99+
100+
80101# # generic gcc CFLAGS. -DTIME must be included.
81- CFLAGS = -DTIME - Wall -pedantic -ansi
102+ CFLAGS = -Wall -pedantic $( OPTON ) -I $( SRCDIR ) -DTIME
82103
83104
84105# #############################################################################
@@ -104,7 +125,7 @@ SOURCES = arith.c big.c context1.c \
104125 dhry_1.c dhry_2.c dhry.h whets.c ubgears.c
105126TESTS = sort.src cctest.c dc.dat large.txt
106127
107- ifdef GRAPHIC_TESTS
128+ ifneq (, $( GRAPHIC_TESTS ) )
108129GRAPHIC_BINS = $(PROGDIR ) /ubgears
109130else
110131GRAPHIC_BINS =
@@ -128,13 +149,15 @@ REQD = $(BINS) $(PROGDIR)/unixbench.logo \
128149 $(TESTDIR ) /large.txt
129150
130151# ######################### the big ALL ############################
131- all : distr programs
152+ all :
132153# # Ick!!! What is this about??? How about let's not chmod everything bogusly.
133154# @chmod 744 * $(SRCDIR)/* $(PROGDIR)/* $(TESTDIR)/* $(DOCDIR)/*
155+ $(MAKE) distr
156+ $(MAKE) programs
134157
135158# ####################### a check for Run ######################
136159check : $(REQD )
137- make all
160+ $( MAKE ) all
138161# ##############################################################
139162# distribute the files out to subdirectories if they are in this one
140163distr :
@@ -178,76 +201,86 @@ distr:
178201 echo "$(RESULTDIR) exists" \
179202 ; fi
180203
204+ .PHONY : all check distr programs run clean spotless
205+
181206programs : $(BINS )
182207
208+ # (use $< to link only the first dependency, instead of $^,
209+ # since the programs matching this pattern have only
210+ # one input file, and others are #include "xxx.c"
211+ # within the first. (not condoning, just documenting))
212+ # (dependencies could be generated by modern compilers,
213+ # but let's not assume modern compilers are present)
214+ $(PROGDIR ) /% :
215+ $(CC ) -o $@ $(CFLAGS ) $< $(LDFLAGS )
216+
183217# Individual programs
184- $(PROGDIR ) /arithoh : $(SRCDIR ) /arith.c
185- $(CC ) -o $(PROGDIR ) /arithoh ${CFLAGS} ${OPTON} -Darithoh $(SRCDIR ) /arith.c
186- $(PROGDIR ) /register : $(SRCDIR ) /arith.c
187- $(CC ) -o $(PROGDIR ) /register ${CFLAGS} ${OPTON} -Ddatum=' register int' $(SRCDIR ) /arith.c
188- $(PROGDIR ) /short : $(SRCDIR ) /arith.c
189- $(CC ) -o $(PROGDIR ) /short ${CFLAGS} ${OPTON} -Ddatum=short $(SRCDIR ) /arith.c
190- $(PROGDIR ) /int : $(SRCDIR ) /arith.c
191- $(CC ) -o $(PROGDIR ) /int ${CFLAGS} ${OPTON} -Ddatum=int $(SRCDIR ) /arith.c
192- $(PROGDIR ) /long : $(SRCDIR ) /arith.c
193- $(CC ) -o $(PROGDIR ) /long ${CFLAGS} ${OPTON} -Ddatum=long $(SRCDIR ) /arith.c
194- $(PROGDIR ) /float : $(SRCDIR ) /arith.c
195- $(CC ) -o $(PROGDIR ) /float ${CFLAGS} ${OPTON} -Ddatum=float $(SRCDIR ) /arith.c
196- $(PROGDIR ) /double : $(SRCDIR ) /arith.c
197- $(CC ) -o $(PROGDIR ) /double ${CFLAGS} ${OPTON} -Ddatum=double $(SRCDIR ) /arith.c
218+ # Sometimes the same source file is compiled in different ways.
219+ # This limits the 'make' patterns that can usefully be applied.
220+
221+ $(PROGDIR ) /arithoh : $(SRCDIR ) /arith.c $(SRCDIR ) /timeit.c
222+ $(PROGDIR ) /arithoh : CFLAGS += -Darithoh
223+ $(PROGDIR ) /register : $(SRCDIR ) /arith.c $(SRCDIR ) /timeit.c
224+ $(PROGDIR ) /register : CFLAGS += -Ddatum='register int'
225+ $(PROGDIR ) /short : $(SRCDIR ) /arith.c $(SRCDIR ) /timeit.c
226+ $(PROGDIR ) /short : CFLAGS += -Ddatum=short
227+ $(PROGDIR ) /int : $(SRCDIR ) /arith.c $(SRCDIR ) /timeit.c
228+ $(PROGDIR ) /int : CFLAGS += -Ddatum=int
229+ $(PROGDIR ) /long : $(SRCDIR ) /arith.c $(SRCDIR ) /timeit.c
230+ $(PROGDIR ) /long : CFLAGS += -Ddatum=long
231+ $(PROGDIR ) /float : $(SRCDIR ) /arith.c $(SRCDIR ) /timeit.c
232+ $(PROGDIR ) /float : CFLAGS += -Ddatum=float
233+ $(PROGDIR ) /double : $(SRCDIR ) /arith.c $(SRCDIR ) /timeit.c
234+ $(PROGDIR ) /double : CFLAGS += -Ddatum=double
235+
236+ $(PROGDIR ) /poll : $(SRCDIR ) /time-polling.c
237+ $(PROGDIR ) /poll : CFLAGS += -DUNIXBENCH -DHAS_POLL
238+ $(PROGDIR ) /poll2 : $(SRCDIR ) /time-polling.c
239+ $(PROGDIR ) /poll2 : CFLAGS += -DUNIXBENCH -DHAS_POLL2
240+ $(PROGDIR ) /select : $(SRCDIR ) /time-polling.c
241+ $(PROGDIR ) /select : CFLAGS += -DUNIXBENCH -DHAS_SELECT
242+
198243$(PROGDIR ) /whetstone-double : $(SRCDIR ) /whets.c
199- $(CC ) -o $(PROGDIR ) /whetstone-double ${CFLAGS} ${OPTON} -DDP -DUNIX -DUNIXBENCH $(SRCDIR ) /whets.c -lm
200- $(PROGDIR ) /hanoi : $(SRCDIR ) /hanoi.c
201- $(CC ) -o $(PROGDIR ) /hanoi ${CFLAGS} ${OPTON} $(SRCDIR ) /hanoi.c
244+ $(PROGDIR ) /whetstone-double : CFLAGS += -DDP -DUNIX -DUNIXBENCH
245+ $(PROGDIR ) /whetstone-double : LDFLAGS += -lm
202246
203- $(PROGDIR ) /poll : $(SRCDIR ) /time-polling.c
204- $(CC ) -DHAS_POLL -DUNIXBENCH -o $(PROGDIR ) /poll ${CFLAGS} ${OPTON} $(SRCDIR ) /time-polling.c
247+ $(PROGDIR ) /pipe : $(SRCDIR ) /pipe.c $(SRCDIR ) /timeit.c
205248
206- $(PROGDIR ) /poll2 : $(SRCDIR ) /time-polling.c
207- $(CC ) -DHAS_POLL2 -DUNIXBENCH -o $(PROGDIR ) /poll2 ${CFLAGS} ${OPTON} $(SRCDIR ) /time-polling.c
249+ $(PROGDIR ) /execl : $(SRCDIR ) /execl.c $(SRCDIR ) /big.c
250+
251+ $(PROGDIR ) /spawn : $(SRCDIR ) /spawn.c $(SRCDIR ) /timeit.c
208252
209- $(PROGDIR ) /select : $(SRCDIR ) /time-polling.c
210- $(CC ) -DHAS_SELECT -DUNIXBENCH -o $(PROGDIR ) /select ${CFLAGS} ${OPTON} $(SRCDIR ) /time-polling.c
253+ $(PROGDIR ) /hanoi : $(SRCDIR ) /hanoi.c $(SRCDIR ) /timeit.c
211254
212255$(PROGDIR ) /fstime : $(SRCDIR ) /fstime.c
213- $(CC ) -o $(PROGDIR ) /fstime ${CFLAGS} ${OPTON} $(SRCDIR ) /fstime.c
214-
215- $(PROGDIR ) /syscall : $(SRCDIR ) /syscall.c
216- $(CC ) -o $(PROGDIR ) /syscall ${CFLAGS} ${OPTON} $(SRCDIR ) /syscall.c
217- $(PROGDIR ) /context1 : $(SRCDIR ) /context1.c
218- $(CC ) -o $(PROGDIR ) /context1 ${CFLAGS} ${OPTON} $(SRCDIR ) /context1.c
219- $(PROGDIR ) /pipe : $(SRCDIR ) /pipe.c
220- $(CC ) -o $(PROGDIR ) /pipe ${CFLAGS} ${OPTON} $(SRCDIR ) /pipe.c
221- $(PROGDIR ) /spawn : $(SRCDIR ) /spawn.c
222- $(CC ) -o $(PROGDIR ) /spawn ${CFLAGS} ${OPTON} $(SRCDIR ) /spawn.c
223- $(PROGDIR ) /execl : $(SRCDIR ) /execl.c $(SRCDIR ) /big.c
224- $(CC ) -o $(PROGDIR ) /execl ${CFLAGS} ${OPTON} $(SRCDIR ) /execl.c
225-
226- $(PROGDIR ) /dhry2 : $(SRCDIR ) /dhry_1.c $(SRCDIR ) /dhry_2.c $(SRCDIR ) /dhry.h
227- cd $(SRCDIR ) ; $(CC ) -c ${CFLAGS} -DHZ=${HZ} ${OPTON} dhry_1.c
228- cd $(SRCDIR ) ; $(CC ) -c ${CFLAGS} -DHZ=${HZ} ${OPTON} dhry_2.c
229- $(CC ) -o $(PROGDIR ) /dhry2 ${CFLAGS} ${OPTON} $(SRCDIR ) /dhry_1.o $(SRCDIR ) /dhry_2.o
230- cd $(SRCDIR ) ; rm -f dhry_1.o dhry_2.o
231- $(PROGDIR ) /dhry2reg : $(SRCDIR ) /dhry_1.c $(SRCDIR ) /dhry_2.c $(SRCDIR ) /dhry.h
232- cd $(SRCDIR ) ; $(CC ) -c ${CFLAGS} -DREG=register -DHZ=${HZ} ${OPTON} dhry_1.c -o dhry_1_reg.o
233- cd $(SRCDIR ) ; $(CC ) -c ${CFLAGS} -DREG=register -DHZ=${HZ} ${OPTON} dhry_2.c -o dhry_2_reg.o
234- $(CC ) -o $(PROGDIR ) /dhry2reg ${CFLAGS} ${OPTON} $(SRCDIR ) /dhry_1_reg.o $(SRCDIR ) /dhry_2_reg.o
235- cd $(SRCDIR ) ; rm -f dhry_1_reg.o dhry_2_reg.o
236-
237- $(PROGDIR ) /looper : $(SRCDIR ) /looper.c
238- $(CC ) -o $(PROGDIR ) /looper ${CFLAGS} ${OPTON} $(SRCDIR ) /looper.c
256+
257+ $(PROGDIR ) /syscall : $(SRCDIR ) /syscall.c $(SRCDIR ) /timeit.c
258+
259+ $(PROGDIR ) /context1 : $(SRCDIR ) /context1.c $(SRCDIR ) /timeit.c
260+
261+ $(PROGDIR ) /looper : $(SRCDIR ) /looper.c $(SRCDIR ) /timeit.c
239262
240263$(PROGDIR ) /ubgears : $(SRCDIR ) /ubgears.c
241- $(CC ) -o $(PROGDIR ) /ubgears ${CFLAGS} ${OPTON} $(SRCDIR ) /ubgears.c $(GL_LIBS )
264+ $(PROGDIR ) /ubgears : LDFLAGS += -lm $(GL_LIBS )
265+
266+ $(PROGDIR ) /dhry2 : CFLAGS += -DHZ=${HZ}
267+ $(PROGDIR ) /dhry2 : $(SRCDIR ) /dhry_1.c $(SRCDIR ) /dhry_2.c \
268+ $(SRCDIR)/dhry.h $(SRCDIR)/timeit.c
269+ $(CC) -o $@ ${CFLAGS} $(SRCDIR)/dhry_1.c $(SRCDIR)/dhry_2.c
270+
271+ $(PROGDIR ) /dhry2reg : CFLAGS += -DHZ=${HZ} -DREG=register
272+ $(PROGDIR ) /dhry2reg : $(SRCDIR ) /dhry_1.c $(SRCDIR ) /dhry_2.c \
273+ $(SRCDIR)/dhry.h $(SRCDIR)/timeit.c
274+ $(CC) -o $@ ${CFLAGS} $(SRCDIR)/dhry_1.c $(SRCDIR)/dhry_2.c
242275
243276# Run the benchmarks and create the reports
244277run :
245278 sh ./Run
246279
247280clean :
248- rm -f $(BINS ) core * ~ * /* ~
281+ $( RM ) $(BINS ) core * ~ * /* ~
249282
250283spotless : clean
251- rm -f $(RESULTDIR ) /* $(TMPDIR ) /*
284+ $( RM ) $(RESULTDIR ) /* $(TMPDIR ) /*
252285
253286# # END ##
0 commit comments