Skip to content

Commit

Permalink
Add makefile and fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Thealexbarney committed Jan 14, 2018
1 parent 520109f commit 54b469e
Show file tree
Hide file tree
Showing 14 changed files with 1,353 additions and 1,291 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ x86/
bld/
[Bb]in/
[Oo]bj/
[Oo]bj_shared/
[Oo]bj_static/
[Ll]og/

# Visual Studio 2015 cache/options directory
Expand Down
58 changes: 58 additions & 0 deletions C/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
NAME = libatrac9

CC = gcc
AR = ar
SFLAGS = -O2
CFLAGS = -Wall -Wextra -std=c99
LFLAGS =
SHARED_SFLAGS = $(SFLAGS) -flto
SHARED_CFLAGS = $(CFLAGS) -fPIC
SHARED_LFLAGS = $(LFLAGS) -shared

SRCDIR = src
OBJDIR = obj
BINDIR = bin

STATIC_OBJDIR = $(OBJDIR)_static
SHARED_OBJDIR = $(OBJDIR)_shared
SRCS = $(wildcard $(SRCDIR)/*.c)
STATIC_OBJS = $(SRCS:$(SRCDIR)/%.c=$(STATIC_OBJDIR)/%.o)
SHARED_OBJS = $(SRCS:$(SRCDIR)/%.c=$(SHARED_OBJDIR)/%.o)

STATIC_NAME = $(BINDIR)/$(NAME).a
SHARED_NAME = $(BINDIR)/$(NAME).so

MKDIR = mkdir -p
RM = rm -f
RMDIR = rm -df

all: static shared
static: create_static_dir create_bin_dir $(STATIC_NAME)
shared: create_shared_dir create_bin_dir $(SHARED_NAME)

create_static_dir:
@$(MKDIR) $(STATIC_OBJDIR)

create_shared_dir:
@$(MKDIR) $(SHARED_OBJDIR)

create_bin_dir:
@$(MKDIR) $(BINDIR)

$(SHARED_NAME): $(SHARED_OBJS)
$(CC) $(SHARED_OBJS) $(SHARED_SFLAGS) $(SHARED_LFLAGS) -o $@

$(SHARED_OBJS): $(SHARED_OBJDIR)/%.o : $(SRCDIR)/%.c
$(CC) $(SHARED_SFLAGS) $(SHARED_CFLAGS) -c $< -o $@

$(STATIC_NAME): $(STATIC_OBJS)
$(AR) rcs $@ $^

$(STATIC_OBJS): $(STATIC_OBJDIR)/%.o : $(SRCDIR)/%.c
$(CC) $(SFLAGS) $(CFLAGS) -c $< -o $@

clean:
$(RM) $(SHARED_OBJS) $(SHARED_NAME) $(STATIC_OBJS) $(STATIC_NAME)
-@$(RMDIR) $(STATIC_OBJDIR) $(SHARED_OBJDIR) $(BINDIR) 2>/dev/null || true

.PHONY: all static shared create_static_dir create_shared_dir create_bin_dir clean
2 changes: 1 addition & 1 deletion C/src/band_extension.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ void FillHighFrequencies(double* spectra, int groupABin, int groupBBin, int grou
void AddNoiseToSpectrum(channel* channel, int index, int count);

void rng_init(rng_cxt* rng, unsigned short seed);
unsigned short rng_next(rng_cxt* rng);
unsigned short rng_next(rng_cxt* rng);
2 changes: 1 addition & 1 deletion C/src/bit_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ int peek_int(bit_reader_cxt* br, const int bits);
int read_int(bit_reader_cxt* br, const int bits);
int read_signed_int(bit_reader_cxt* br, const int bits);
int read_offset_binary(bit_reader_cxt* br, const int bits);
void align_position(bit_reader_cxt* br, const unsigned int multiple);
void align_position(bit_reader_cxt* br, const unsigned int multiple);
2 changes: 1 addition & 1 deletion C/src/decinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void init_huffman_codebooks()
{
init_huffman_set(HuffmanScaleFactorsUnsigned, sizeof(HuffmanScaleFactorsUnsigned) / sizeof(HuffmanCodebook));
init_huffman_set(HuffmanScaleFactorsSigned, sizeof(HuffmanScaleFactorsSigned) / sizeof(HuffmanCodebook));
init_huffman_set(HuffmanSpectrum, sizeof(HuffmanSpectrum) / sizeof(HuffmanCodebook));
init_huffman_set((HuffmanCodebook*)HuffmanSpectrum, sizeof(HuffmanSpectrum) / sizeof(HuffmanCodebook));
}

void init_huffman_set(const HuffmanCodebook* codebooks, int count)
Expand Down
2 changes: 1 addition & 1 deletion C/src/error_codes.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ typedef enum at9_status
if (status != ERR_SUCCESS) { \
return status; \
} \
} while (0)
} while (0)
Loading

0 comments on commit 54b469e

Please sign in to comment.