Skip to contentSkip to conversation

CodeSamples: Cleanups and Makefile updates

PATCH In review Akira Yokosawa 2 participants 7 messages Jun 9, 2017

lore
Share & tools
lore
#0 lore raw

cover CodeSamples: Cleanups and Makefile updates

From b31141981b13d40fbbe5d20fa339d714ecba084c Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <[email protected]>
Date: Fri, 9 Jun 2017 23:59:11 +0900
Subject: [PATCH 0/5] CodeSamples: Cleanups and Makefile updates

Hi Paul,

Removal of gprof-helper.c and linux/list.h has become a fairly large patch set.

Patch 1 is simple removal.
Patch 2 is an improvement to make the "-jN" option to propagate to subdirectories.
Patch 3 removes linux/list.h, with refactoring of recipes. Patch 4 adds subdirectories that can be built by "make" in the CodeSamples/ directory.
Patch 5 improves build behavior for unsupported architectures. You can test the behavior by overriding "arch" variable by defining it as an environment variable, e.g.:

    $ export arch=unsupported
    $ make clean; make
After the test,
    $ unset arch
will restore the normal behavior.

Thoughts?

Thanks, Akira
--

Akira Yokosawa (5):
CodeSamples: Remove gprof-helper.c
CodeSamples: Use $(MAKE) for recursive make
CodeSamples: Makefile: Remove linux/list.h
CodeSamples: Makefile: Add subdirectories
CodeSamples: Makefile: Distinguish arch-independent targets

 CodeSamples/.gitignore                   |   1 -
 CodeSamples/Makefile                     | 125 +-----
 CodeSamples/SMPdesign/Makefile           |  19 +-
 CodeSamples/advsync/Makefile             |  11 +-
 CodeSamples/count/Makefile               |  11 +-
 CodeSamples/datastruct/Issaquah/Makefile |  11 +-
 CodeSamples/datastruct/hash/Makefile     |  11 +-
 CodeSamples/datastruct/log/Makefile      |  11 +-
 CodeSamples/datastruct/skiplist/Makefile |  11 +-
 CodeSamples/defer/Makefile               |  18 +-
 CodeSamples/depends.mk                   |  14 +-
 CodeSamples/gprof-helper.c               | 118 ------
 CodeSamples/intro/Makefile               |  15 +-
 CodeSamples/linux/list.h                 | 700 -------------------------------
 CodeSamples/locking/Makefile             |  15 +-
 CodeSamples/recipes.mk                   |  10 +
 CodeSamples/toolsoftrade/Makefile        |   1 +
 17 files changed, 139 insertions(+), 963 deletions(-)
 delete mode 100644 CodeSamples/gprof-helper.c
 delete mode 100644 CodeSamples/linux/list.h
 create mode 100644 CodeSamples/recipes.mk
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/5 CodeSamples: Remove gprof-helper.c

From 5d81fb381768463ac02881edb5e8caf3896e9c48 Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <[email protected]>
Date: Tue, 6 Jun 2017 00:06:44 +0900
Subject: [PATCH 1/5] CodeSamples: Remove gprof-helper.c

Paul confirmed that he no longer needs this.
Also remove its entry in .gitignore.

---
 CodeSamples/.gitignore     |   1 -
 CodeSamples/gprof-helper.c | 118 ---------------------------------------------
 2 files changed, 119 deletions(-)
 delete mode 100644 CodeSamples/gprof-helper.c
CodeSamples/.gitignore +0 -1
index e116055..042e44d 100644
@@ -1,3 +1,2 @@
-/gprof-helper.c
 /Makefile.arch
 /api.h
CodeSamples/gprof-helper.c deleted +0 -118

118 lines not on this page · raw message

Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/5 CodeSamples: Use $(MAKE) for recursive make

In reply to Akira Yokosawa

From e227572a57eaa6c14636c1d197a6d40254bcfa5c Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <[email protected]>
Date: Tue, 6 Jun 2017 00:24:15 +0900
Subject: [PATCH 2/5] CodeSamples: Use $(MAKE) for recursive make

For recursive make, "$(MAKE)" is recommended.[1]
By this change, options such as "-j4" can be transferred to builds under subdirectories.

Also convert the list of recursive "make"s to a "for" loop by defining a variable "subdirs".

