forked from ProcursusTeam/Procursus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lsof.mk
60 lines (49 loc) · 1.96 KB
/
lsof.mk
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
ifneq ($(PROCURSUS),1)
$(error Use the main Makefile)
endif
SUBPROJECTS += lsof
DOWNLOAD += https://opensource.apple.com/tarballs/lsof/lsof-$(LSOF_VERSION).tar.gz
LSOF_VERSION := 62
DEB_LSOF_V ?= $(LSOF_VERSION)
lsof-setup: setup
$(call EXTRACT_TAR,lsof-$(LSOF_VERSION).tar.gz,lsof-$(LSOF_VERSION),lsof)
mkdir -p $(BUILD_STAGE)/lsof/usr/{sbin,share/man/man8}
$(SED) -i 's/lcurses/lncursesw/' $(BUILD_WORK)/lsof/lsof/Configure
# Mess of copying over headers because some build_base headers interfere with the build of Apple cmds.
mkdir -p $(BUILD_WORK)/lsof/lsof/include/rpc
wget -q -nc -P $(BUILD_WORK)/lsof/lsof/include/rpc \
https://opensource.apple.com/source/Libinfo/Libinfo-538/rpc.subproj/pmap_prot.h
ifneq ($(wildcard $(BUILD_WORK)/lsof/.build_complete),)
lsof:
@echo "Using previously built lsof."
else
lsof: lsof-setup network-cmds-setup ncurses
cd $(BUILD_WORK)/lsof/lsof; \
DARWIN_BASE=libproc LSOF_VERS=1700 \
LSOF_INCLUDE=$(BUILD_BASE)/usr/include \
./Configure -n darwin
unlink $(BUILD_WORK)/lsof/lsof/dchannel.c && touch $(BUILD_WORK)/lsof/lsof/dchannel.c
echo -e "#include \"lsof.h\"\n \
void process_channel(int pid, int32_t fd){}" > $(BUILD_WORK)/lsof/lsof/dchannel.c
cd $(BUILD_WORK)/lsof/lsof; \
$(MAKE) \
CC=$(CC) \
AR="$(AR) cr \$${LIB} \$${OBJ}" \
RANLIB="$(RANLIB) \$${LIB}" \
RC_CFLAGS="$(CFLAGS) -DHASUTMPX -isystem $(BUILD_WORK)/network-cmds/include -isystem $(BUILD_WORK)/lsof/lsof/include -L$(BUILD_BASE)/usr/lib"
cp -a $(BUILD_WORK)/lsof/lsof/lsof $(BUILD_STAGE)/lsof/usr/sbin
cp -a $(BUILD_WORK)/lsof/lsof/lsof.8 $(BUILD_STAGE)/lsof/usr/share/man/man8
touch $(BUILD_WORK)/lsof/.build_complete
endif
lsof-package: lsof-stage
# lsof.mk Package Structure
rm -rf $(BUILD_DIST)/lsof
# lsof.mk Prep lsof
cp -a $(BUILD_STAGE)/lsof $(BUILD_DIST)
# lsof.mk Sign
$(call SIGN,lsof,general.xml)
# lsof.mk Make .debs
$(call PACK,lsof,DEB_LSOF_V)
# lsof.mk Build cleanup
rm -rf $(BUILD_DIST)/lsof
.PHONY: lsof lsof-package