Skip to content

Commit d74d571

Browse files
committed
test1
1 parent a7e7312 commit d74d571

File tree

3 files changed

+90
-22
lines changed

3 files changed

+90
-22
lines changed

Makefile.am

Lines changed: 53 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,49 @@ 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+
533
bin_PROGRAMS = cava
634
cavadir = $(top_srcdir)
7-
cava_SOURCES = cava.c cavacore.c config.c input/common.c input/fifo.c input/shmem.c \
35+
cava_SOURCES = cava.c
36+
libcava_la_SOURCES = cavacore.c config.c input/common.c input/fifo.c input/shmem.c \
837
output/common.c output/terminal_noncurses.c output/raw.c output/noritake.c
9-
cava_CPPFLAGS = -DPACKAGE=\"$(PACKAGE)\" -DVERSION=\"$(VERSION)\" \
10-
-D_POSIX_SOURCE -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE_EXTENDED \
11-
-DFONTDIR=\"@FONT_DIR@\" -DFONTFILE=\"@FONT_FILE@\" \
12-
-I$(top_builddir) -I$(top_builddir)/include
38+
cava_CPPFLAGS = \
39+
-DPACKAGE=\"$(PACKAGE)\" \
40+
-DVERSION=\"$(VERSION)\" \
41+
-D_POSIX_SOURCE \
42+
-D_POSIX_C_SOURCE=200809L \
43+
-D_XOPEN_SOURCE_EXTENDED \
44+
-DFONTDIR=\"@FONT_DIR@\" \
45+
-DFONTFILE=\"@FONT_FILE@\" \
46+
-I$(top_builddir) \
47+
-I$(top_builddir)/include
1348
cava_CFLAGS = -std=c99 -Wall -Wextra -Wno-unused-result -Wno-unknown-warning-option -Wno-maybe-uninitialized -Wno-vla-parameter
1449

1550
EXTRA_DIST = \
@@ -51,7 +86,7 @@ endif
5186

5287
if FREEBSD
5388
if CAVAFONT
54-
CLEANFILES = cava.bdf cava.fnt
89+
CLEANFILES += cava.bdf cava.fnt
5590

5691
cava.fnt: ${srcdir}/cava.psf
5792
${PSF2BDF} --fontname="-gnu-cava-medium-r-normal--16-160-75-75-c-80-iso10646-1" ${srcdir}/cava.psf cava.bdf
@@ -60,43 +95,45 @@ endif
6095
endif
6196

6297
if ALSA
63-
cava_SOURCES += input/alsa.c input/alsa.h
98+
libcava_la_SOURCES += input/alsa.c input/alsa.h
6499
endif
65100

66101
if PORTAUDIO
67-
cava_SOURCES += input/portaudio.c input/portaudio.h
102+
libcava_la_SOURCES += input/portaudio.c input/portaudio.h
68103
endif
69104

70105
if PIPEWIRE
71-
cava_SOURCES += input/pipewire.c input/pipewire.h
106+
libcava_la_SOURCES += input/pipewire.c input/pipewire.h
72107
endif
73108

74109
if PULSE
75-
cava_SOURCES += input/pulse.c input/pulse.h
110+
libcava_la_SOURCES += input/pulse.c input/pulse.h
76111
endif
77112

78113
if SNDIO
79-
cava_SOURCES += input/sndio.c input/sndio.h
114+
libcava_la_SOURCES += input/sndio.c input/sndio.h
80115
endif
81116

82117
if OSS
83-
cava_SOURCES += input/oss.c input/oss.h
118+
libcava_la_SOURCES += input/oss.c input/oss.h
84119
endif
85120

86121
if JACK
87-
cava_SOURCES += input/jack.c input/jack.h
122+
libcava_la_SOURCES += input/jack.c input/jack.h
88123
endif
89124

90125
if NCURSES
91-
cava_SOURCES += output/terminal_ncurses.c output/terminal_bcircle.c \
126+
libcava_la_SOURCES += output/terminal_ncurses.c output/terminal_bcircle.c \
92127
output/terminal_ncurses.h output/terminal_bcircle.h
93128

94129
endif
95130

96131
if SDL
97-
cava_SOURCES += output/sdl_cava.c output/sdl_cava.h
132+
libcava_la_SOURCES += output/sdl_cava.c output/sdl_cava.h
98133
endif
99134

100135
if SDL_GLSL
101-
cava_SOURCES += output/sdl_glsl.c output/sdl_glsl.h
136+
libcava_la_SOURCES += output/sdl_glsl.c output/sdl_glsl.h
102137
endif
138+
139+
cava_SOURCES += $(libcava_la_SOURCES)

config.c

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,9 @@ bool validate_config(struct config_params *p, struct error_s *error) {
591591

592592
bool load_config(char configPath[PATH_MAX], struct config_params *p, struct error_s *error) {
593593
free_config(p);
594-
594+
#ifdef _WIN32
595+
p->hFile = NULL;
596+
#endif
595597
FILE *fp;
596598
bool result;
597599
char *cava_config_home = get_cava_config_home(error);
@@ -643,6 +645,33 @@ bool load_config(char configPath[PATH_MAX], struct config_params *p, struct erro
643645
strcpy(configPath, newPath);
644646
}
645647
#endif
648+
// expand env variables in configPath
649+
char *cfgPathOrig = (char *)malloc(PATH_MAX * sizeof(char));
650+
strcpy(cfgPathOrig, configPath);
651+
configPath[0] = '\0';
652+
const char *delimiter = "/";
653+
short int addDelimiter = 0;
654+
char *env = NULL;
655+
656+
if (*cfgPathOrig == *delimiter)
657+
addDelimiter = 1;
658+
659+
for (char *pch = strtok(cfgPathOrig, delimiter); pch != NULL;
660+
pch = strtok(NULL, delimiter)) {
661+
if (addDelimiter == 1)
662+
strcat(configPath, delimiter);
663+
if (*pch == '$')
664+
env = getenv(pch + 1);
665+
if (env && *env) {
666+
strcat(configPath, env);
667+
env = NULL;
668+
} else
669+
strcat(configPath, pch);
670+
addDelimiter = 1;
671+
}
672+
673+
free(cfgPathOrig);
674+
646675
fp = fopen(configPath, "rb");
647676
if (fp) {
648677
fclose(fp);

configure.ac

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -475,12 +475,14 @@ if test -z "$FONT_DIR" ; then
475475
FONT_DIR="$DEFAULT_FONT_DIR"
476476
fi
477477

478+
# --- Define the program name and version for the pkgconfig file ---
479+
PKG_CONFIG_NAME="libcava"
480+
PKG_CONFIG_VERSION="$VERSION"
481+
PKG_CONFIG_DESC="A lightweight, customizable audio visualizer"
478482

483+
AC_SUBST([PKG_CONFIG_NAME])
484+
AC_SUBST([PKG_CONFIG_VERSION])
485+
AC_SUBST([PKG_CONFIG_DESC])
479486

480487
AC_CONFIG_FILES([Makefile])
481488
AC_OUTPUT
482-
483-
484-
485-
486-

0 commit comments

Comments
 (0)