From: Akira Yokosawa <akiyks@gmail.com>
To: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: perfbook@vger.kernel.org, Akira Yokosawa <akiyks@gmail.com>
Subject: [RFC PATCH 1/4] CodeSamples: Add rule to generate Makefile.arch and api.h
Date: Tue, 30 May 2017 07:14:57 +0900 [thread overview]
Message-ID: <14adfa18-9518-e56a-ae40-81fbd06c0fb7@gmail.com> (raw)
In-Reply-To: <f9df1cc9-32af-951c-1f89-b89331c9dce9@gmail.com>
From b4845ac3b17aaade7258528fa114def5f6554242 Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <akiyks@gmail.com>
Date: Sun, 28 May 2017 09:29:44 +0900
Subject: [RFC PATCH 1/4] CodeSamples: Add rule to generate Makefile.arch and api.h
To generate suitable Makefile.arch and api.h for host arch,
describe the dependency in depends.mk and include it in Makefiles.
Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
---
CodeSamples/Makefile | 18 +++++++++++++
CodeSamples/SMPdesign/Makefile | 3 +++
CodeSamples/advsync/Makefile | 3 +++
CodeSamples/count/Makefile | 3 +++
CodeSamples/datastruct/Issaquah/Makefile | 3 +++
CodeSamples/datastruct/hash/Makefile | 3 +++
CodeSamples/datastruct/log/Makefile | 3 +++
CodeSamples/datastruct/skiplist/Makefile | 3 +++
CodeSamples/defer/Makefile | 3 +++
CodeSamples/depends.mk | 43 ++++++++++++++++++++++++++++++++
CodeSamples/intro/Makefile | 3 +++
CodeSamples/locking/Makefile | 3 +++
CodeSamples/toolsoftrade/Makefile | 3 +++
13 files changed, 94 insertions(+)
create mode 100644 CodeSamples/depends.mk
diff --git a/CodeSamples/Makefile b/CodeSamples/Makefile
index f5461e9..4168220 100644
--- a/CodeSamples/Makefile
+++ b/CodeSamples/Makefile
@@ -1,3 +1,7 @@
+.PHONY: all clean pthreads pthreads-x86 pthreads-ppc64 pthreads-arm
+
+top := .
+
all:
(cd SMPdesign; make)
(cd advsync; make)
@@ -6,6 +10,17 @@ all:
(cd intro; make)
(cd toolsoftrade; make)
+include depends.mk
+
+api.h Makefile.arch:
+ifeq ($(strip $(target)),)
+ make pthreads
+ $(warning "Could not figure out which target to use (arch:$(arch)).\
+ Used 'make pthreads' in CodeSamples/Makefile.")
+else
+ make pthreads-$(target)
+endif
+
pthreads:
echo "#ifndef __PERFBOOK_API_H__" > api.h
echo "#define __PERFBOOK_API_H__" >> api.h
@@ -125,3 +140,6 @@ pthreads-arm:
echo "#endif /* #ifndef __PERFBOOK_API_H__ */" >> api.h
echo "# MECHANICALLY GENERATED, DO NOT EDIT!!!" > Makefile.arch
cat arch-arm/Makefile.arch >> Makefile.arch
+
+clean:
+ rm -f Makefile.arch api.h
diff --git a/CodeSamples/SMPdesign/Makefile b/CodeSamples/SMPdesign/Makefile
index ae0cdd7..d03575c 100644
--- a/CodeSamples/SMPdesign/Makefile
+++ b/CodeSamples/SMPdesign/Makefile
@@ -25,6 +25,9 @@ include ../Makefile.arch
# http://www.ibm.com/developerworks/wikis/display/hpccentral/Tuning+options+to+consider+with+gcc#Tuningoptionstoconsiderwithgcc-mcpuandmtune
# GCC_ARGS=-g -O3 -m64 -mcpu=power5 -mtune=power5
+top := ..
+include $(top)/depends.mk
+
smpalloc: smpalloc.c ../api.h
cc $(GCC_ARGS) -g -o smpalloc -DTEST smpalloc.c -lpthread
diff --git a/CodeSamples/advsync/Makefile b/CodeSamples/advsync/Makefile
index b02ca37..bb4c8fc 100644
--- a/CodeSamples/advsync/Makefile
+++ b/CodeSamples/advsync/Makefile
@@ -20,6 +20,9 @@ PROGS = q singleq wfenqueue
all: $(PROGS)
+top := ..
+include $(top)/depends.mk
+
q: q.c q.h queuetorture.h ../api.h
cc $(GCC_ARGS) -o q -DTEST q.c -lpthread
diff --git a/CodeSamples/count/Makefile b/CodeSamples/count/Makefile
index 05fcf04..d3fbb83 100644
--- a/CodeSamples/count/Makefile
+++ b/CodeSamples/count/Makefile
@@ -35,6 +35,9 @@ RCU_SRCS = ../defer/rcu_nest32.h ../defer/rcu_nest32.c
all: $(PROGS)
+top := ..
+include $(top)/depends.mk
+
count_atomic: count_atomic.c ../api.h counttorture.h
cc $(GCC_ARGS) $(CFLAGS) -o count_atomic count_atomic.c -lpthread
diff --git a/CodeSamples/datastruct/Issaquah/Makefile b/CodeSamples/datastruct/Issaquah/Makefile
index 013738c..bb3d6a3 100644
--- a/CodeSamples/datastruct/Issaquah/Makefile
+++ b/CodeSamples/datastruct/Issaquah/Makefile
@@ -21,6 +21,9 @@ LIB = ../../lib
all: $(PROGS)
+top := ../..
+include $(top)/depends.mk
+
# NOTE: For decent scalability on update-side tests as of early 2015,
# use something like jemalloc() instead of glibc malloc().
# If you install jemalloc at /home/paulmck/jemalloc, you will
diff --git a/CodeSamples/datastruct/hash/Makefile b/CodeSamples/datastruct/hash/Makefile
index a87bdbb..85dfa5d 100644
--- a/CodeSamples/datastruct/hash/Makefile
+++ b/CodeSamples/datastruct/hash/Makefile
@@ -20,6 +20,9 @@ PROGS = hash_bkt hash_bkt_hazptr hash_bkt_rcu hash_global hash_resize
all: $(PROGS)
+top := ../..
+include $(top)/depends.mk
+
hash_bkt: hash_bkt.c ../../api.h hashtorture.h
cc $(GCC_ARGS) -DTEST_HASH -o hash_bkt hash_bkt.c -lpthread
diff --git a/CodeSamples/datastruct/log/Makefile b/CodeSamples/datastruct/log/Makefile
index f225c92..cd2c571 100644
--- a/CodeSamples/datastruct/log/Makefile
+++ b/CodeSamples/datastruct/log/Makefile
@@ -21,6 +21,9 @@ LIB = ../../lib
all: $(PROGS)
+top := ../..
+include $(top)/depends.mk
+
log_glock: log_glock.c ../../api.h logtorture.h log.h
cc $(GCC_ARGS) -DTEST_LOG -I $(LIB) -g -o log_glock log_glock.c $(LIB)/random.c -lpthread
diff --git a/CodeSamples/datastruct/skiplist/Makefile b/CodeSamples/datastruct/skiplist/Makefile
index 7289979..ab6f524 100644
--- a/CodeSamples/datastruct/skiplist/Makefile
+++ b/CodeSamples/datastruct/skiplist/Makefile
@@ -21,6 +21,9 @@ LIB = ../../lib
all: $(PROGS)
+top := ../..
+include $(top)/depends.mk
+
skiplist: skiplist.c ../../api.h skiplisttorture.h skiplist.h
cc $(GCC_ARGS) -DTEST_SKIPLIST -I $(LIB) -g -o skiplist skiplist.c $(LIB)/random.c -lpthread -lurcu -lurcu-signal
diff --git a/CodeSamples/defer/Makefile b/CodeSamples/defer/Makefile
index 35db164..5e0f1e7 100644
--- a/CodeSamples/defer/Makefile
+++ b/CodeSamples/defer/Makefile
@@ -46,6 +46,9 @@ PROGS = bug_rcu_dp \
all: $(PROGS)
+top := ..
+include $(top)/depends.mk
+
# Note that bug_srcu_a is disabled until completed.
bug_srcu_a: bug_srcu_a.c srcu.c ../api.h
cc $(GCC_ARGS) -o bug_srcu_a -DTEST bug_srcu_a.c -lurcu -lpthread
diff --git a/CodeSamples/depends.mk b/CodeSamples/depends.mk
new file mode 100644
index 0000000..409eeee
--- /dev/null
+++ b/CodeSamples/depends.mk
@@ -0,0 +1,43 @@
+ifeq ($(strip $(arch)),)
+arch := $(shell uname -m)
+endif
+
+ifeq ($(arch),i686)
+target := x86
+else ifeq ($(arch),x86_64)
+target := x86
+else ifeq ($(arch),ppc64)
+target := ppc64
+else ifneq (,$(findstring arm,$(arch)))
+target := arm
+else
+target :=
+endif
+
+api_depend_common := $(top)/linux/common.h \
+ $(top)/api-pthreads/api-pthreads.h \
+ $(top)/linux/list.h
+ifeq ($(target),x86)
+api_depend := $(top)/arch-x86/arch-x86.h
+arch_depend := $(top)/arch-x86/Makefile.arch
+else ifeq ($(target),ppc64)
+api_depend := $(top)/arch-ppc64/arch-ppc64.h
+arch_depend := $(top)/arch-ppc64/Makefile.arch
+else ifeq ($(target),arm)
+api_depend := $(top)/arch-arm/arch-arm.h
+arch_depend := $(top)/arch-arm/Makefile.arch
+else
+api_depend :=
+arch_depend :=
+endif
+
+ifneq ($(top),.)
+$(top)/api.h: $(api_depend) $(api_depend_common)
+ make -C $(top) api.h
+
+$(top)/Makefile.arch: $(arch_depend)
+ make -C $(top) Makefile.arch
+else
+$(top)/api.h: $(api_depend) $(api_depend_common)
+$(top)/Makefile.arch: $(arch_depend)
+endif
diff --git a/CodeSamples/intro/Makefile b/CodeSamples/intro/Makefile
index e323834..ba2f257 100644
--- a/CodeSamples/intro/Makefile
+++ b/CodeSamples/intro/Makefile
@@ -2,6 +2,9 @@ PROGS = initrace initraceperf lockinc nakedinc perthreadinc threadcreate
all: $(PROGS)
+top := ..
+include $(top)/depends.mk
+
initrace: initrace.c ../api.h
cc -g -Wall -o initrace initrace.c -lpthread
diff --git a/CodeSamples/locking/Makefile b/CodeSamples/locking/Makefile
index 15cf8f1..5862448 100644
--- a/CodeSamples/locking/Makefile
+++ b/CodeSamples/locking/Makefile
@@ -2,6 +2,9 @@ PROGS = locked_list xchglock
all: $(PROGS)
+top := ..
+include $(top)/depends.mk
+
locked_list: locked_list.c ../api.h
cc -g -Wall -o locked_list locked_list.c
diff --git a/CodeSamples/toolsoftrade/Makefile b/CodeSamples/toolsoftrade/Makefile
index 4b7f219..b6216e8 100644
--- a/CodeSamples/toolsoftrade/Makefile
+++ b/CodeSamples/toolsoftrade/Makefile
@@ -26,6 +26,9 @@ PROGS = forkjoin \
all: $(PROGS)
+top := ..
+include $(top)/depends.mk
+
forkjoin: forkjoin.c ../api.h
cc $(GCC_ARGS) -o forkjoin forkjoin.c
--
2.7.4
next prev parent reply other threads:[~2017-05-29 22:14 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-29 22:13 [RFC PATCH 0/4] CodeSamples: Cleanups and fixes Akira Yokosawa
2017-05-29 22:14 ` Akira Yokosawa [this message]
2017-05-29 22:16 ` [RFC PATCH 2/4] CodeSamples: Remove generated files from repository Akira Yokosawa
2017-05-29 22:17 ` [RFC PATCH 3/4] CodeSamples: Use 'intptr_t' to be compatible with 'void *' Akira Yokosawa
2017-05-30 0:10 ` Paul E. McKenney
2017-05-29 22:18 ` [RFC PATCH 4/4] CodeSamples/defer: Add compiler barriers in gettimestampmp.c Akira Yokosawa
2017-05-30 0:12 ` Paul E. McKenney
2017-05-30 0:02 ` [RFC PATCH 0/4] CodeSamples: Cleanups and fixes Paul E. McKenney
2017-05-30 1:44 ` Akira Yokosawa
2017-05-30 12:05 ` [RFC PATCH v2 0/2] " Akira Yokosawa
2017-05-30 12:06 ` [RFC PATCH v2 1/2] CodeSamples: Use 'intptr_t' to be compatible with 'void *' Akira Yokosawa
2017-05-30 12:07 ` [RFC PATCH v2 2/2] CodeSamples/defer: Add compiler barriers in gettimestampmp.c Akira Yokosawa
2017-05-31 18:46 ` [RFC PATCH v2 0/2] CodeSamples: Cleanups and fixes Paul E. McKenney
2017-05-31 21:19 ` Akira Yokosawa
2017-06-01 0:05 ` Paul E. McKenney
2017-06-01 1:45 ` Junchang Wang
2017-06-01 4:19 ` Paul E. McKenney
2017-06-01 4:34 ` Junchang Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=14adfa18-9518-e56a-ae40-81fbd06c0fb7@gmail.com \
--to=akiyks@gmail.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=perfbook@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.