[1] https://www.gnu.org/software/make/manual/html_node/Recursion.html

---
 CodeSamples/Makefile   | 16 ++++++++--------
 CodeSamples/depends.mk |  4 ++--
 2 files changed, 10 insertions(+), 10 deletions(-)
CodeSamples/Makefile +8 -8
index e1593a7..ec9e9a6 100644
@@ -1,24 +1,24 @@
+subdirs = SMPdesign advsync count defer intro toolsoftrade
+
 .PHONY: all clean pthreads pthreads-x86 pthreads-ppc64 pthreads-arm
 
 top := .
 
 all:
-	(cd SMPdesign; make)
-	(cd advsync; make)
-	(cd count; make)
-	(cd defer; make)
-	(cd intro; make)
-	(cd toolsoftrade; make)
+	for d in $(subdirs); \
+	do \
+		$(MAKE) -C $$d; \
+	done
 
 include depends.mk
 
 api.h Makefile.arch:
 ifeq ($(strip $(target)),)
-	make pthreads
+	$(MAKE) pthreads
 	$(warning "Could not figure out which target to use (arch:$(arch)).\
 		   Used 'make pthreads' in CodeSamples/Makefile.")
 else
-	make pthreads-$(target)
+	$(MAKE) pthreads-$(target)
 endif
 
 pthreads:
CodeSamples/depends.mk +2 -2
index f3a325d..9d2691b 100644
@@ -35,10 +35,10 @@ endif
 
 ifneq ($(top),.)
 $(top)/api.h: $(api_depend) $(api_depend_common)
-	make -C $(top) api.h
+	$(MAKE) -C $(top) api.h
 
 $(top)/Makefile.arch: $(arch_depend)
-	make -C $(top) Makefile.arch
+	$(MAKE) -C $(top) Makefile.arch
 else
 $(top)/api.h: $(api_depend) $(api_depend_common)
 $(top)/Makefile.arch: $(arch_depend)
Signature · 1 line
2.7.4
#3 lore raw

PATCH 3/5 CodeSamples: Makefile: Remove linux/list.h

In reply to Akira Yokosawa

From 19d56c2963ca68952fb593eff967954f26de23bf Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <[email protected]>
Date: Wed, 7 Jun 2017 00:00:31 +0900
Subject: [PATCH 3/5] CodeSamples: Makefile: Remove linux/list.h

linux/list.h was used as a fallback when header files of liburcu was not found. However, current code samples depend on a later version of liburcu API. Nowadays, liburcu is available for most Linux distributions as a package (e.g., liburcu-dev for Ubuntu, liburcu-devel for Fedora).
Remove linux/list.h and its dependency in Makefile rather than import newer definitions.

While dropping the dependency, merge redundant recipes into a single recipe by using the variable "target" defined in depend.mk.

---
 CodeSamples/Makefile     | 107 +-------
 CodeSamples/depends.mk   |   3 +-
 CodeSamples/linux/list.h | 700 -----------------------------------------------
 3 files changed, 12 insertions(+), 798 deletions(-)
 delete mode 100644 CodeSamples/linux/list.h
CodeSamples/Makefile +11 -96
index ec9e9a6..1bfdf08 100644
@@ -1,6 +1,6 @@
 subdirs = SMPdesign advsync count defer intro toolsoftrade
 
-.PHONY: all clean pthreads pthreads-x86 pthreads-ppc64 pthreads-arm
+.PHONY: all clean pthreads
 
 top := .
 
@@ -15,10 +15,9 @@ 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.")
+	$(warning "Could not figure out which target arch to use (arch:$(arch)).")
 else
-	$(MAKE) pthreads-$(target)
+	$(MAKE) pthreads
 endif
 
 pthreads:
@@ -28,35 +27,10 @@ pthreads:
 	echo "" >> api.h
 	cat linux/common.h >> api.h
 	echo "" >> api.h
