summaryrefslogtreecommitdiffstats
path: root/src/winpcap.mk
blob: a4c6441fec42c4621dd39f4a5a2534fea31e55df (plain)
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
# This file is part of MXE. See LICENSE.md for licensing information.

PKG             := winpcap
$(PKG)_WEBSITE  := https://www.winpcap.org/
$(PKG)_DESCR    := WinPcap
$(PKG)_IGNORE   :=
$(PKG)_VERSION  := 4_1_3
$(PKG)_CHECKSUM := 346a93f6b375ac4c1add5c8c7178498f1feed4172fb33383474a91b48ec6633a
$(PKG)_SUBDIR   := winpcap
$(PKG)_FILE     := WpcapSrc_$($(PKG)_VERSION).zip
$(PKG)_URL      := https://www.winpcap.org/install/bin/$($(PKG)_FILE)
$(PKG)_DEPS     := gcc

define $(PKG)_UPDATE
    $(WGET) -q -O- 'https://www.winpcap.org/devel.htm' | \
    $(SED) -n 's,.*WpcapSrc_\([0-9][^>]*\)\.zip.*,\1,p' | \
    head -1
endef

define $(PKG)_BUILD
    # build
    cd '$(1)' && $(TARGET)-gcc -ICommon -IpacketNtx/Dll -O -c '$(1)/packetNtx/Dll/Packet32.c' -D_WINNT4
    cd '$(1)' && $(TARGET)-gcc -ICommon -IpacketNtx/Dll -O -c '$(1)/packetNtx/Dll/AdInfo.c'
    cd '$(1)' && $(TARGET)-gcc -ICommon -IpacketNtx/Dll -O -c '$(1)/packetNtx/Dll/NpfImExt.c'
    $(TARGET)-ar rc '$(1)/libpacket.a' '$(1)/Packet32.o' '$(1)/AdInfo.o' '$(1)/NpfImExt.o'
    $(TARGET)-ranlib '$(1)/libpacket.a'
    $(INSTALL) -d '$(PREFIX)/$(TARGET)/lib'
    $(INSTALL) -m644 '$(1)/libpacket.a' '$(PREFIX)/$(TARGET)/lib/'

    mv '$(1)/wpcap/libpcap/Win32/Include/ip6_misc.h' '$(1)/file.tmp'
    mv '$(1)/file.tmp' '$(1)/wpcap/libpcap/Win32/Include/IP6_misc.h'

    CC='$(TARGET)-gcc' \
    AR='$(TARGET)-ar' \
    RANLIB='$(TARGET)-ranlib' \
    $(MAKE) -C '$(1)/wpcap/PRJ' -j 1 libwpcap.a

    $(INSTALL) -d '$(PREFIX)/$(TARGET)/include'
    $(INSTALL) -m644 \
         $(1)/wpcap/libpcap/Win32/Include/IP6_misc.h \
         $(1)/wpcap/libpcap/pcap-namedb.h \
         $(1)/wpcap/libpcap/pcap-bpf.h \
         $(1)/wpcap/libpcap/remote-ext.h \
         $(1)/Common/Packet32.h \
         $(1)/wpcap/Win32-Extensions/Win32-Extensions.h \
         $(1)/wpcap/libpcap/Win32/Include/bittypes.h \
         $(1)/wpcap/libpcap/pcap-stdinc.h \
         $(1)/wpcap/libpcap/pcap.h \
        '$(PREFIX)/$(TARGET)/include/'

    $(INSTALL) -d '$(PREFIX)/$(TARGET)/include/pcap'
    $(INSTALL) -m644 \
        $(1)/wpcap/libpcap/pcap/namedb.h \
        $(1)/wpcap/libpcap/pcap/sll.h \
        $(1)/wpcap/libpcap/pcap/bpf.h \
        $(1)/wpcap/libpcap/pcap/usb.h \
        $(1)/wpcap/libpcap/pcap/pcap.h \
        $(1)/wpcap/libpcap/pcap/bluetooth.h \
        $(1)/wpcap/libpcap/pcap/vlan.h \
        '$(PREFIX)/$(TARGET)/include/pcap/'

    $(INSTALL) -m644 '$(1)/wpcap/PRJ/libwpcap.a' '$(PREFIX)/$(TARGET)/lib/'

    # create pkg-config file
    $(INSTALL) -d '$(PREFIX)/$(TARGET)/lib/pkgconfig'
    (echo 'Name: $(PKG)'; \
     echo 'Version: $($(PKG)_VERSION)'; \
     echo 'Description: $($(PKG)_DESCR)'; \
     echo 'Requires:'; \
     echo 'Libs: -lwpcap -lpacket -lws2_32 -lversion'; \
     echo 'Cflags: -I$(PREFIX)/$(TARGET)/include/pcap';) \
     > '$(PREFIX)/$(TARGET)/lib/pkgconfig/$(PKG).pc'

    # compile test
    '$(TARGET)-gcc' \
        -W -Wall \
        '$(SOURCE_DIR)/Examples-pcap/basic_dump_ex/basic_dump_ex.c' -o '$(PREFIX)/$(TARGET)/bin/test-$(PKG).exe' \
        `'$(TARGET)-pkg-config' $(PKG) --cflags --libs`
endef

$(PKG)_BUILD_SHARED =