Browse Source

fix dylib suffix detection

Xℹ Ruoyao 4 years ago
parent
commit
0ab8e225d1
3 changed files with 18 additions and 15 deletions
  1. 1 14
      Makefile
  2. 3 1
      demo/Makefile
  3. 14 0
      dylib.make

+ 1 - 14
Makefile

@@ -13,20 +13,7 @@ CFLAGS += -fPIC
 OBJFILES := schmidt_trigger.o ringbuf.o monotonic_queue.o
 OBJFILES += jump_rope_count_device.o
 
-DYLIB_SUFFIX=unknown
-UNAME_S := $(shell uname -s)
-ifeq ($(UNAME_S), Linux)
-	DYLIB_SUFFIX=.so
-endif
-ifeq ($(UNAME_S), Darwin)
-	DYLIB_SUFFIX=.dylib
-endif
-
-ifeq ($(DYLIB_SUFFIX), unknown)
-	$(error Unsupported operating system)
-else
-	DYLIB := libjump$(DYLIB_SUFFIX)
-endif
+include dylib.make
 
 all: $(DYLIB) demo/demo
 

+ 3 - 1
demo/Makefile

@@ -7,7 +7,9 @@ endif
 
 CFLAGS=-I..
 
-demo: main.o ../libjump.so
+include ../dylib.make
+
+demo: main.o ../$(DYLIB)
 	cc -o $@ $(LDFLAGS) $< $(LIBS)
 
 main.o: main.c

+ 14 - 0
dylib.make

@@ -0,0 +1,14 @@
+DYLIB_SUFFIX=unknown
+UNAME_S := $(shell uname -s)
+ifeq ($(UNAME_S), Linux)
+	DYLIB_SUFFIX=.so
+endif
+ifeq ($(UNAME_S), Darwin)
+	DYLIB_SUFFIX=.dylib
+endif
+
+ifeq ($(DYLIB_SUFFIX), unknown)
+	$(error Unsupported operating system)
+else
+	DYLIB := libjump$(DYLIB_SUFFIX)
+endif