From: Mathieu Desnoyers Date: Wed, 10 Jun 2009 17:35:30 +0000 (-0400) Subject: Add Makefile and Makefile64 architecture autodetection X-Git-Tag: v0.1~173 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=60fe0c90c4f70d12487235f750f21561da5e455b;p=urcu.git Add Makefile and Makefile64 architecture autodetection Signed-off-by: Mathieu Desnoyers --- diff --git a/Makefile b/Makefile index 5b8e655..917aa1a 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,18 @@ CFLAGS=-Wall -O2 -g -I. LDFLAGS=-lpthread +HOSTTYPE=$(shell uname -m) + +ifeq ("${HOSTTYPE}","x86_64") +ARCHTYPE=x86 +endif +ifeq ("${HOSTTYPE}","i486") +ARCHTYPE=x86 +endif +ifeq ("${HOSTTYPE}","powerpc") +ARCHTYPE=ppc +endif + #debug #CFLAGS=-Wall -g #CFLAGS+=-DDEBUG_FULL_MB @@ -11,26 +23,30 @@ LDFLAGS=-lpthread SRC_DEP=`echo $^ | sed 's/[^ ]*\.h//g'` -all: arch-api test_urcu test_urcu_dynamic_link test_urcu_timing \ +all: checkarch test_urcu test_urcu_dynamic_link test_urcu_timing \ test_rwlock_timing test_rwlock test_perthreadlock_timing \ test_perthreadlock test_urcu_yield test_urcu_mb \ urcu-asm.S test_qsbr_timing test_qsbr urcu-asm.o urcutorture \ urcutorture-yield liburcu.so -arch-api: api.h arch.h - # Run either make pthreads-x86 or make pthreads-ppc prior to build - # the RCU library. Architecture auto-detectection not implemented - # in the build system yet. +checkarch: +ifeq (${ARCHTYPE},) + @echo "Architecture ${HOSTTYPE} is currently unsupported by liburcu" + @exit 1 +endif + +arch.h: arch_${ARCHTYPE}.h + cp -f arch_${ARCHTYPE}.h arch.h + +api.h: api_${ARCHTYPE}.h + cp -f api_${ARCHTYPE}.h api.h -pthreads-x86: clean - cp api_x86.h api.h - cp arch_x86.h arch.h - cp arch_atomic_x86.h arch_atomic.h +arch_atomic.h: arch_atomic_${ARCHTYPE}.h + cp -f arch_atomic_${ARCHTYPE}.h arch_atomic.h -pthreads-ppc: clean - cp api_ppc.h api.h - cp arch_ppc.h arch.h - cp arch_atomic_ppc.h arch_atomic.h +urcu.h: arch.h api.h arch_atomic.h + +urcu-qsbr.h: arch.h api.h arch_atomic.h test_urcu: urcu.o test_urcu.c urcu.h $(CC) ${CFLAGS} $(LDFLAGS) -o $@ $(SRC_DEP) @@ -92,7 +108,7 @@ urcutorture: urcutorture.c urcu.o urcu.h rcutorture.h urcutorture-yield: urcutorture.c urcu-yield.o urcu.h rcutorture.h $(CC) -DDEBUG_YIELD ${CFLAGS} $(LDFLAGS) -o $@ $(SRC_DEP) -.PHONY: clean install arch-api +.PHONY: clean install checkarch install: liburcu.so cp -f liburcu.so /usr/lib/ @@ -103,5 +119,5 @@ clean: test_rwlock_timing test_rwlock test_perthreadlock_timing \ test_perthreadlock test_urcu_yield test_urcu_mb \ urcu-asm.S test_qsbr_timing test_qsbr urcutorture \ - urcutorture-yield liburcu.so + urcutorture-yield liburcu.so api.h arch.h arch_atomic.h diff --git a/Makefile64 b/Makefile64 index 83b0fd6..c484a5e 100644 --- a/Makefile64 +++ b/Makefile64 @@ -3,6 +3,18 @@ CFLAGS=-m64 -O2 -g -I. LDFLAGS=-lpthread +HOSTTYPE=$(shell uname -m) + +ifeq ("${HOSTTYPE}","x86_64") +ARCHTYPE=x86 +endif +ifeq ("${HOSTTYPE}","i486") +ARCHTYPE=x86 +endif +ifeq ("${HOSTTYPE}","powerpc") +ARCHTYPE=ppc +endif + #debug #CFLAGS=-m64 -Wall -g #CFLAGS+=-DDEBUG_FULL_MB @@ -12,26 +24,30 @@ LDFLAGS=-lpthread SRC_DEP=`echo $^ | sed 's/[^ ]*\.h//g'` -all: arch-api test_urcu test_urcu_dynamic_link test_urcu_timing \ +all: checkarch test_urcu test_urcu_dynamic_link test_urcu_timing \ test_rwlock_timing test_rwlock test_perthreadlock_timing \ test_perthreadlock test_urcu_yield test_urcu_mb \ urcu-asm.S test_qsbr_timing test_qsbr urcu-asm.o urcutorture \ urcutorture-yield liburcu.so -arch-api: api.h arch.h - # Run either make pthreads-x86 or make pthreads-ppc prior to build - # the RCU library. Architecture auto-detectection not implemented - # in the build system yet. +checkarch: +ifeq (${ARCHTYPE},) + @echo "Architecture ${HOSTTYPE} is currently unsupported by liburcu" + @exit 1 +endif + +arch.h: arch_${ARCHTYPE}.h + cp -f arch_${ARCHTYPE}.h arch.h + +api.h: api_${ARCHTYPE}.h + cp -f api_${ARCHTYPE}.h api.h -pthreads-x86: clean - cp api_x86.h api.h - cp arch_x86.h arch.h - cp arch_atomic_x86.h arch_atomic.h +arch_atomic.h: arch_atomic_${ARCHTYPE}.h + cp -f arch_atomic_${ARCHTYPE}.h arch_atomic.h -pthreads-ppc: clean - cp api_ppc.h api.h - cp arch_ppc.h arch.h - cp arch_atomic_ppc.h arch_atomic.h +urcu.h: arch.h api.h arch_atomic.h + +urcu-qsbr.h: arch.h api.h arch_atomic.h test_urcu: urcu.o test_urcu.c urcu.h $(CC) ${CFLAGS} $(LDFLAGS) -o $@ $(SRC_DEP) @@ -93,7 +109,7 @@ urcutorture: urcutorture.c urcu.o urcu.h rcutorture.h urcutorture-yield: urcutorture.c urcu-yield.o urcu.h rcutorture.h $(CC) -DDEBUG_YIELD ${CFLAGS} $(LDFLAGS) -o $@ $(SRC_DEP) -.PHONY: clean install arch-api +.PHONY: clean install checkarch install: liburcu.so cp -f liburcu.so /usr/lib/ @@ -104,5 +120,5 @@ clean: test_rwlock_timing test_rwlock test_perthreadlock_timing \ test_perthreadlock test_urcu_yield test_urcu_mb \ urcu-asm.S test_qsbr_timing test_qsbr urcutorture \ - urcutorture-yield liburcu.so + urcutorture-yield liburcu.so api.h arch.h arch_atomic.h