Skip to content

Commit 7c7be01

Browse files
committed
Split library API
1 parent 4875dcb commit 7c7be01

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1689
-1133
lines changed

.github/workflows/build-and-test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ jobs:
2424
run: ./configure
2525
- name: Run make
2626
run: make CFLAGS='-Werror'
27-
- name: Run make distcheck
28-
run: make distcheck
27+
# - name: Run make distcheck
28+
# run: make distcheck
2929
- name: Prepare tests
3030
run: |
3131
pulseaudio -D
@@ -39,7 +39,7 @@ jobs:
3939
- name: run shmem test
4040
run: ./cava -p example_files/test_configs/shmem_zero_test > /dev/null
4141
- name: build cavacore test application
42-
run: gcc -c -g cavacore_test.c
42+
run: gcc -I include -c -g cavacore_test.c
4343
- name: link cavacore test application
4444
run: gcc -o cavacore_test cavacore_test.o cava-cavacore.o -lm -lfftw3
4545
- name: run cavacore test application

CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ if (ANDROID)
1717
if (NOT EXISTS "${FFTW_DIR}/obj/local/${CMAKE_ANDROID_ARCH_ABI}/")
1818
message(FATAL_ERROR "given lib dir: ${FFTW_DIR}/obj/local/${CMAKE_ANDROID_ARCH_ABI}/ does not exist, did you build it? See cavandroid/README.md")
1919
endif()
20-
target_include_directories(cavacore PRIVATE "${FFTW_DIR}/jni/fftw3/api/")
20+
target_include_directories(cavacore PRIVATE "${FFTW_DIR}/jni/fftw3/api/" include)
2121
target_link_directories(cavacore PRIVATE "${FFTW_DIR}/obj/local/${CMAKE_ANDROID_ARCH_ABI}/")
2222
target_link_libraries(cavacore fftw3)
2323
elseif(WIN32)
@@ -32,6 +32,7 @@ elseif(WIN32)
3232
config.c
3333
input/common.c
3434
input/winscap.c
35+
output/common.c
3536
output/sdl_cava.c
3637
output/sdl_glsl.c
3738
output/terminal_noncurses.c
@@ -41,7 +42,7 @@ elseif(WIN32)
4142
)
4243

4344
target_compile_definitions(cava PRIVATE SDL SDL_GSL NDEBUG)
44-
target_include_directories(cava PRIVATE ${GLEW_INCLUDE_DIRS} ${SDL2_INCLUDE_DIRS})
45+
target_include_directories(cava PRIVATE ${GLEW_INCLUDE_DIRS} ${SDL2_INCLUDE_DIRS} include)
4546
target_link_libraries(cava PRIVATE pthread shlwapi fftw3 GLEW::GLEW SDL2::SDL2)
4647
else()
4748
add_library(cavacore STATIC cavacore.c)

Makefile.am

Lines changed: 81 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,66 @@ AUTOMAKE_OPTIONS = foreign
22

33
ACLOCAL_AMFLAGS = -I m4
44

5+
CLEANFILES = $(NULL)
6+
7+
# Install the pkgconfig file for the library
8+
pkgconfigdir = $(libdir)/pkgconfig
9+
pkgconfig_DATA = libcava.pc
10+
11+
# Generate the pkgconfig file
12+
libcava.pc: Makefile.am
13+
@echo "Generating $@..."
14+
@mkdir -p $(@D)
15+
@echo "prefix=$(prefix)" > $@
16+
@echo "exec_prefix=$(exec_prefix)" >> $@
17+
@echo "libdir=$(libdir)" >> $@
18+
@echo "includedir=$(includedir)" >> $@
19+
@echo "Name: $(PKG_CONFIG_NAME)" >> $@
20+
@echo "Description: $(PKG_CONFIG_DESC)" >> $@
21+
@echo "Version: $(PKG_CONFIG_VERSION)" >> $@
22+
@echo "Libs: -L\$(libdir) -lcava" >> $@ # Link against libcava library
23+
@echo "Cflags: -I\$(includedir)/cava -I\$(includedir)/cava/input -I\$(includedir)/cava/output" >> $@
24+
25+
# Clean up the generated pkgconfig file
26+
CLEANFILES += libcava.pc
27+
28+
# Define the library to be built
29+
# 'lib' directory implies shared library by default with Automake.
30+
# Use 'noinst_LTLIBRARIES' if you don't want to install it but build it for internal use.
31+
lib_LTLIBRARIES = libcava.la
32+
33+
AM_LIBTOOL_VERSION = $(AM_LIBTOOL_CURRENT):$(AM_LIBTOOL_REVISION):$(AM_LIBTOOL_RELEASE)
34+
AM_LIBTOOL_REL = $(AM_LIBTOOL_RELEASE):$(AM_LIBTOOL_REVISION):$(AM_LIBTOOL_CURRENT)
35+
36+
libcava_la_LDFLAGS = -version-info $(AM_LIBTOOL_REL)
37+
538
bin_PROGRAMS = cava
39+
640
cavadir = $(top_srcdir)
7-
cava_SOURCES = cava.c cavacore.c config.c input/common.c input/fifo.c input/shmem.c \
8-
output/terminal_noncurses.c output/raw.c output/noritake.c \
9-
cavacore.h config.h input/common.h input/fifo.h input/shmem.h \
10-
output/terminal_noncurses.h output/raw.h output/noritake.h \
11-
util.h third_party/incbin.h
12-
cava_CPPFLAGS = -DPACKAGE=\"$(PACKAGE)\" -DVERSION=\"$(VERSION)\" \
13-
-D_POSIX_SOURCE -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE_EXTENDED \
14-
-DFONTDIR=\"@FONT_DIR@\" -DFONTFILE=\"@FONT_FILE@\"
41+
cava_SOURCES = cava.c
42+
libcava_la_SOURCES = cavacore.c config.c input/common.c input/fifo.c input/shmem.c \
43+
output/common.c output/terminal_noncurses.c output/raw.c output/noritake.c
44+
45+
cava_CPPFLAGS = \
46+
-DPACKAGE=\"$(PACKAGE)\" \
47+
-DVERSION=\"$(VERSION)\" \
48+
-DLIB_VERSION=\"$(VERSION)\" \
49+
-D_POSIX_SOURCE \
50+
-D_POSIX_C_SOURCE=200809L \
51+
-D_XOPEN_SOURCE_EXTENDED \
52+
-DFONTDIR=\"@FONT_DIR@\" \
53+
-DFONTFILE=\"@FONT_FILE@\" \
54+
-I$(srcdir) \
55+
-I$(srcfir)/input \
56+
-I$(srcfir)/output \
57+
-I$(srcdir)/include
58+
59+
AM_CFLAGS = $(cava_CPPFLAGS)
60+
1561
cava_CFLAGS = -std=c99 -Wall -Wextra -Wno-unused-result -Wno-unknown-warning-option -Wno-maybe-uninitialized -Wno-vla-parameter
1662

