1
mirror of https://github.com/rapid7/metasploit-payloads synced 2025-02-28 06:13:03 +01:00
Brent Cook 0d59fc7447 support building on newer Linux systems and Makefile cleanups
- try to share some bits between different makefiles, make modifying
   global compiler flags not such a huge pain.
 - directly specify we should be using the gold rather than bpf linker
 - make compiler output largely quiet except where we care - allow
   warnings to actually be visible
 - don't delete downloaded tarballs with --really-clean
 - add missing dependencies between libraries
   (--no-add-needed/--no-copy-dt-needed-entries causes lots of trouble)
 - update readme to show what to install to build

I made minimal changes to the loader makefile - it breaks easily.
 -Os prevents if from being able to load libc, for instance
2015-01-13 16:33:56 -06:00

30 lines
2.2 KiB
Makefile

PCAP_VERSION=1.1.1
$(COMPILED)/libpcap.so: $(build_tmp)/libpcap-$(PCAP_VERSION)/libpcap.so.$(PCAP_VERSION)
cp $(build_tmp)/libpcap-$(PCAP_VERSION)/libpcap.so.$(PCAP_VERSION) $(COMPILED)/libpcap.so
$(build_tmp)/libpcap-$(PCAP_VERSION)/libpcap.so.$(PCAP_VERSION):
[ -d $(build_tmp) ] || mkdir $(build_tmp)
[ -f $(build_tmp)/libpcap-$(PCAP_VERSION).tar.gz ] || wget -O $(build_tmp)/libpcap-$(PCAP_VERSION).tar.gz http://www.tcpdump.org/release/libpcap-$(PCAP_VERSION).tar.gz
[ -f $(build_tmp)/libpcap-$(PCAP_VERSION)/configure ] || tar -C $(build_tmp) -xzf $(build_tmp)/libpcap-$(PCAP_VERSION).tar.gz
(cd $(build_tmp)/libpcap-$(PCAP_VERSION) && ./configure --disable-bluetooth --without-bluetooth --without-usb --disable-usb --without-can --disable-can --without-usb-linux --disable-usb-linux --without-libnl > build.log)
echo '#undef HAVE_DECL_ETHER_HOSTTON' >> $(build_tmp)/libpcap-$(PCAP_VERSION)/config.h
echo '#undef HAVE_SYS_BITYPES_H' >> $(build_tmp)/libpcap-$(PCAP_VERSION)/config.h
echo '#undef PCAP_SUPPORT_CAN' >> $(build_tmp)/libpcap-$(PCAP_VERSION)/config.h
echo '#undef PCAP_SUPPORT_USB' >> $(build_tmp)/libpcap-$(PCAP_VERSION)/config.h
echo '#undef HAVE_ETHER_HOSTTON' >> $(build_tmp)/libpcap-$(PCAP_VERSION)/config.h
echo '#define _STDLIB_H this_works_around_malloc_definition_in_grammar_dot_c' >> $(build_tmp)/libpcap-$(PCAP_VERSION)/config.h
(cd $(build_tmp)/libpcap-$(PCAP_VERSION) && patch -p0 < $(cwd)/source/libpcap/pcap_nametoaddr_fix.diff)
(cd $(build_tmp)/libpcap-$(PCAP_VERSION) && patch -p0 < $(cwd)/source/libpcap/pcap-linux.diff)
(cd $(build_tmp)/libpcap-$(PCAP_VERSION) && patch -p1 < $(cwd)/source/libpcap/longjmp.diff)
sed -i -e s/pcap-usb-linux.c//g -e s/fad-getad.c/fad-gifc.c/g $(build_tmp)/libpcap-$(PCAP_VERSION)/Makefile
sed -i -e s^"CC = gcc"^"CC = gcc $(PCAP_CFLAGS)"^g $(build_tmp)/libpcap-$(PCAP_VERSION)/Makefile
$(MAKE) -C $(build_tmp)/libpcap-$(PCAP_VERSION) >> build.log
clean-pcap:
#(cd $(build_tmp)/libpcap-$(PCAP_VERSION)/ && make clean)
# This avoids the pcap target trying to patch the same file more than once.
# It's a pretty small tar, so untar'ing goes pretty quickly anyway, in
# contrast to openssl.
rm -fr $(COMPILED)/libpcap.so $(build_tmp)/libpcap-$(PCAP_VERSION)