-	cat api-pthreads/api-pthreads.h >> api.h
-	echo "" >> api.h
-	if test -f /usr/include/urcu-call-rcu.h -o -f /usr/local/include/urcu-call-rcu.h ; \
-	then \
-		echo "#define _LGPL_SOURCE" >> api.h; \
-		echo "#include <urcu/rculist.h>" >> api.h; \
-		echo "#include <urcu/rcuhlist.h>" >> api.h; \
-		echo "#include <urcu-pointer.h>" >> api.h; \
-	elif test -d /usr/include/urcu -o -d /usr/local/include/urcu ; \
-	then \
-		echo "#define _LGPL_SOURCE" >> api.h; \
-		echo "#include <urcu/rculist.h>" >> api.h; \
-		echo "#include <urcu/rcuhlist.h>" >> api.h; \
-		echo "#include <urcu-pointer-static.h>" >> api.h; \
-	else \
-		cat linux/list.h >> api.h; \
-	fi
-	echo "#endif /* #ifndef __PERFBOOK_API_H__ */" >> api.h
-	echo "# MECHANICALLY GENERATED, DO NOT EDIT!!!" > Makefile.arch
-
-pthreads-x86:
-	echo "#ifndef __PERFBOOK_API_H__" > api.h
-	echo "#define __PERFBOOK_API_H__" >> api.h
-	echo "/* MECHANICALLY GENERATED, DO NOT EDIT!!! */" >> api.h
-	echo "" >> api.h
-	cat linux/common.h >> api.h
-	echo "" >> api.h
-	cat arch-x86/arch-x86.h >> api.h
+ifneq ($(strip $(target)),)
+	cat arch-$(target)/arch-$(target).h >> api.h
 	echo "" >> api.h
+endif
 	cat api-pthreads/api-pthreads.h >> api.h
 	echo "" >> api.h
 	cat api-pthreads/api-gcc.h >> api.h
@@ -74,74 +48,15 @@ pthreads-x86:
 		echo "#include <urcu/rcuhlist.h>" >> api.h; \
 		echo "#include <urcu-pointer-static.h>" >> api.h; \
 	else \
-		cat linux/list.h >> api.h; \
+		echo "### Missing liburcu package!!!  Install it. ###"; \
+		exit 1;  \
 	fi
 	echo "#endif /* #ifndef __PERFBOOK_API_H__ */" >> api.h
 	echo "# MECHANICALLY GENERATED, DO NOT EDIT!!!" > Makefile.arch
 	echo "" >> Makefile.arch
-	cat arch-x86/Makefile.arch >> Makefile.arch
-
-pthreads-ppc64:
-	echo "#ifndef __PERFBOOK_API_H__" >> api.h
-	echo "#define __PERFBOOK_API_H__" >> api.h
-	echo "/* MECHANICALLY GENERATED, DO NOT EDIT!!! */" >> api.h
-	echo "" >> api.h
-	cat linux/common.h >> api.h
-	echo "" >> api.h
-	cat arch-ppc64/arch-ppc64.h >> api.h
-	echo "" >> api.h
-	cat api-pthreads/api-pthreads.h >> api.h
-	echo "" >> api.h
-	cat api-pthreads/api-gcc.h >> api.h
-	echo "" >> api.h
-	if test -f /usr/include/urcu-call-rcu.h -o -f /usr/local/include/urcu-call-rcu.h ; \
-	then \
-		echo "#define _LGPL_SOURCE" >> api.h; \
-		echo "#include <urcu/rculist.h>" >> api.h; \
-		echo "#include <urcu/rcuhlist.h>" >> api.h; \
-		echo "#include <urcu-pointer.h>" >> api.h; \
-	elif test -d /usr/include/urcu -o -d /usr/local/include/urcu ; \
-	then \
-		echo "#define _LGPL_SOURCE" >> api.h; \
-		echo "#include <urcu/rculist.h>" >> api.h; \
-		echo "#include <urcu/rcuhlist.h>" >> api.h; \
-		echo "#include <urcu-pointer-static.h>" >> api.h; \
-	else \
-		cat linux/list.h >> api.h; \
-	fi
-	echo "#endif /* #ifndef __PERFBOOK_API_H__ */" >> api.h
-	echo "# MECHANICALLY GENERATED, DO NOT EDIT!!!" > Makefile.arch
-	cat arch-ppc64/Makefile.arch >> Makefile.arch
-
-pthreads-arm:
-	echo "#ifndef __PERFBOOK_API_H__" > api.h
-	echo "#define __PERFBOOK_API_H__" >> api.h
-	echo "/* MECHANICALLY GENERATED, DO NOT EDIT!!! */" >> api.h
-	echo "" >> api.h
-	cat linux/common.h >> api.h
-	echo "" >> api.h
-	cat arch-arm/arch-arm.h >> api.h
-	echo "" >> api.h
-	cat api-pthreads/api-pthreads.h >> api.h
-	echo "" >> api.h
-	if test -f /usr/include/urcu-call-rcu.h -o -f /usr/local/include/urcu-call-rcu.h ; \
-	then \
-		echo "#define _LGPL_SOURCE" >> api.h; \
-		echo "#include <urcu/rculist.h>" >> api.h; \
-		echo "#include <urcu/rcuhlist.h>" >> api.h; \
-		echo "#include <urcu-pointer.h>" >> api.h; \
-	elif test -d /usr/include/urcu -o -d /usr/local/include/urcu ; \
-	then \
-		echo "#define _LGPL_SOURCE" >> api.h; \
-		echo "#include <urcu/rculist.h>" >> api.h; \
-		echo "#include <urcu/rcuhlist.h>" >> api.h; \
-		echo "#include <urcu-pointer-static.h>" >> api.h; \
-	else \
-		cat linux/list.h >> api.h; \
-	fi
-	echo "#endif /* #ifndef __PERFBOOK_API_H__ */" >> api.h
-	echo "# MECHANICALLY GENERATED, DO NOT EDIT!!!" > Makefile.arch
-	cat arch-arm/Makefile.arch >> Makefile.arch
+ifneq ($(strip $(target)),)
+	cat arch-$(target)/Makefile.arch >> Makefile.arch
+endif
 
 clean:
 	rm -f Makefile.arch api.h
