-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
57 lines (50 loc) · 1.55 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
TARGET = uri_parser
LIB_NAME = uri_parser
PKG_NAME = uri-parser
PREFIX ?= /usr/local
UNAME := $(shell uname)
.PHONY: install package
all: $(TARGET)
$(TARGET): *.c
clang -c *.c
ifeq ($(UNAME), Linux) # build for linux
ar -rcs lib$(LIB_NAME).a *.o
endif
ifeq ($(UNAME), Darwin) # build for darwin
libtool -dynamic *.o -o lib$(LIB_NAME).dylib -lSystem -macosx_version_min 10.11
endif
rm *.o
install:
mkdir -p $(TARGET)/usr/local/lib
mkdir -p $(TARGET)/usr/local/include/$(TARGET)
cp *.h $(TARGET)/usr/local/include/$(TARGET)
ifeq ($(UNAME), Darwin)
# copy .dylib
cp lib$(LIB_NAME).dylib $(TARGET)/usr/local/lib/
endif
ifeq ($(UNAME), Linux)
# copy .a
cp lib$(LIB_NAME).a $(TARGET)/usr/local/lib/
endif
mkdir -p $(PREFIX)
cp -r $(TARGET)/usr/local/* $(PREFIX)/
package:
ifeq ($(UNAME), Linux)
mkdir -p $(TARGET)/DEBIAN
mkdir -p $(TARGET)/usr/local/lib
mkdir -p $(TARGET)/usr/local/include/$(TARGET)
cp *.h $(TARGET)/usr/local/include/$(TARGET)
cp lib$(LIB_NAME).a $(TARGET)/usr/local/lib/
touch $(TARGET)/DEBIAN/control
echo "Package: $(PKG_NAME)" >> $(TARGET)/DEBIAN/control
echo "Version: 0.1.0" >> $(TARGET)/DEBIAN/control
echo "Section: custom" >> $(TARGET)/DEBIAN/control
echo "Priority: optional" >> $(TARGET)/DEBIAN/control
echo "Architecture: all" >> $(TARGET)/DEBIAN/control
echo "Essential: no" >> $(TARGET)/DEBIAN/control
echo "Installed-Size: 4772" >> $(TARGET)/DEBIAN/control
echo "Maintainer: zewo.io" >> $(TARGET)/DEBIAN/control
echo "Description: $(TARGET)" >> $(TARGET)/DEBIAN/control
dpkg-deb --build $(TARGET)
rm -rf $(TARGET)
endif