summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 4a111fb9714ada999d09bde85514f42e5fcf7996 (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
TOP	= $(shell readlink -f .)

CC	= gcc
ARCH	= x86-linux64

ifeq ($(ARCH),x86-linux)
CFLAGS	= -m32
endif

INSTALLDIR	= $(TOP)/inst.$(ARCH)

all: sources build pack

sources:
	cd $(TOP)/SOURCES && make

build:
	rm -Rf $(TOP)/build.$(ARCH) && mkdir $(TOP)/build.$(ARCH)
ifneq (,$(findstring x86-mingw,$(ARCH)))
	cd $(TOP)/build.$(ARCH) && \
		unzip $(TOP)/SOURCES/WpdPack_4_1_2.zip
	mkdir -p $(INSTALLDIR)/include
	mkdir -p $(INSTALLDIR)/lib
	cp -rf $(TOP)/build.$(ARCH)/WpdPack/Include/* $(INSTALLDIR)/include/
ifeq ($(ARCH),x86-mingw32)
	cp -f $(TOP)/build.$(ARCH)/WpdPack/Lib/*.a $(INSTALLDIR)/lib/
	cp -f $(TOP)/build.$(ARCH)/WpdPack/Lib/*.lib $(INSTALLDIR)/lib/
else
	cp -f $(TOP)/build.$(ARCH)/WpdPack/Lib/*.a $(INSTALLDIR)/lib/
	cp -f $(TOP)/build.$(ARCH)/WpdPack/Lib/x64/*.lib $(INSTALLDIR)/lib/
endif
else
	cd $(TOP)/build.$(ARCH) && \
		unzip $(TOP)/SOURCES/WpcapSrc_4_1_3.zip
	cd $(TOP)/build.$(ARCH)/winpcap && \
		patch -p0 < $(TOP)/SOURCES/001-missing_sockio_h_linux.patch
	cd $(TOP)/build.$(ARCH)/winpcap/wpcap/libpcap && \
		mkdir -p $(INSTALLDIR)/bin && \
		chmod a+x ./configure && \
		CC=$(CC) CFLAGS=$(CFLAGS) \
		./configure --prefix=$(INSTALLDIR) && \
		make && make install
endif

pack:
	cd $(INSTALLDIR) && \
		tar -zcvf $(TOP)/libpcap-$(ARCH).tgz .

clean:
	find $(INSTALLDIR) -name "pcap*" | xargs rm -Rf
	find $(INSTALLDIR) -type f -name "libpcap*" | xargs rm -f
	rm -Rf build.$(ARCH)

fullclean:
	rm -Rf $(TOP)/inst.*
	rm -Rf $(TOP)/build.*
	rm -f $(TOP)/*.tgz