hi,
I want to use a single Makefile for three platforms (Linux64, MinGw64, MinGw32) to generate a simple binary (using SDL2).
The source is a single .c file, so use Automake, Autoconf is too heavy.

As now I concentrated the differences only in three variables:
INCPATH
LIBPATH
LDFLAGS
that have minor variations for path reason.



Is there a Makefile trick to take in account differences for those three platforms?


thank you.



INCPATH=/usr/local/include          # Linux64
INCPATH=/mingw64/include            # MinGw64
INCPATH=/mingw32/include            # MinGw32
CC = gcc
CFLAGS = -std=gnu11 -Wall -c -O3 -I$(INCPATH)
LD = $(CC)
LIBPATH=/usr/lib/x86_64-linux-gnu   # Linux64
LIBPATH=/mingw64/lib                # MinGw64
LIBPATH=/mingw32/lib                # MinGw32
SDL_LIB = -L$(LIBPATH) -lSDL2main -lSDL2 -Wl,-rpath=$(LIBPATH)
LDFLAGS = -lmingw32 $(SDL_LIB) -lm  # MinGw32/64
LDFLAGS = $(SDL_LIB) -lm            # Linux64
FILE = spectra
SOURCE = $(FILE)
TARGET = $(FILE)

all: $(TARGET)

$(TARGET): $(SOURCE).o
        $(LD) $< $(LDFLAGS) -o $@

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

clean:
        rm *.o && rm $(TARGET)


--
Valerio


_______________________________________________
Msys2-users mailing list
Msys2-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/msys2-users

Reply via email to