forked from pilight/pilight
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.old
144 lines (122 loc) · 6.4 KB
/
Makefile.old
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
GCC = $(CROSS_COMPILE)gcc
SYS := $(shell $(GCC) -dumpmachine)
ifdef CROSS_COMPILE
INCLUDE = -isystem/usr/include/ -isystem/usr/include/x86_64-linux-gnu/
endif
ifneq (, $(findstring x86_64, $(SYS)))
OSFLAGS = -Ofast -fPIC -march=native -mtune=native -mfpmath=sse -Wconversion -Wunreachable-code -Wstrict-prototypes
endif
ifneq (, $(findstring arm, $(SYS)))
ifneq (, $(findstring gnueabihf, $(SYS)))
OSFLAGS = -Ofast -mfloat-abi=hard -mfpu=vfp -march=armv6 -Wconversion -Wunreachable-code -Wstrict-prototypes
endif
ifneq (, $(findstring gnueabi, $(SYS)))
OSFLAGS = -Ofast -mfloat-abi=hard -mfpu=vfp -march=armv6 -Wconversion -Wunreachable-code -Wstrict-prototypes
endif
ifneq (, $(findstring gnueabisf, $(SYS)))
OSFLAGS = -Ofast -mfloat-abi=soft -mfpu=vfp -march=armv6 -Wconversion -Wunreachable-code -Wstrict-prototypes
endif
endif
ifneq (, $(findstring amd64, $(SYS)))
OSFLAGS = -O3 -fPIC -march=native -mtune=native -mfpmath=sse -Wno-conversion
endif
GIT_HASH := $(shell git describe --always)
CFLAGS = -ffast-math $(OSFLAGS) -Wl,-rpath=/usr/local/lib/,-rpath=/usr/lib/,-rpath=/lib/ -Wfloat-equal -Wshadow -Wpointer-arith -Wcast-align -Wstrict-overflow=5 -Wwrite-strings -Waggregate-return -Wcast-qual -Wswitch-default -Wswitch-enum -Wformat=2 -g -Wall -I. -isystem.. -Ilibs/pilight/ -Ilibs/protocols/ -Ilibs/hardware/ -Ilibs/avrdude/ -pthread -lm -ldl -DHASH=\"$(GIT_HASH)\"
SUBDIRS = libs/pilight libs/protocols libs/hardware libs/avrdude
SRC = $(wildcard *.c)
INCLUDES = $(wildcard libs/pilight/*.c) $(wildcard libs/avrdude/*.c)
PROGAMS = $(patsubst %.c,pilight-%,$(SRC))
LIBS = libs/pilight/pilight.o libs/avrdude/avrdude.o libs/protocols/protocols.o libs/hardware/hardware.o
PROTCOLS := $(shell cd libs/protocols/ && find * -name \*.so)
HARDWARE := $(shell cd libs/hardware/ && find * -name \*.so)
WEBFILES := $(shell cd web && find * -type f)
WEBDIRS := $(shell cd web && find * -type d )
.PHONY: subdirs $(SUBDIRS)
subdirs: modules $(SUBDIRS) all
modules:
ls libs/protocols/*.h | sed -e"" 's/libs/ #include "../g' -e"" 's/\.h/\.h"/g' > libs/pilight/protocol_header.h
grep -h ".*Init(void)" libs/protocols/*.c | sed -e"" "s/void / /" -e"" "s/(void) {/();/" > libs/pilight/protocol_init.h
ls libs/hardware/*.h | sed -e"" 's/libs/ #include "../g' -e"" 's/\.h/\.h"/g' > libs/pilight/hardware_header.h
grep -h "void .*Init(void)" libs/hardware/*.c | sed -e"" "s/void / /" -e"" "s/(void) {/();/" > libs/pilight/hardware_init.h
$(SUBDIRS):
$(MAKE) -C $@ GIT_HASH=$(GIT_HASH)
all: $(LIBS) libpilight.so libpilight.a $(PROGAMS)
libpilight.so: $(LIBS)
$(GCC) $(LIBS) -shared -o libpilight.so -lpthread -lm -ldl
libpilight.a: $(LIBS)
$(CROSS_COMPILE)ar -rsc libpilight.a $(LIBS)
pilight-daemon: daemon.c $(INCLUDES) $(LIBS) libpilight.so
$(GCC) $(CFLAGS) -o $@ $(patsubst pilight-%,%.c,$@) libpilight.so -lz -lrt
pilight-send: send.c $(INCLUDES) $(LIBS) libpilight.so
$(GCC) $(CFLAGS) -o $@ $(patsubst pilight-%,%.c,$@) libpilight.so -lz -lrt
pilight-receive: receive.c $(INCLUDES) $(LIBS) libpilight.so
$(GCC) $(CFLAGS) -o $@ $(patsubst pilight-%,%.c,$@) libpilight.so -lz -lrt
pilight-debug: debug.c $(INCLUDES) $(LIBS) libpilight.so
$(GCC) $(CFLAGS) -o $@ $(patsubst pilight-%,%.c,$@) libpilight.so -lz -lrt
pilight-learn: learn.c $(INCLUDES) $(LIBS) libpilight.so
$(GCC) $(CFLAGS) -o $@ $(patsubst pilight-%,%.c,$@) libpilight.so -lz -lrt
pilight-control: control.c $(INCLUDES) $(LIBS) libpilight.so
$(GCC) $(CFLAGS) -o $@ $(patsubst pilight-%,%.c,$@) libpilight.so -lz -lrt
pilight-raw: raw.c $(INCLUDES) $(LIBS) libpilight.so
$(GCC) $(CFLAGS) -o $@ $(patsubst pilight-%,%.c,$@) libpilight.so -lz -lrt
pilight-uuid: uuid.c $(INCLUDES) $(LIBS) libpilight.so
$(GCC) $(CFLAGS) -o $@ $(patsubst pilight-%,%.c,$@) libpilight.so -lz -lrt
pilight-flash: flash.c $(INCLUDES) $(LIBS) libpilight.so
$(GCC) $(CFLAGS) -o $@ $(patsubst pilight-%,%.c,$@) libpilight.so -lz -lrt
install:
[ -d /usr/share/images/pilight/ ] && rm -r /usr/share/images/pilight/ || true
install -m 0755 -d /usr/local/lib/pilight/
install -m 0755 -d /usr/local/lib/pilight/protocols/
install -m 0755 -d /usr/local/lib/pilight/hardware/
install -m 0755 -d /usr/local/sbin
install -m 0755 -d /usr/local/bin
install -m 0755 -d /etc/pilight
for f in $(WEBDIRS) ; do \
install -m 0755 -d /usr/local/share/pilight/$$f; \
done
install -m 0655 pilight-daemon /usr/local/sbin/
install -m 0655 pilight-send /usr/local/bin/
install -m 0655 pilight-receive /usr/local/bin/
install -m 0655 pilight-control /usr/local/bin/
install -m 0655 pilight-debug /usr/local/sbin/
install -m 0655 pilight-learn /usr/local/sbin/
install -m 0655 pilight-raw /usr/local/sbin/
install -m 0655 pilight-uuid /usr/local/bin/
install -m 0655 pilight-flash /usr/local/sbin/
install -m 0655 libpilight.so /usr/local/lib/pilight/
install -m 0655 libpilight.a /usr/local/lib/pilight/
install -m 0644 settings.json-default /etc/pilight/
for f in $(WEBFILES) ; do \
cd web/ && install -D $$f /usr/local/share/pilight/`dirname $$f` || true && cd ..; \
done
for f in $(PROTCOLS) ; do \
cd libs/protocols/ && install -D $$f /usr/local/lib/pilight/protocols/ || true && cd .. && cd ..; \
done
for f in $(HARDWARE) ; do \
cd libs/hardware/ && install -D $$f /usr/local/lib/pilight/hardware/ || true && cd .. && cd ..; \
done
install -m 0755 init/pilight.initd /etc/init.d/
mv /etc/init.d/pilight.initd /etc/init.d/pilight
update-rc.d pilight defaults
[ ! -f /etc/pilight/settings.json ] && mv /etc/pilight/settings.json-default /etc/pilight/settings.json || true
[ ! -f /etc/pilight/hardware.json ] && cp hardware.json /etc/pilight/ || true
[ -f /usr/local/sbin/pilight-control ] && rm /usr/local/sbin/pilight-control || true
[ -f /usr/local/sbin/pilight-send ] && rm /usr/local/sbin/pilight-send || true
[ -f /usr/local/sbin/pilight-receive ] && rm /usr/local/sbin/pilight-receive || true
[ -f /usr/local/sbin/pilight-uuid ] && rm /usr/local/sbin/pilight-uuid || true
cp tzdata.json /etc/pilight/ || true
mv /usr/local/lib/pilight/libpilight.so /usr/local/lib/pilight/libpilight.so.4
ln -sf /usr/local/lib/pilight/libpilight.so.4 /usr/local/lib/libpilight.so
ldconfig
clean:
rm pilight-* >/dev/null 2>&1 || true
rm *pilight*.so* >/dev/null 2>&1 || true
rm *pilight*.a* >/dev/null 2>&1 || true
$(MAKE) -C libs/protocols/ $@;
dist-clean:
rm pilight-* >/dev/null 2>&1 || true
rm *pilight*.so* >/dev/null 2>&1 || true
rm *pilight*.a* >/dev/null 2>&1 || true
for dir in $(SUBDIRS); do \
$(MAKE) -C $$dir $@; \
done