Skip to content

Commit

Permalink
Get Makefile working with both C and C++ compilers
Browse files Browse the repository at this point in the history
We need HAVE_STPCPY defined to avoid duplicating it.

We shouldn't depend on CPPFLAGS if building with gcc.
It may be necessary to build with a C++ compiler when using portaudio
or integrating into a C++ project. Now it builds either way.
  • Loading branch information
ec1oud committed Oct 7, 2024
1 parent 50ee0c0 commit 029e3d1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ FFT_OBJ = $(patsubst %.c,$(BUILD_DIR)/%.o,$(FFT_SRC))

TARGETS = gen_ft8 decode_ft8 test_ft8

CFLAGS = -fsanitize=address -O3 -ggdb3
CPPFLAGS = -std=c11 -I.
CFLAGS = -fsanitize=address -O3 -ggdb3 -DHAVE_STPCPY -I.
LDFLAGS = -fsanitize=address -lm

# Optionally, use Portaudio for live audio input
# Portaudio is a C++ library, so then you need to build with clang++ or g++:
# it's up to you to set CC accordingly!
# Then -std=c11 is useful.
ifdef PORTAUDIO_PREFIX
CPPFLAGS += -DUSE_PORTAUDIO -I$(PORTAUDIO_PREFIX)/include
CFLAGS += -std=c11 -DUSE_PORTAUDIO -I$(PORTAUDIO_PREFIX)/include
LDFLAGS += -lportaudio -L$(PORTAUDIO_PREFIX)/lib
endif

Expand Down Expand Up @@ -46,4 +48,4 @@ test_ft8: $(BUILD_DIR)/test/test.o $(FT8_OBJ)

$(BUILD_DIR)/%.o: %.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $^
$(CC) $(CFLAGS) -o $@ -c $^

0 comments on commit 029e3d1

Please sign in to comment.