mirror of
https://github.com/kdlucas/byte-unixbench.git
synced 2024-12-11 23:30:07 +08:00
Makefile modernization
update optimization flags use Makefile patterns to reduce duplication remove -ansi flag (increase portability) add missing dependencies
This commit is contained in:
parent
64c45b40c0
commit
7f1ddef4e8
@ -31,6 +31,8 @@
|
|||||||
# 09/30/07 adding ubgears, GRAPHIC_TESTS switch
|
# 09/30/07 adding ubgears, GRAPHIC_TESTS switch
|
||||||
# 10/14/07 adding large.txt
|
# 10/14/07 adding large.txt
|
||||||
# 01/13/11 added support for parallel compilation
|
# 01/13/11 added support for parallel compilation
|
||||||
|
# 01/07/16 [refer to version control commit messages and
|
||||||
|
# cease using two-digit years in date formats]
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
@ -39,9 +41,9 @@
|
|||||||
|
|
||||||
SHELL = /bin/sh
|
SHELL = /bin/sh
|
||||||
|
|
||||||
# GRAPHICS TESTS: Uncomment the definition of "GRAPHIC_TESTS" to enable
|
# GRAPHIC TESTS: Uncomment the definition of "GRAPHIC_TESTS" to enable
|
||||||
# the building of the graphics benchmarks. This will require the
|
# the building of the graphics benchmarks. This will require the
|
||||||
# X11 libraries on your system.
|
# X11 libraries on your system. (e.g. libX11-devel mesa-libGL-devel)
|
||||||
#
|
#
|
||||||
# Comment the line out to disable these tests.
|
# Comment the line out to disable these tests.
|
||||||
# GRAPHIC_TESTS = defined
|
# GRAPHIC_TESTS = defined
|
||||||
@ -71,14 +73,33 @@ CC=gcc
|
|||||||
# -m386 -malign-loops=1 -malign-jumps=1 -malign-functions=1
|
# -m386 -malign-loops=1 -malign-jumps=1 -malign-functions=1
|
||||||
|
|
||||||
## For Solaris 2, or general-purpose GCC 2.7.x
|
## For Solaris 2, or general-purpose GCC 2.7.x
|
||||||
OPTON = -O2 -fomit-frame-pointer -fforce-addr -ffast-math -Wall
|
#OPTON = -O2 -fomit-frame-pointer -fforce-addr -ffast-math -Wall
|
||||||
|
|
||||||
## For Digital Unix v4.x, with DEC cc v5.x
|
## For Digital Unix v4.x, with DEC cc v5.x
|
||||||
#OPTON = -O4
|
#OPTON = -O4
|
||||||
#CFLAGS = -DTIME -std1 -verbose -w0
|
#CFLAGS = -DTIME -std1 -verbose -w0
|
||||||
|
|
||||||
|
## gcc optimization flags
|
||||||
|
## (-ffast-math) disables strict IEEE or ISO rules/specifications for math funcs
|
||||||
|
OPTON = -O3 -ffast-math
|
||||||
|
|
||||||
|
## OS detection. Comment out if gmake syntax not supported by other 'make'.
|
||||||
|
OSNAME:=$(shell uname -s)
|
||||||
|
|
||||||
|
ifeq ($(OSNAME),Linux)
|
||||||
|
OPTON += -march=native -mtune=native
|
||||||
|
endif
|
||||||
|
ifeq ($(OSNAME),Darwin)
|
||||||
|
# (adjust flags or comment out this section for older versions of XCode or OS X)
|
||||||
|
# (-mmacosx-versin-min= requires at least that version of SDK be installed)
|
||||||
|
OPTON += -march=native -mmacosx-version-min=10.10
|
||||||
|
#http://stackoverflow.com/questions/9840207/how-to-use-avx-pclmulqdq-on-mac-os-x-lion/19342603#19342603
|
||||||
|
CFLAGS += -Wa,-q
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
## generic gcc CFLAGS. -DTIME must be included.
|
## generic gcc CFLAGS. -DTIME must be included.
|
||||||
CFLAGS = -DTIME -Wall -pedantic -ansi
|
CFLAGS = -Wall -pedantic $(OPTON) -I $(SRCDIR) -DTIME
|
||||||
|
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
@ -104,7 +125,7 @@ SOURCES = arith.c big.c context1.c \
|
|||||||
dhry_1.c dhry_2.c dhry.h whets.c ubgears.c
|
dhry_1.c dhry_2.c dhry.h whets.c ubgears.c
|
||||||
TESTS = sort.src cctest.c dc.dat large.txt
|
TESTS = sort.src cctest.c dc.dat large.txt
|
||||||
|
|
||||||
ifdef GRAPHIC_TESTS
|
ifneq (,$(GRAPHIC_TESTS))
|
||||||
GRAPHIC_BINS = $(PROGDIR)/ubgears
|
GRAPHIC_BINS = $(PROGDIR)/ubgears
|
||||||
else
|
else
|
||||||
GRAPHIC_BINS =
|
GRAPHIC_BINS =
|
||||||
@ -128,13 +149,15 @@ REQD = $(BINS) $(PROGDIR)/unixbench.logo \
|
|||||||
$(TESTDIR)/large.txt
|
$(TESTDIR)/large.txt
|
||||||
|
|
||||||
# ######################### the big ALL ############################
|
# ######################### the big ALL ############################
|
||||||
all: distr programs
|
all:
|
||||||
## Ick!!! What is this about??? How about let's not chmod everything bogusly.
|
## Ick!!! What is this about??? How about let's not chmod everything bogusly.
|
||||||
# @chmod 744 * $(SRCDIR)/* $(PROGDIR)/* $(TESTDIR)/* $(DOCDIR)/*
|
# @chmod 744 * $(SRCDIR)/* $(PROGDIR)/* $(TESTDIR)/* $(DOCDIR)/*
|
||||||
|
$(MAKE) distr
|
||||||
|
$(MAKE) programs
|
||||||
|
|
||||||
# ####################### a check for Run ######################
|
# ####################### a check for Run ######################
|
||||||
check: $(REQD)
|
check: $(REQD)
|
||||||
make all
|
$(MAKE) all
|
||||||
# ##############################################################
|
# ##############################################################
|
||||||
# distribute the files out to subdirectories if they are in this one
|
# distribute the files out to subdirectories if they are in this one
|
||||||
distr:
|
distr:
|
||||||
@ -178,76 +201,86 @@ distr:
|
|||||||
echo "$(RESULTDIR) exists" \
|
echo "$(RESULTDIR) exists" \
|
||||||
; fi
|
; fi
|
||||||
|
|
||||||
|
.PHONY: all check distr programs run clean spotless
|
||||||
|
|
||||||
programs: $(BINS)
|
programs: $(BINS)
|
||||||
|
|
||||||
|
# (use $< to link only the first dependency, instead of $^,
|
||||||
|
# since the programs matching this pattern have only
|
||||||
|
# one input file, and others are #include "xxx.c"
|
||||||
|
# within the first. (not condoning, just documenting))
|
||||||
|
# (dependencies could be generated by modern compilers,
|
||||||
|
# but let's not assume modern compilers are present)
|
||||||
|
$(PROGDIR)/%:
|
||||||
|
$(CC) -o $@ $(CFLAGS) $< $(LDFLAGS)
|
||||||
|
|
||||||
# Individual programs
|
# Individual programs
|
||||||
$(PROGDIR)/arithoh: $(SRCDIR)/arith.c
|
# Sometimes the same source file is compiled in different ways.
|
||||||
$(CC) -o $(PROGDIR)/arithoh ${CFLAGS} ${OPTON} -Darithoh $(SRCDIR)/arith.c
|
# This limits the 'make' patterns that can usefully be applied.
|
||||||
$(PROGDIR)/register: $(SRCDIR)/arith.c
|
|
||||||
$(CC) -o $(PROGDIR)/register ${CFLAGS} ${OPTON} -Ddatum='register int' $(SRCDIR)/arith.c
|
$(PROGDIR)/arithoh: $(SRCDIR)/arith.c $(SRCDIR)/timeit.c
|
||||||
$(PROGDIR)/short: $(SRCDIR)/arith.c
|
$(PROGDIR)/arithoh: CFLAGS += -Darithoh
|
||||||
$(CC) -o $(PROGDIR)/short ${CFLAGS} ${OPTON} -Ddatum=short $(SRCDIR)/arith.c
|
$(PROGDIR)/register: $(SRCDIR)/arith.c $(SRCDIR)/timeit.c
|
||||||
$(PROGDIR)/int: $(SRCDIR)/arith.c
|
$(PROGDIR)/register: CFLAGS += -Ddatum='register int'
|
||||||
$(CC) -o $(PROGDIR)/int ${CFLAGS} ${OPTON} -Ddatum=int $(SRCDIR)/arith.c
|
$(PROGDIR)/short: $(SRCDIR)/arith.c $(SRCDIR)/timeit.c
|
||||||
$(PROGDIR)/long: $(SRCDIR)/arith.c
|
$(PROGDIR)/short: CFLAGS += -Ddatum=short
|
||||||
$(CC) -o $(PROGDIR)/long ${CFLAGS} ${OPTON} -Ddatum=long $(SRCDIR)/arith.c
|
$(PROGDIR)/int: $(SRCDIR)/arith.c $(SRCDIR)/timeit.c
|
||||||
$(PROGDIR)/float: $(SRCDIR)/arith.c
|
$(PROGDIR)/int: CFLAGS += -Ddatum=int
|
||||||
$(CC) -o $(PROGDIR)/float ${CFLAGS} ${OPTON} -Ddatum=float $(SRCDIR)/arith.c
|
$(PROGDIR)/long: $(SRCDIR)/arith.c $(SRCDIR)/timeit.c
|
||||||
$(PROGDIR)/double: $(SRCDIR)/arith.c
|
$(PROGDIR)/long: CFLAGS += -Ddatum=long
|
||||||
$(CC) -o $(PROGDIR)/double ${CFLAGS} ${OPTON} -Ddatum=double $(SRCDIR)/arith.c
|
$(PROGDIR)/float: $(SRCDIR)/arith.c $(SRCDIR)/timeit.c
|
||||||
|
$(PROGDIR)/float: CFLAGS += -Ddatum=float
|
||||||
|
$(PROGDIR)/double: $(SRCDIR)/arith.c $(SRCDIR)/timeit.c
|
||||||
|
$(PROGDIR)/double: CFLAGS += -Ddatum=double
|
||||||
|
|
||||||
|
$(PROGDIR)/poll: $(SRCDIR)/time-polling.c
|
||||||
|
$(PROGDIR)/poll: CFLAGS += -DUNIXBENCH -DHAS_POLL
|
||||||
|
$(PROGDIR)/poll2: $(SRCDIR)/time-polling.c
|
||||||
|
$(PROGDIR)/poll2: CFLAGS += -DUNIXBENCH -DHAS_POLL2
|
||||||
|
$(PROGDIR)/select: $(SRCDIR)/time-polling.c
|
||||||
|
$(PROGDIR)/select: CFLAGS += -DUNIXBENCH -DHAS_SELECT
|
||||||
|
|
||||||
$(PROGDIR)/whetstone-double: $(SRCDIR)/whets.c
|
$(PROGDIR)/whetstone-double: $(SRCDIR)/whets.c
|
||||||
$(CC) -o $(PROGDIR)/whetstone-double ${CFLAGS} ${OPTON} -DDP -DUNIX -DUNIXBENCH $(SRCDIR)/whets.c -lm
|
$(PROGDIR)/whetstone-double: CFLAGS += -DDP -DUNIX -DUNIXBENCH
|
||||||
$(PROGDIR)/hanoi: $(SRCDIR)/hanoi.c
|
$(PROGDIR)/whetstone-double: LDFLAGS += -lm
|
||||||
$(CC) -o $(PROGDIR)/hanoi ${CFLAGS} ${OPTON} $(SRCDIR)/hanoi.c
|
|
||||||
|
|
||||||
$(PROGDIR)/poll: $(SRCDIR)/time-polling.c
|
$(PROGDIR)/pipe: $(SRCDIR)/pipe.c $(SRCDIR)/timeit.c
|
||||||
$(CC) -DHAS_POLL -DUNIXBENCH -o $(PROGDIR)/poll ${CFLAGS} ${OPTON} $(SRCDIR)/time-polling.c
|
|
||||||
|
|
||||||
$(PROGDIR)/poll2: $(SRCDIR)/time-polling.c
|
$(PROGDIR)/execl: $(SRCDIR)/execl.c $(SRCDIR)/big.c
|
||||||
$(CC) -DHAS_POLL2 -DUNIXBENCH -o $(PROGDIR)/poll2 ${CFLAGS} ${OPTON} $(SRCDIR)/time-polling.c
|
|
||||||
|
|
||||||
$(PROGDIR)/select: $(SRCDIR)/time-polling.c
|
$(PROGDIR)/spawn: $(SRCDIR)/spawn.c $(SRCDIR)/timeit.c
|
||||||
$(CC) -DHAS_SELECT -DUNIXBENCH -o $(PROGDIR)/select ${CFLAGS} ${OPTON} $(SRCDIR)/time-polling.c
|
|
||||||
|
$(PROGDIR)/hanoi: $(SRCDIR)/hanoi.c $(SRCDIR)/timeit.c
|
||||||
|
|
||||||
$(PROGDIR)/fstime: $(SRCDIR)/fstime.c
|
$(PROGDIR)/fstime: $(SRCDIR)/fstime.c
|
||||||
$(CC) -o $(PROGDIR)/fstime ${CFLAGS} ${OPTON} $(SRCDIR)/fstime.c
|
|
||||||
|
|
||||||
$(PROGDIR)/syscall: $(SRCDIR)/syscall.c
|
$(PROGDIR)/syscall: $(SRCDIR)/syscall.c $(SRCDIR)/timeit.c
|
||||||
$(CC) -o $(PROGDIR)/syscall ${CFLAGS} ${OPTON} $(SRCDIR)/syscall.c
|
|
||||||
$(PROGDIR)/context1: $(SRCDIR)/context1.c
|
|
||||||
$(CC) -o $(PROGDIR)/context1 ${CFLAGS} ${OPTON} $(SRCDIR)/context1.c
|
|
||||||
$(PROGDIR)/pipe: $(SRCDIR)/pipe.c
|
|
||||||
$(CC) -o $(PROGDIR)/pipe ${CFLAGS} ${OPTON} $(SRCDIR)/pipe.c
|
|
||||||
$(PROGDIR)/spawn: $(SRCDIR)/spawn.c
|
|
||||||
$(CC) -o $(PROGDIR)/spawn ${CFLAGS} ${OPTON} $(SRCDIR)/spawn.c
|
|
||||||
$(PROGDIR)/execl: $(SRCDIR)/execl.c $(SRCDIR)/big.c
|
|
||||||
$(CC) -o $(PROGDIR)/execl ${CFLAGS} ${OPTON} $(SRCDIR)/execl.c
|
|
||||||
|
|
||||||
$(PROGDIR)/dhry2: $(SRCDIR)/dhry_1.c $(SRCDIR)/dhry_2.c $(SRCDIR)/dhry.h
|
$(PROGDIR)/context1: $(SRCDIR)/context1.c $(SRCDIR)/timeit.c
|
||||||
cd $(SRCDIR); $(CC) -c ${CFLAGS} -DHZ=${HZ} ${OPTON} dhry_1.c
|
|
||||||
cd $(SRCDIR); $(CC) -c ${CFLAGS} -DHZ=${HZ} ${OPTON} dhry_2.c
|
|
||||||
$(CC) -o $(PROGDIR)/dhry2 ${CFLAGS} ${OPTON} $(SRCDIR)/dhry_1.o $(SRCDIR)/dhry_2.o
|
|
||||||
cd $(SRCDIR); rm -f dhry_1.o dhry_2.o
|
|
||||||
$(PROGDIR)/dhry2reg: $(SRCDIR)/dhry_1.c $(SRCDIR)/dhry_2.c $(SRCDIR)/dhry.h
|
|
||||||
cd $(SRCDIR); $(CC) -c ${CFLAGS} -DREG=register -DHZ=${HZ} ${OPTON} dhry_1.c -o dhry_1_reg.o
|
|
||||||
cd $(SRCDIR); $(CC) -c ${CFLAGS} -DREG=register -DHZ=${HZ} ${OPTON} dhry_2.c -o dhry_2_reg.o
|
|
||||||
$(CC) -o $(PROGDIR)/dhry2reg ${CFLAGS} ${OPTON} $(SRCDIR)/dhry_1_reg.o $(SRCDIR)/dhry_2_reg.o
|
|
||||||
cd $(SRCDIR); rm -f dhry_1_reg.o dhry_2_reg.o
|
|
||||||
|
|
||||||
$(PROGDIR)/looper: $(SRCDIR)/looper.c
|
$(PROGDIR)/looper: $(SRCDIR)/looper.c $(SRCDIR)/timeit.c
|
||||||
$(CC) -o $(PROGDIR)/looper ${CFLAGS} ${OPTON} $(SRCDIR)/looper.c
|
|
||||||
|
|
||||||
$(PROGDIR)/ubgears: $(SRCDIR)/ubgears.c
|
$(PROGDIR)/ubgears: $(SRCDIR)/ubgears.c
|
||||||
$(CC) -o $(PROGDIR)/ubgears ${CFLAGS} ${OPTON} $(SRCDIR)/ubgears.c $(GL_LIBS)
|
$(PROGDIR)/ubgears: LDFLAGS += -lm $(GL_LIBS)
|
||||||
|
|
||||||
|
$(PROGDIR)/dhry2: CFLAGS += -DHZ=${HZ}
|
||||||
|
$(PROGDIR)/dhry2: $(SRCDIR)/dhry_1.c $(SRCDIR)/dhry_2.c \
|
||||||
|
$(SRCDIR)/dhry.h $(SRCDIR)/timeit.c
|
||||||
|
$(CC) -o $@ ${CFLAGS} $(SRCDIR)/dhry_1.c $(SRCDIR)/dhry_2.c
|
||||||
|
|
||||||
|
$(PROGDIR)/dhry2reg: CFLAGS += -DHZ=${HZ} -DREG=register
|
||||||
|
$(PROGDIR)/dhry2reg: $(SRCDIR)/dhry_1.c $(SRCDIR)/dhry_2.c \
|
||||||
|
$(SRCDIR)/dhry.h $(SRCDIR)/timeit.c
|
||||||
|
$(CC) -o $@ ${CFLAGS} $(SRCDIR)/dhry_1.c $(SRCDIR)/dhry_2.c
|
||||||
|
|
||||||
# Run the benchmarks and create the reports
|
# Run the benchmarks and create the reports
|
||||||
run:
|
run:
|
||||||
sh ./Run
|
sh ./Run
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(BINS) core *~ */*~
|
$(RM) $(BINS) core *~ */*~
|
||||||
|
|
||||||
spotless: clean
|
spotless: clean
|
||||||
rm -f $(RESULTDIR)/* $(TMPDIR)/*
|
$(RM) $(RESULTDIR)/* $(TMPDIR)/*
|
||||||
|
|
||||||
## END ##
|
## END ##
|
||||||
|
Loading…
Reference in New Issue
Block a user