Skip to content

Commit

Permalink
build: relative header includes, dropping -Isrc/compat and -Isrc/common
Browse files Browse the repository at this point in the history
Only the generated config.h and the API headers in src/include should be
located via search path now.


git-svn-id: svn://scm.orgis.org/mpg123/trunk@5386 35dc7657-300d-0410-a2e5-dc2837fedb53
  • Loading branch information
thor committed Dec 6, 2023
1 parent d13cbbf commit f26bfa5
Show file tree
Hide file tree
Showing 111 changed files with 193 additions and 158 deletions.
9 changes: 1 addition & 8 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,7 @@ XFAIL_TESTS =
check_PROGRAMS =

AM_CPPFLAGS = -DPKGLIBDIR="\"$(pkglibdir)\""
# That can be trimmed down later when adapting the sources to
# use relative paths for includes.
# TODO: Actually do more relative includes.
AM_CPPFLAGS += \
$(LTDLINCL) \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/compat \
-I$(top_srcdir)/src/common
AM_CPPFLAGS += $(LTDLINCL)

# Automake cannot handle dependencies behind an autoconf expansion.
# So we need elaborate ifelsery here to make it see the libtool
Expand Down
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
------
- build:
-- Reorganize shared headers, API headers into src/include.
-- Use relative include paths, avoiding internal directories in
CPPFLAGS except for config.h.
-- Group C99 feature checks and make several standard headers
mandatory.
-- Get rid of SIZE_P, OFF_P and friends.
Expand Down
2 changes: 0 additions & 2 deletions ports/cmake/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,6 @@ option(USE_NEW_HUFFTABLE "use new huffman decoding scheme by Taihei (faster on m
include_directories(
"${CMAKE_CURRENT_SOURCE_DIR}/../../../src/"
"${CMAKE_CURRENT_BINARY_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../src/compat"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../src/common"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../src/include")

add_compile_definitions(
Expand Down
42 changes: 42 additions & 0 deletions scripts/fixinc.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/perl

use File::Basename qw(dirname);
use File::Spec::Functions qw(abs2rel);

my @incdirs = ('src/common', 'src/compat', 'src');

sub header
{
my ($from, $inc) = @_;
for(dirname($from), @incdirs)
{
my $cand = "$_/$inc";
return $cand if -e $cand;
}
return undef;
}

for my $f (@ARGV)
{
open(my $ih, '<', $f) or die "meh: $!\n";
open(my $oh, '>', "$f.tmp") or die "moh: $!\n";
while(my $line = <$ih>)
{
if($line =~ m,^(\s*\#\s*include\s+)"([^/]+)\"(.*)$,)
{
my ($pre, $inc, $post) = ($1, $2, $3);
my $h = header($f, $inc);
if($inc ne "config.h" and defined $h)
{
if(dirname($h) ne dirname($f))
{
my $rel = abs2rel($h, dirname($f));
print "$f: including $inc ($rel)\n";
$line = $pre.'"'.$rel.'"'.$post."\n";
}
}
}
print $oh "$line";
}
rename("$f.tmp", $f);
}
2 changes: 1 addition & 1 deletion src/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#include <sys/wait.h>
#endif

#include "debug.h"
#include "common/debug.h"

static syn123_handle *sh = NULL;
static struct mpg123_fmt outfmt = { .encoding=0, .rate=0, .channels=0 };
Expand Down
2 changes: 1 addition & 1 deletion src/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#ifndef _MPG123_AUDIO_H_
#define _MPG123_AUDIO_H_

#include "compat.h"
#include "compat/compat.h"
#include "mpg123.h"
#include "out123.h"

Expand Down
2 changes: 1 addition & 1 deletion src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "terms.h"
#include "metaprint.h"

#include "debug.h"
#include "common/debug.h"

enum player_state playstate = STATE_PLAYING;
const char playsym[STATE_COUNT] = { '>', '_', '=', '?' };
Expand Down
2 changes: 1 addition & 1 deletion src/compat/compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include <shlwapi.h>
#endif

#include "debug.h"
#include "../common/debug.h"

#ifndef WINDOWS_UWP

Expand Down
2 changes: 1 addition & 1 deletion src/compat/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ size_t INT123_unintr_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *st
#define normal mpg123_normal
#endif

#include "true.h"
#include "../common/true.h"

#if (!defined(WIN32) || defined (__CYGWIN__)) && defined(HAVE_SIGNAL_H)
void (*INT123_catchsignal(int signum, void(*handler)(int)))(int);
Expand Down
2 changes: 1 addition & 1 deletion src/compat/compat_dl.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
# endif
#endif

#include "debug.h"
#include "../common/debug.h"

#include "wpathconv.h"

Expand Down
2 changes: 1 addition & 1 deletion src/compat/compat_str.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <locale.h>
#endif

#include "debug.h"
#include "../common/debug.h"

/* A safe realloc also for very old systems where realloc(NULL, size) returns NULL. */
void *INT123_safe_realloc(void *ptr, size_t size)
Expand Down
4 changes: 2 additions & 2 deletions src/control_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#ifndef _BSD_SOURCE
#define _BSD_SOURCE
#endif
#include "compat.h"
#include "compat/compat.h"

#include "mpg123app.h"
#include "out123.h"
Expand Down Expand Up @@ -60,7 +60,7 @@ static int mode = MODE_STOPPED;
static int init = 0;
static int sendstat_disabled = FALSE;

#include "debug.h"
#include "common/debug.h"

void generic_sendmsg (const char *fmt, ...)
{
Expand Down
2 changes: 1 addition & 1 deletion src/equalizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

#include "mpg123app.h"
#include "debug.h"
#include "common/debug.h"

/* Load the settings from the path in the global variable equalfile.
If there is no file, restore equalizer defaults.
Expand Down
2 changes: 1 addition & 1 deletion src/filters.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "filters.h"
#include <ctype.h>

#include "debug.h"
#include "common/debug.h"

// Validate syntax of filter specification, returning the number
// of configured filters.
Expand Down
2 changes: 1 addition & 1 deletion src/filters.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#ifndef MPG123_FILTERS_H
#define MPG123_FILTERS_H

#include "compat.h"
#include "compat/compat.h"

struct filter
{
Expand Down
4 changes: 2 additions & 2 deletions src/getlopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
*/

#include "config.h"
#include "compat.h"
#include "compat/compat.h"
#include "getlopt.h"
#include "debug.h"
#include "common/debug.h"

int loptind = 1; /* index in argv[] */
int loptchr = 0; /* index in argv[loptind] */
Expand Down
4 changes: 2 additions & 2 deletions src/httpget.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
#include "resolver.h"

#include <errno.h>
#include "true.h"
#include "common/true.h"
#endif

#include <ctype.h>

#include "debug.h"
#include "common/debug.h"

void httpdata_init(struct httpdata *e)
{
Expand Down
2 changes: 1 addition & 1 deletion src/libmpg123/calctables.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#define CALCTABLES
#include "mpg123lib_intern.h"
#include "debug.h"
#include "../common/debug.h"

#define ASIZE(a) (sizeof(a)/sizeof(*a))

Expand Down
2 changes: 1 addition & 1 deletion src/libmpg123/dither_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

#include "config.h"
#include "compat.h"
#include "../compat/compat.h"
#include "dither.h"

static const uint32_t init_seed = 2463534242UL;
Expand Down
6 changes: 3 additions & 3 deletions src/libmpg123/format.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
*/

#include "mpg123lib_intern.h"
#include "sample.h"
#include "debug.h"
#include "../common/sample.h"
#include "../common/debug.h"

/* static int chans[NUM_CHANNELS] = { 1 , 2 }; */
static const long my_rates[MPG123_RATES] = /* only the standard rates */
Expand Down Expand Up @@ -686,7 +686,7 @@ static void conv_s16_to_s32(struct outbuffer *buf)
#endif
#endif

#include "swap_bytes_impl.h"
#include "../common/swap_bytes_impl.h"

void swap_endian(struct outbuffer *buf, int block)
{
Expand Down
2 changes: 1 addition & 1 deletion src/libmpg123/frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#define WANT_GETCPUFLAGS
#include "mpg123lib_intern.h"
#include "getcpuflags.h"
#include "debug.h"
#include "../common/debug.h"

static void frame_fixed_reset(mpg123_handle *fr);

Expand Down
2 changes: 1 addition & 1 deletion src/libmpg123/gapless.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
This is no stand-alone header, precisely to be able to fool it into using fake handle types for testing the math.
*/

#include "debug.h"
#include "../common/debug.h"

#ifdef GAPLESS
/* From internal sample number to external. */
Expand Down
2 changes: 1 addition & 1 deletion src/libmpg123/getbits.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#define _MPG123_GETBITS_H_

#include "mpg123lib_intern.h"
#include "debug.h"
#include "../common/debug.h"

#define backbits(fr,nob) ((void)( \
fr->bits_avail += nob, \
Expand Down
2 changes: 1 addition & 1 deletion src/libmpg123/icy.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#ifndef NO_ICY

#include "compat.h"
#include "../compat/compat.h"
#include "mpg123.h"

struct icy_meta
Expand Down
2 changes: 1 addition & 1 deletion src/libmpg123/icy2utf8.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#include "config.h"
/* Includes string and stdlib headers... */
#include "compat.h"
#include "../compat/compat.h"

/* ThOr: too lazy for this type check; also we use char/short all around anyway.
Of cource, it would be the proper way to use _these_ kind of types all around. */
Expand Down
2 changes: 1 addition & 1 deletion src/libmpg123/id3.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@

#include "mpg123lib_intern.h"
#include "id3.h"
#include "debug.h"
#include "../common/debug.h"

#ifndef NO_ID3V2 /* Only the main parsing routine will always be there. */

Expand Down
2 changes: 1 addition & 1 deletion src/libmpg123/index.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

#include "index.h"
#include "debug.h"
#include "../common/debug.h"

/* The next expected frame offset, one step ahead. */
static int64_t fi_next(struct frame_index *fi)
Expand Down
2 changes: 1 addition & 1 deletion src/libmpg123/index.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/

#include "config.h"
#include "compat.h"
#include "../compat/compat.h"

struct frame_index
{
Expand Down
2 changes: 1 addition & 1 deletion src/libmpg123/layer1.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include "mpg123lib_intern.h"
#include "getbits.h"
#include "debug.h"
#include "../common/debug.h"

/*
Allocation value is not allowed to be 15. Initially, libmad showed me the
Expand Down
2 changes: 1 addition & 1 deletion src/libmpg123/layer3.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "huffman.h"
#endif
#include "getbits.h"
#include "debug.h"
#include "../common/debug.h"



Expand Down
8 changes: 4 additions & 4 deletions src/libmpg123/lfs_wrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@
#endif

// For correct MPG123_EXPORT.
#include "abi_align.h"
#include "../common/abi_align.h"

// Need the full header with non-portable API, for the bare mpg123_open*()
// declarations. But no renaming shenanigans.
#define MPG123_NO_LARGENAME
#include "mpg123.h"

#include "lfs_wrap.h"
#include "abi_align.h"
#include "compat.h"
#include "../common/abi_align.h"
#include "../compat/compat.h"
#include <sys/stat.h>
#include <fcntl.h>

Expand All @@ -61,7 +61,7 @@
// A paranoid check that someone did not define a wrong SIZEOF_OFF_T at configure time.
typedef unsigned char MPG123_STATIC_ASSERT[(SIZEOF_OFF_T == sizeof(off_t)) ? 1 : -1];

#include "debug.h"
#include "../common/debug.h"

// We do not want to expose this publicly, but it is cleaner to have it also defined
// as portable API to offer the legacy function wrapper over. It's an undocumented
Expand Down
6 changes: 3 additions & 3 deletions src/libmpg123/libmpg123.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
*/

#include "mpg123lib_intern.h"
#include "version.h"
#include "../version.h"
#include "icy2utf8.h"

#include "gapless.h"
/* Want accurate rounding function regardless of decoder setup. */
#define FORCE_ACCURATE
#include "sample.h"
#include "../common/sample.h"
#include "parse.h"
#ifndef PORTABLE_API
#include "lfs_wrap.h"
#endif

#include "debug.h"
#include "../common/debug.h"

#define SEEKFRAME(mh) ((mh)->ignoreframe < 0 ? 0 : (mh)->ignoreframe)

Expand Down
Loading

0 comments on commit f26bfa5

Please sign in to comment.