From 1f3bc80ed11961ea8472e30a70560964b77b5ee2 Mon Sep 17 00:00:00 2001 From: Anthony Samms Date: Mon, 15 Sep 2025 11:36:55 -0400 Subject: [PATCH] please work --- .github/workflows/python-app.yml | 8 --- libs/audio/Makefile | 100 +++++++++++++++++++++++++++---- 2 files changed, 87 insertions(+), 21 deletions(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 4578fb9..f5e1386 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -115,10 +115,6 @@ jobs: Copy-Item "libaudio.dll" "../../build/lib/" echo "Copied libaudio.dll" } - if (Test-Path "audio.dll") { - Copy-Item "audio.dll" "../../build/lib/" - echo "Copied audio.dll" - } # Copy vcpkg DLLs that are needed at runtime $vcpkgBin = "$env:VCPKG_INSTALLATION_ROOT/installed/x64-windows/bin" @@ -130,10 +126,6 @@ jobs: } } - # Verify what was copied - echo "Files in build/lib:" - ls ../../build/lib/ - # Add to PATH echo "${{ github.workspace }}/build/lib" >> $env:GITHUB_PATH shell: powershell diff --git a/libs/audio/Makefile b/libs/audio/Makefile index b4bc1e9..e28e95c 100644 --- a/libs/audio/Makefile +++ b/libs/audio/Makefile @@ -1,31 +1,94 @@ # Makefile for audio library +# Default compiler and flags for Unix-like systems CC = gcc CFLAGS = -Wall -Wextra -O3 -fPIC -std=c99 LDFLAGS = -shared -Wl,--export-dynamic LIBS = -lportaudio -lsndfile -lsamplerate -lpthread -lm -# Detect OS for library naming -UNAME_S := $(shell uname -s) -ifeq ($(UNAME_S),Darwin) +# Detect OS and set appropriate flags +UNAME_S := $(shell uname -s 2>/dev/null || echo Windows) + +# Windows detection (including GitHub Actions Windows runners) +ifneq (,$(findstring Windows,$(UNAME_S))) + # Windows with MSVC + CC = cl + LIBNAME = libaudio.dll + CFLAGS = /O2 /W3 /MD /TC + LDFLAGS = /DLL + LIBS = portaudio.lib libsndfile.lib libsamplerate.lib + OBJ_EXT = .obj + + # Check for vcpkg environment + ifdef VCPKG_INSTALLATION_ROOT + INCLUDE_PATH = /I"$(VCPKG_INSTALLATION_ROOT)/installed/x64-windows/include" + LIB_PATH = /LIBPATH:"$(VCPKG_INSTALLATION_ROOT)/installed/x64-windows/lib" + CFLAGS += $(INCLUDE_PATH) + LDFLAGS += $(LIB_PATH) + endif + + # Check for environment variables set by GitHub Actions + ifdef VCPKG_INCLUDE_PATH + CFLAGS += /I"$(VCPKG_INCLUDE_PATH)" + endif + ifdef VCPKG_LIB_PATH + LDFLAGS += /LIBPATH:"$(VCPKG_LIB_PATH)" + endif + +else ifeq ($(UNAME_S),Darwin) + # macOS LIBNAME = libaudio.dylib CFLAGS += -I/usr/local/include -I/opt/homebrew/include LDFLAGS = -shared -undefined dynamic_lookup LDFLAGS += -L/usr/local/lib -L/opt/homebrew/lib + OBJ_EXT = .o + else ifeq ($(UNAME_S),Linux) + # Linux LIBNAME = libaudio.so + OBJ_EXT = .o + else - LIBNAME = libaudio.dll - LIBS += -lole32 -lwinmm - LDFLAGS = -shared + # Generic Unix fallback + LIBNAME = libaudio.so + OBJ_EXT = .o endif SOURCES = $(wildcard *.c) -OBJECTS = $(SOURCES:.c=.o) -.PHONY: all clean install +# Object files with correct extension +ifneq (,$(findstring Windows,$(UNAME_S))) + OBJECTS = $(SOURCES:.c=.obj) +else + OBJECTS = $(SOURCES:.c=.o) +endif + +.PHONY: all clean install debug check-deps all: $(LIBNAME) +# Windows-specific build rule +ifneq (,$(findstring Windows,$(UNAME_S))) +$(LIBNAME): $(OBJECTS) + link $(LDFLAGS) /OUT:$@ $^ $(LIBS) + +%.obj: %.c + $(CC) $(CFLAGS) /c $< /Fo:$@ + +clean: + -del /Q *.obj $(LIBNAME) 2>nul || rm -f $(OBJECTS) $(LIBNAME) + +install: + @echo "Install not implemented for Windows. Copy $(LIBNAME) to your application directory." + +check-deps: + @echo "Checking dependencies on Windows..." + @echo "Assuming vcpkg dependencies are installed..." + @if exist "$(VCPKG_INSTALLATION_ROOT)\installed\x64-windows\include\portaudio.h" (echo PortAudio found!) else (echo PortAudio not found! && exit 1) + @if exist "$(VCPKG_INSTALLATION_ROOT)\installed\x64-windows\include\sndfile.h" (echo libsndfile found!) else (echo libsndfile not found! && exit 1) + @echo "All dependencies found!" + +else +# Unix/Linux/macOS build rules $(LIBNAME): $(OBJECTS) $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) @@ -39,13 +102,24 @@ install: $(LIBNAME) sudo cp $(LIBNAME) /usr/local/lib/ sudo ldconfig 2>/dev/null || true -# Development target with debug symbols -debug: CFLAGS += -g -DDEBUG -debug: $(LIBNAME) - -# Check dependencies check-deps: @echo "Checking dependencies..." @pkg-config --exists portaudio-2.0 || (echo "PortAudio not found!" && false) @pkg-config --exists sndfile || (echo "libsndfile not found!" && false) @echo "All dependencies found!" + +endif + +# Development target with debug symbols (cross-platform) +debug: CFLAGS += $(if $(findstring Windows,$(UNAME_S)),/Zi,-g -DDEBUG) +debug: $(LIBNAME) + +# Help target +help: + @echo "Available targets:" + @echo " all - Build the audio library (default)" + @echo " clean - Remove build artifacts" + @echo " install - Install library (Unix/Linux/macOS only)" + @echo " debug - Build with debug symbols" + @echo " check-deps- Check for required dependencies" + @echo " help - Show this help message"