The INCPATH and LIBPATH variables you have defined are probably redundant: gcc should automatically be searching those directories for header files and libraries already. (You can run `gcc -print-search-dirs | grep libraries` to see which directories are searched for libraries. You can run `gcc -E -v test.c` to see where it is searching for header files.)
You can run the pkg-config utility to get the arguments needed to SDL2. For example, try running: pkg-config --cflags --libs sdl2 Here is a shell command I ran to build a single-file SDL2 program I was working on recently: gcc -g -Wall -Wextra -std=c11 -O2 main.c $(pkg-config --cflags --libs sdl2) -o output Since it's just one command, a shell script is fine and you don't really need a Makefile. But the syntax to run pkg-config in your Makefile would be: $(shell pkg-config --cflags --libs sdl2) If you need to depend on more libraries, just add their names onto the end of the pkg-config command. I don't think you need to detect the operating system in your Makefile. It's easy enough to do it with a few #ifdef directives in your source file if you need to. --David On Tue, Mar 12, 2019 at 4:08 AM Valerio Messina via Msys2-users < msys2-users@lists.sourceforge.net> wrote: > 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 >
_______________________________________________ Msys2-users mailing list Msys2-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/msys2-users