-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
61 lines (49 loc) · 1.42 KB
/
Makefile
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
CXX := g++
CXXFLAGS := -Wall -std=c++17 -g -framework IOKit
EXES := smctemp
STATIC_LIB := libsmctemp.a
DEST_PREFIX := /usr/local
AR := ar
ARFLAGS := rc
RANLIB := ranlib
ARCH := $(shell uname -m)
PROCESS_IS_TRANSLATED := $(shell sysctl -in sysctl.proc_translated)
ifeq ($(ARCH), x86_64)
ifeq ($(PROCESS_IS_TRANSLATED), 1)
# Running under Rosetta
CXXFLAGS += -DARCH_TYPE_ARM64
else
CXXFLAGS += -DARCH_TYPE_X86_64
endif
else ifeq ($(ARCH), arm64)
CXXFLAGS += -DARCH_TYPE_ARM64
else
$(error Not support architecture: $(ARCH))
endif
OBJS := smctemp.o \
smctemp_string.o
HEADERS := smctemp.h \
smctemp_string.h \
smctemp_types.h
all: $(EXES)
$(EXES): $(OBJS) main.cc
$(CXX) $(CXXFLAGS) -o $(EXES) $(OBJS) main.cc
staticlib: $(OBJS)
$(RM) $(STATIC_LIB)
$(AR) $(ARFLAGS) $(STATIC_LIB) $^
$(RANLIB) $(STATIC_LIB)
smctemp.o: smctemp_string.h smctemp.h smctemp.cc
$(CXX) $(CXXFLAGS) -o smctemp.o -c smctemp.cc
smctemp_string.o: smctemp_string.h smctemp_string.cc
$(CXX) $(CXXFLAGS) -o smctemp_string.o -c smctemp_string.cc
install: $(EXES)
install -d $(DEST_PREFIX)/bin
install -m 0755 $(EXES) $(DEST_PREFIX)/bin
installstaticlib: $(STATIC_LIB)
install -d $(DEST_PREFIX)/lib
install -d $(DEST_PREFIX)/include
install -m 0644 $(STATIC_LIB) $(DEST_PREFIX)/lib
install -m 0644 $(HEADERS) $(DEST_PREFIX)/include
clean:
$(RM) -r $(EXES) smctemp.o smctemp_string.o smctemp.dSYM $(STATIC_LIB)
.PHONY: clean