Skip to content

Conversation

@rajamukerji
Copy link

This pull request adds comprehensive macOS build support and fixes compilation warnings throughout the codebase.

Changes Made

macOS Build Support

  • Updated vars.mk to remove outdated macOS SDK specification
  • Enhanced Makefile with proper macOS compiler flags and library paths
  • Added macOS-specific build instructions to README
  • Updated minimum macOS version to 10.12
  • Added warning suppression flags for deprecated prototypes

Compilation Fixes

  • Fixed _U_ macro definition for macOS compatibility
  • Modernized function prototypes throughout the codebase
  • Fixed header guard issues in multiple files
  • Resolved type casting warnings
  • Fixed variable type mismatches (socklen_t vs int)
  • Prevented duplicate symbol definitions

Code Quality Improvements

  • Added proper header guards to prevent multiple inclusions
  • Modernized K&R style function declarations to ANSI C
  • Fixed compiler warnings for better code quality
  • Improved platform-specific conditional compilation

Testing

Builds successfully on macOS with make PLATFORM=osx after installing libpcap via Homebrew.

Files Modified

  • README.md - Added macOS build instructions
  • vars.mk - Updated macOS compiler configuration
  • Multiple .c/.h files - Fixed function prototypes and warnings
  • Makefile - Enhanced macOS build support

This maintains backward compatibility while enabling clean compilation on modern macOS systems.

## Changes Made

### Build System Fixes
- Update macOS SDK version from 10.8 to current SDK
- Fix Makefile to properly define OSXTARGET and OSXLIB variables
- Use xcrun clang instead of specific SDK version

### Header Guards
- Add missing header guards to gencode.h to prevent redefinition errors

### Compilation Fixes
- Fix pointer sign conversion warnings in daemon.c and pcap-remote.c
- Fix socklen_t type mismatch in getsockopt call
- Remove tautological pointer comparisons for array variables
- Fix varargs warning in rpcap_checkmsg function
- Guard INT_MAX macro redefinition in inet.c

### Function Prototypes
- Update deprecated K&R style function definitions to modern C prototypes
- Fix functions in scanner.l, inet.c, nametoaddr.c, and bpf_image.c

### Missing Symbols
- Add missing pcap_parse and pcap_strcasecmp function definitions
- Include required source files (gencode.c, nametoaddr.c, etc.) in build

## Result
- rpcapd now builds successfully on macOS with only legacy warnings
- All functional compilation errors eliminated
- Binary tested and working on macOS
Add _U_ macro definition to pcap-int.h to resolve compilation errors.
The _U_ macro is used for unused variable attributes but was not defined,
causing build failures on macOS.
Add platform-specific build instructions for Linux, macOS, and Windows.
Include the PLATFORM=osx flag required for macOS builds.
- Add -Wno-deprecated-non-prototype to suppress K&R style function warnings
- Add -Wno-return-type to suppress missing return value warnings
- Add -Wl,-w to suppress linker warnings
- Enables clean builds on macOS without affecting functionality
The port parameter can be NULL, so we need to check for this condition
before dereferencing it to prevent potential segmentation faults.
The ctrlport parameter can be NULL, so we need to check for this condition
before dereferencing it to prevent potential segmentation faults.
Remove NULL checks for array pointers in pcap-new.c and pcap-remote.c
as arrays can never be NULL. This fixes compiler warnings on macOS.
- Add missing stdlib.h include in fileconf.c for atoi function
- Replace _U_ macro with __attribute__((unused)) in rcsid declarations
- Add missing pcap.c and savefile.c to Makefile sources
- Fix sys_nerr type declaration to match system headers

These fixes resolve compilation errors that prevented the build from
completing successfully on macOS with modern compilers.
- Add platform detection for macOS/Darwin in Makefile
- Add Solaris platform support to the Makefile
- Fix yacc and lex commands to use pcap_ prefix for generated symbols
- This resolves linking errors for pcap_parse, pcap_lval, and pcap_lex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant