Jumping Back To SDL2 - Does My Linux Makefile Look OK?

Hi,

I’ve been away from SDL2 for a long time, but am now returning to it.
SDL2.0.8 made it into the new *ubuntu 18.04 LTS(Long Term Support).

I am in the process of updating my Windows®/Linux cross-platform SDL2 2-D game engine.
Was hoping someone could look at my very old Linux makefile?

Makefile is below, please suggest changes as necessary:


TARGET = lf

VERSION = 5.0

DEL_FILE = rm -f

CC = g++
CFLAGS = -pipe -Wall -g #-“ggdb”
SDL_CFLAGS = $(shell sdl2-config --cflags)
SDL_LIBS = $(shell sdl2-config --libs)

SDL_TTF_LIBS = -lSDL2_ttf
SDL_IMAGE_LIBS = -lSDL2_image
SDL_MIXER_LIBS = -lSDL2_mixer

OBJECTS = src/main.o
src/audio.o
src/data.o
src/input.o
src/interface.o
src/logic.o
src/screens.o
src/visuals.o

SOURCES = src/main.cpp
src/audio.cpp
src/data.cpp
src/input.cpp
src/interface.cpp
src/logic.cpp
src/screens.cpp
src/visuals.cpp

HEADERS = src/audio.h
src/data.h
src/input.h
src/interface.h
src/logic.h
src/screens.h
src/visuals.h

$(TARGET): $(OBJECTS)
$(CC) $(OBJECTS) $(SDL_LIBS) $(SDL_TTF_LIBS) $(SDL_IMAGE_LIBS) $(SDL_MIXER_LIBS) -o $@

.cpp.o:
$(CC) $(CFLAGS) $(SDL_CFLAGS) -c $< -o $@

clean:
rm $(OBJECTS) $(TARGET)


Thank you!

Jesse
www.FallenAngelSoftware.com

got a C Makefile here:

For C++ you probably want something likes this:
# c++ source
$(BUILD_DIR)/%.cpp.o: %.cpp
$(MKDIR_P) $(dir $@)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@

stolen from:

Sorry, my knowledge of Linux makefiles is very limited.
Where in my makefile would I put the above 3 lines?
And also do I need it to replace something in the original?
Thanks!

Jesse

Makefiles are read recursively and every line is executed in it’s own subshell.


check this out.

Cheers,
Cass