-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
89 lines (67 loc) · 2.33 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
CC ?= gcc
CFLAGS += -Wall -g
CXX ?= g++
CXXFLAGS += -Wall -g
COBJS = hid.o
CCOBJS = ptrim-lib.o
LIBS = -l curses
INCLUDES += -I hidapi/ -I src/
UNAME := $(shell uname)
ifeq ($(UNAME), )
UNAME = Win
endif
ALL = ptrim ptrim-server ptrim-client
ifeq ($(UNAME), Linux)
LIBS += `pkg-config libusb-1.0 libudev --libs`
INCLUDES += `pkg-config libusb-1.0 --cflags`
OS = linux
endif
ifeq ($(UNAME), Darwin)
LIBS += -framework IOKit -framework CoreFoundation
OS = mac
endif
ifeq ($(UNAME), Win)
LIBS = -lsetupapi
OS = windows
ALL = ptrim
endif
INCLUDES += -I hidapi/$(OS)/
ROOT_TEST = if test `whoami` != "root"; then echo "You need to be root to install, try using sudo" >&2; exit 1; fi
MAN1_PAGES = man/man1/ptrim.1.bz2 man/man1/ptrim-server.1.bz2 man/man1/ptrim-client.1.bz2
MAN_PAGES = $(MAN1_PAGES)
VERSION = 0.3.1
DIRECTORY = PlasmaTrim_CLI-$(OS)-v$(VERSION)
all: $(ALL)
install: all man
$(ROOT_TEST)
install ptrim ptrim-server ptrim-client /usr/bin/
install-zip: all $(MAN_PAGES)
mkdir -p $(DIRECTORY)
echo '#!/bin/bash' > $(DIRECTORY)/install.sh
echo '$(ROOT_TEST)' >> $(DIRECTORY)/install.sh
echo 'install $(MAN1_PAGES) /usr/share/man/man1/' >> $(DIRECTORY)/install.sh
echo 'install ptrim ptrim-server ptrim-client /usr/bin/' >> $(DIRECTORY)/install.sh
chmod 755 $(DIRECTORY)/install.sh
cp -a ptrim ptrim-server ptrim-client $(DIRECTORY)
mkdir -p $(DIRECTORY)/man/man1
cp -a $(MAN1_PAGES) $(DIRECTORY)/man/man1
zip -r $(DIRECTORY).zip $(DIRECTORY)
ptrim: $(COBJS) $(CCOBJS) ptrim.o
$(CXX) $(CXXFLAGS) $(LDFLAGS) $^ $(LIBS) -o ptrim
ptrim-server: $(COBJS) $(CCOBJS) ptrim-server.o
$(CXX) $(CXXFLAGS) $(LDFLAGS) $^ $(LIBS) -o ptrim-server
ptrim-client: $(COBJS) $(CCOBJS) ptrim-client.o
$(CXX) $(CXXFLAGS) $(LDFLAGS) $^ $(LIBS) -o ptrim-client
man: $(MAN_PAGES)
$(ROOT_TEST)
install $(MAN1_PAGES) /usr/share/man/man1/
man/%.bz2: man/%
bzip2 -kf $?
hid.o: hidapi/$(OS)/hid.c
$(CC) $(CFLAGS) -c $(INCLUDES) $< -o $@
%.o: src/%.cc src/*.h
$(CXX) $(CXXFLAGS) -c $(INCLUDES) -Wno-write-strings $< -o $@
clean:
rm -f *.o ptrim ptrim-server ptrim-client man/*/*bz2
rm -rf PlasmaTrim_CLI-*
.PHONY: clean install man