CodeSamples/depends.mk +1 -2
index 9d2691b..81f8bec 100644
@@ -17,8 +17,7 @@ target :=
 endif
 
 api_depend_common := $(top)/linux/common.h \
-	$(top)/api-pthreads/api-pthreads.h \
-	$(top)/linux/list.h
+	$(top)/api-pthreads/api-pthreads.h
 ifeq ($(target),x86)
 api_depend := $(top)/arch-x86/arch-x86.h
 arch_depend := $(top)/arch-x86/Makefile.arch
CodeSamples/linux/list.h deleted +0 -700

700 lines not on this page · raw message

Signature · 1 line
2.7.4
#4 lore raw

PATCH 4/5 CodeSamples: Makefile: Add subdirectories

In reply to Akira Yokosawa

From 7e77e8a2d087b979ab984e9b90731b5db0d1eedc Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <[email protected]>
Date: Wed, 7 Jun 2017 20:41:34 +0900
Subject: [PATCH 4/5] CodeSamples: Makefile: Add subdirectories

Add subdirectories whose builds depend on api.h and Makefile.arch. Now that liburcu is mandatory, we can safely add these subdirectories which contain targets to be linked to urcu libraries.

---
 CodeSamples/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
CodeSamples/Makefile +2 -1
index 1bfdf08..cef6927 100644
@@ -1,4 +1,5 @@
-subdirs = SMPdesign advsync count defer intro toolsoftrade
+subdirs =  SMPdesign advsync count defer intro toolsoftrade locking
+subdirs += datastruct/Issaquah datastruct/hash datastruct/log datastruct/skiplist
 
 .PHONY: all clean pthreads
 
Signature · 1 line
2.7.4
#5 lore raw

PATCH 5/5 CodeSamples: Makefile: Distinguish arch-independent targets

In reply to Akira Yokosawa

From b31141981b13d40fbbe5d20fa339d714ecba084c Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <[email protected]>
Date: Fri, 9 Jun 2017 19:18:40 +0900
Subject: [PATCH 5/5] CodeSamples: Makefile: Distinguish arch-independent targets

On hosts of unsupported architecture, generated api.h does not contain architecture-specific definitions. This will result in build errors.

There are quite a few code samples which can be built with such api.h. So, this patch distinguishes architecture-independent targets in Makefiles and let those targets be built.

