-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
46 lines (33 loc) · 824 Bytes
/
Makefile
File metadata and controls
46 lines (33 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Makefile for atomic_store library
CC ?= cc
CFLAGS ?= -O2 -Wall -Wextra -std=c11
AR ?= ar
ARFLAGS ?= rcs
UNAME_S := $(shell uname -s)
# Detect shared library extension and flags
ifeq ($(UNAME_S),Darwin)
SO_EXT = dylib
SO_LDFLAGS = -dynamiclib
else
SO_EXT = so
SO_LDFLAGS = -shared
endif
LIBNAME = atomicstore
LIBSTATIC = lib$(LIBNAME).a
LIBSHARED = lib$(LIBNAME).$(SO_EXT)
SRCS = atomic_store.c
OBJS = $(SRCS:.c=.o)
.PHONY: all clean shared
# Default: build static lib
all: $(LIBSTATIC)
shared: $(LIBSHARED)
# Static library
$(LIBSTATIC): $(OBJS)
$(AR) $(ARFLAGS) $@ $^
$(LIBSHARED): $(OBJS)
$(CC) $(SO_LDFLAGS) -o $@ $^
# Object files
%.o: %.c atomic_store.h
$(CC) $(CFLAGS) -fPIC -c $< -o $@
clean:
rm -f $(OBJS) $(LIBSTATIC) $(LIBSHARED) $(TEST_BIN)