1763
EXTRA_DIST = \
64+
include \
1865
output/shaders/pass_through.vert \
1966
output/shaders/bar_spectrum.frag \
2067
output/shaders/northern_lights.frag \
@@ -31,6 +78,19 @@ EXTRA_DIST = \
3178
.clang-format \
3279
CMakeLists.txt
3380

81+
# Install entire directories preserving structure
82+
dist-hook:
83+
cp -r include/cava $(DESTDIR)$(includedir)
84+
# Define the target to install the headers
85+
install-exec-hook:
86+
@$(MKDIR_P) $(DESTDIR)$(includedir)/cava
87+
# Install entire directories preserving structure
88+
install-data-hook:
89+
cp -r include/cava/* $(DESTDIR)$(includedir)/cava/
90+
# Define uninstall hook to remove the directory
91+
uninstall-hook:
92+
$(AM_V_GEN) rm -rf "$(DESTDIR)$(includedir)/cava"
93+
3494
if OSX
3595
cava_CFLAGS += -DNORT
3696
cava_LDADD =
@@ -42,7 +102,7 @@ endif
42102

43103
if FREEBSD
44104
if CAVAFONT
45-
CLEANFILES = cava.bdf cava.fnt
105+
CLEANFILES += cava.bdf cava.fnt
46106

47107
cava.fnt: ${srcdir}/cava.psf
48108
${PSF2BDF} --fontname="-gnu-cava-medium-r-normal--16-160-75-75-c-80-iso10646-1" ${srcdir}/cava.psf cava.bdf
@@ -51,43 +111,45 @@ endif
51111
endif
52112

53113
if ALSA
54-
cava_SOURCES += input/alsa.c input/alsa.h
114+
libcava_la_SOURCES += input/alsa.c input/alsa.h
55115
endif
56116

57117
if PORTAUDIO
58-
cava_SOURCES += input/portaudio.c input/portaudio.h
118+
libcava_la_SOURCES += input/portaudio.c input/portaudio.h
59119
endif
60120

61121
if PIPEWIRE
62-
cava_SOURCES += input/pipewire.c input/pipewire.h
122+
libcava_la_SOURCES += input/pipewire.c input/pipewire.h
63123
endif
64124

65125
if PULSE
66-
cava_SOURCES += input/pulse.c input/pulse.h
126+
libcava_la_SOURCES += input/pulse.c input/pulse.h
67127
endif
68128

69129
if SNDIO
70-
cava_SOURCES += input/sndio.c input/sndio.h
130+
libcava_la_SOURCES += input/sndio.c input/sndio.h
71131
endif
72132

73133
if OSS
74-
cava_SOURCES += input/oss.c input/oss.h
134+
libcava_la_SOURCES += input/oss.c input/oss.h
75135
endif
76136

77137
if JACK
78-
cava_SOURCES += input/jack.c input/jack.h
138+
libcava_la_SOURCES += input/jack.c input/jack.h
79139
endif
80140

81141
if NCURSES
82-
cava_SOURCES += output/terminal_ncurses.c output/terminal_bcircle.c \
142+
libcava_la_SOURCES += output/terminal_ncurses.c output/terminal_bcircle.c \
83143
output/terminal_ncurses.h output/terminal_bcircle.h
84144

85145
endif
86146

87147
if SDL
88-
cava_SOURCES += output/sdl_cava.c output/sdl_cava.h
148+
libcava_la_SOURCES += output/sdl_cava.c output/sdl_cava.h
89149
endif
90150

91151
if SDL_GLSL
92-
cava_SOURCES += output/sdl_glsl.c output/sdl_glsl.h
152+
libcava_la_SOURCES += output/sdl_glsl.c output/sdl_glsl.h
93153
endif
154+
155+
cava_SOURCES += $(libcava_la_SOURCES)

0 commit comments

Comments
 (0)