---
 CodeSamples/Makefile                     |  3 ++-
 CodeSamples/SMPdesign/Makefile           | 19 ++++++++++++++-----
 CodeSamples/advsync/Makefile             | 11 +++++++++--
 CodeSamples/count/Makefile               | 11 +++++++++--
 CodeSamples/datastruct/Issaquah/Makefile | 11 +++++++++--
 CodeSamples/datastruct/hash/Makefile     | 11 +++++++++--
 CodeSamples/datastruct/log/Makefile      | 11 +++++++++--
 CodeSamples/datastruct/skiplist/Makefile | 11 +++++++++--
 CodeSamples/defer/Makefile               | 18 ++++++++++++++----
 CodeSamples/depends.mk                   | 11 -----------
 CodeSamples/intro/Makefile               | 15 ++++++++++++---
 CodeSamples/locking/Makefile             | 15 ++++++++++++---
 CodeSamples/recipes.mk                   | 10 ++++++++++
 CodeSamples/toolsoftrade/Makefile        |  1 +
 14 files changed, 119 insertions(+), 39 deletions(-)
 create mode 100644 CodeSamples/recipes.mk
CodeSamples/Makefile +2 -1
index cef6927..6b2c3c9 100644
@@ -4,6 +4,7 @@ subdirs += datastruct/Issaquah datastruct/hash datastruct/log datastruct/skiplis
 .PHONY: all clean pthreads
 
 top := .
+include depends.mk
 
 all:
 	for d in $(subdirs); \
@@ -11,7 +12,7 @@ all:
 		$(MAKE) -C $$d; \
 	done
 
-include depends.mk
+include recipes.mk
 
 api.h Makefile.arch:
 ifeq ($(strip $(target)),)
CodeSamples/SMPdesign/Makefile +14 -5
index d03575c..b1e5fc8 100644
@@ -14,20 +14,29 @@
 #
 # Copyright (c) 2008 Paul E. McKenney, IBM Corporation.
 
-PROGS = smpalloc lockdeq lockhdeq locktdeq lockrwdeq matmul matmul_block
+ARCH_INDEPENDENT = smpalloc
+ARCH_DEPENDENT = lockdeq lockhdeq locktdeq lockrwdeq matmul matmul_block
+PROGS = $(ARCH_DEPENDENT) $(ARCH_INDEPENDENT)
 
+include ../Makefile.arch
+
+top := ..
+include $(top)/depends.mk
+
+ifeq ($(strip $(target)),)
+all: $(ARCH_INDEPENDENT)
+	@echo "### $(ARCH_DEPENDENT) in SMPdesign/ can't be built on arch: '$(arch)'."
+else
 all: $(PROGS)
+endif
 
-include ../Makefile.arch
+include $(top)/recipes.mk
 
 # GCC_ARGS=-g -O3
 
 # 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
 
CodeSamples/advsync/Makefile +9 -2
index bb4c8fc..f2e0db3 100644
@@ -18,11 +18,18 @@ include ../Makefile.arch
 
 PROGS =	q singleq wfenqueue
 
-all: $(PROGS)
-
 top := ..
 include $(top)/depends.mk
 
+ifeq ($(strip $(target)),)
+all:
+	@echo "### None in advsync/ can be built on arch: '$(arch)'."
+else
+all: $(PROGS)
+endif
+
+include $(top)/recipes.mk
+
 q: q.c q.h queuetorture.h ../api.h
 	cc $(GCC_ARGS) -o q -DTEST q.c -lpthread
 
CodeSamples/count/Makefile +9 -2
index d3fbb83..eacdb57 100644
@@ -33,11 +33,18 @@ PROGS =	count_atomic \
 
 RCU_SRCS = ../defer/rcu_nest32.h ../defer/rcu_nest32.c
 
-all: $(PROGS)
-
 top := ..
 include $(top)/depends.mk
 
+ifeq ($(strip $(target)),)
+all:
+	@echo "### None in count/ can be built on arch: '$(arch)'."
+else
+all: $(PROGS)
+endif
+
+include $(top)/recipes.mk
+
 count_atomic: count_atomic.c ../api.h counttorture.h
 	cc $(GCC_ARGS) $(CFLAGS) -o count_atomic count_atomic.c -lpthread
 
CodeSamples/datastruct/Issaquah/Makefile +9 -2
index bb3d6a3..b5b63e1 100644
@@ -19,11 +19,18 @@ include ../../Makefile.arch
 PROGS = existence_test treetorture
 LIB = ../../lib
 
-all: $(PROGS)
-
 top := ../..
 include $(top)/depends.mk
 
