Add Makefile and Makefile64 architecture autodetection
authorMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Wed, 10 Jun 2009 17:35:30 +0000 (13:35 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Wed, 10 Jun 2009 17:35:30 +0000 (13:35 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Makefile
Makefile64

index 5b8e6557c5fffe1a9d5e7946fa0d42d6a31014ed..917aa1a31b6be0d90b974da8d1759f55123cd239 100644 (file)
--- 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
 
index 83b0fd60b4e5d9b71dda9ccd32f7f11e703e17af..c484a5ebd4adbf311e82d5c6af4f0fcd0b4afb41 100644 (file)
@@ -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
 
This page took 0.029453 seconds and 4 git commands to generate.