+ifeq ($(strip $(target)),)
+all:
+	@echo "### None in datastruct/Issaquah/ can be built on arch: '$(arch)'."
+else
+all: $(PROGS)
+endif
+
+include $(top)/recipes.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
CodeSamples/datastruct/hash/Makefile +9 -2
index 85dfa5d..d75936f 100644
@@ -18,11 +18,18 @@ include ../../Makefile.arch
 
 PROGS =	hash_bkt hash_bkt_hazptr hash_bkt_rcu hash_global hash_resize
 
-all: $(PROGS)
-
 top := ../..
 include $(top)/depends.mk
 
+ifeq ($(strip $(target)),)
+all:
+	@echo "### None in datastruct/hash/ can be built on arch: '$(arch)'."
+else
+all: $(PROGS)
+endif
+
+include $(top)/recipes.mk
+
 hash_bkt: hash_bkt.c ../../api.h hashtorture.h
 	cc $(GCC_ARGS) -DTEST_HASH -o hash_bkt hash_bkt.c -lpthread
 
CodeSamples/datastruct/log/Makefile +9 -2
index cd2c571..b45a162 100644
@@ -19,11 +19,18 @@ include ../../Makefile.arch
 PROGS =	log_glock
 LIB = ../../lib
 
-all: $(PROGS)
-
 top := ../..
 include $(top)/depends.mk
 
+ifeq ($(strip $(target)),)
+all:
+	@echo "### None in datastruct/log/ can be built on arch: '$(arch)'."
+else
+all: $(PROGS)
+endif
+
+include $(top)/recipes.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
 
CodeSamples/datastruct/skiplist/Makefile +9 -2
index ab6f524..9044b9c 100644
@@ -19,11 +19,18 @@ include ../../Makefile.arch
 PROGS =	skiplist skiplist_glock
 LIB = ../../lib
 
-all: $(PROGS)
-
 top := ../..
 include $(top)/depends.mk
 
+ifeq ($(strip $(target)),)
+all:
+	@echo "### None in datastruct/skiplist/ can be built on arch: '$(arch)'."
+else
+all: $(PROGS)
+endif
+
+include $(top)/recipes.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
 
CodeSamples/defer/Makefile +14 -4
index 5e0f1e7..5a08c1f 100644
@@ -16,11 +16,12 @@
 
 include ../Makefile.arch
 
-PROGS =	bug_rcu_dp \
-	gettimestamp \
+ARCH_INDEPENDENT = bug_rcu_dp \
+	ptxroute
+
+ARCH_DEPENDENT = gettimestamp \
 	gettimestampmp \
 	hazptr \
-	ptxroute \
 	rcu \
 	rcu64 \
 	rcu64_atomicgp \
@@ -44,11 +45,20 @@ PROGS =	bug_rcu_dp \
 	route_seqlock \
 	seqlocktorture \
 
-all: $(PROGS)
+PROGS = $(ARCH_DEPENDENT) $(ARCH_INDEPENDENT)
 
 top := ..
 include $(top)/depends.mk
 
+ifeq ($(strip $(target)),)
+all: $(ARCH_INDEPENDENT)
+	@echo "### $(ARCH_DEPENDENT) in defer/ can't be built on arch: '$(arch)'."
+else
+all: $(PROGS)
+endif
+
+include $(top)/recipes.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
CodeSamples/depends.mk +0 -11
index 81f8bec..8eb45b4 100644
@@ -31,14 +31,3 @@ 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
CodeSamples/intro/Makefile +12 -3
index ba2f257..c7be0cb 100644
@@ -1,10 +1,19 @@
-PROGS = initrace initraceperf lockinc nakedinc perthreadinc threadcreate
-
-all: $(PROGS)
+ARCH_INDEPENDENT = initraceperf lockinc nakedinc perthreadinc threadcreate
+ARCH_DEPENDENT = initrace
+PROGS = $(ARCH_DEPENDENT) $(ARCH_INDEPENDENT)
 
 top := ..
 include $(top)/depends.mk
 
+ifeq ($(strip $(target)),)
+all: $(ARCH_INDEPENDENT)
+	@echo "### $(ARCH_DEPENDENT) in intro/ can't be built on arch: '$(arch)'."
+else
+all: $(PROGS)
+endif
+
+include $(top)/recipes.mk
+
 initrace: initrace.c ../api.h
 	cc -g -Wall -o initrace initrace.c -lpthread
 
CodeSamples/locking/Makefile +12 -3
index 5862448..3663a7d 100644
@@ -1,10 +1,19 @@
-PROGS = locked_list xchglock
-
-all: $(PROGS)
+ARCH_INDEPENDENT = locked_list
+ARCH_DEPENDENT = xchglock
+PROGS = $(ARCH_INDEPENDENT) $(ARCH_DEPENDENT)
 
 top := ..
 include $(top)/depends.mk
 
+ifeq ($(strip $(target)),)
+all: $(ARCH_INDEPENDENT)
+	@echo "### $(ARCH_DEPENDENT) in locking/ can't be built on arch: '$(arch)'."
+else
+all: $(PROGS)
+endif
+
+include $(top)/recipes.mk
+
 locked_list: locked_list.c ../api.h
 	cc -g -Wall -o locked_list locked_list.c
 
CodeSamples/recipes.mk new file +10 -0
new file mode 100644
index 0000000..afeaf2f
@@ -0,0 +1,10 @@
+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
CodeSamples/toolsoftrade/Makefile +1 -0
index b6216e8..d23ff21 100644
@@ -28,6 +28,7 @@ all: $(PROGS)
 
 top := ..
 include $(top)/depends.mk
+include $(top)/recipes.mk
 
 forkjoin: forkjoin.c ../api.h
 	cc $(GCC_ARGS) -o forkjoin forkjoin.c
Signature · 1 line
2.7.4
#6 lore raw
In reply to Akira Yokosawa
Quoted 19 lines · Akira Yokosawa
Quoted 1 line

From b31141981b13d40fbbe5d20fa339d714ecba084c Mon Sep 17 00:00:00 2001

From: Akira Yokosawa <[email protected]>
Date: Fri, 9 Jun 2017 23:59:11 +0900
Subject: [PATCH 0/5] CodeSamples: Cleanups and Makefile updates

Hi Paul,

Removal of gprof-helper.c and linux/list.h has become a fairly large patch set.

Patch 1 is simple removal.
Patch 2 is an improvement to make the "-jN" option to propagate to subdirectories.
Patch 3 removes linux/list.h, with refactoring of recipes. Patch 4 adds subdirectories that can be built by "make" in the CodeSamples/ directory.
Patch 5 improves build behavior for unsupported architectures. You can test the behavior by overriding "arch" variable by defining it as an environment variable, e.g.:

Quoted 7 lines
    $ export arch=unsupported
    $ make clean; make
After the test,
    $ unset arch
will restore the normal behavior.

Thoughts?

Seems to work, applied and pushed, thank you!

Thanx, Paul

Quoted 35 lines

Thanks, Akira
--

Akira Yokosawa (5):
CodeSamples: Remove gprof-helper.c
CodeSamples: Use $(MAKE) for recursive make
CodeSamples: Makefile: Remove linux/list.h
CodeSamples: Makefile: Add subdirectories
CodeSamples: Makefile: Distinguish arch-independent targets

 CodeSamples/.gitignore                   |   1 -
 CodeSamples/Makefile                     | 125 +-----
 CodeSamples/SMPdesign/Makefile           |  19 +-
 CodeSamples/advsync/Makefile             |  11 +-
 CodeSamples/count/Makefile               |  11 +-
 CodeSamples/datastruct/Issaquah/Makefile |  11 +-
 CodeSamples/datastruct/hash/Makefile     |  11 +-
 CodeSamples/datastruct/log/Makefile      |  11 +-
 CodeSamples/datastruct/skiplist/Makefile |  11 +-
 CodeSamples/defer/Makefile               |  18 +-
 CodeSamples/depends.mk                   |  14 +-
 CodeSamples/gprof-helper.c               | 118 ------
 CodeSamples/intro/Makefile               |  15 +-
 CodeSamples/linux/list.h                 | 700 -------------------------------
 CodeSamples/locking/Makefile             |  15 +-
 CodeSamples/recipes.mk                   |  10 +
 CodeSamples/toolsoftrade/Makefile        |   1 +
 17 files changed, 139 insertions(+), 963 deletions(-)
 delete mode 100644 CodeSamples/gprof-helper.c
 delete mode 100644 CodeSamples/linux/list.h
 create mode 100644 CodeSamples/recipes.mk
Signature · 1 line
2.7.4