Makefile BSD support

This commit is contained in:
igor725 2019-04-06 10:44:53 +03:00
parent ca5e99f758
commit d546009254

View File

@ -2,24 +2,14 @@ SOURCES=$(wildcard *.c)
OBJECTS=$(patsubst %.c, %.o, $(SOURCES))
COMMITSHA=$(shell git rev-parse --short HEAD)
ENAME=ClassiCube
PLAT=ns
DEL=rm
JOBS=1
ifeq ($(PLAT),ns)
ifndef $(PLAT)
ifeq ($(OS),Windows_NT)
PLAT=mingw
else
UNAME=$(shell uname -s)
ifeq ($(UNAME),Linux)
PLAT=linux
endif
ifeq ($(UNAME),Darwin)
PLAT=osx
endif
ifeq ($(UNAME),SunOS)
PLAT=solaris
endif
PLAT=$(shell uname -s | tr -s '[:upper:]' '[:lower:]')
endif
endif
@ -37,14 +27,31 @@ CC_linux=gcc
LIBS_linux=-lX11 -lpthread -lGL -lm -lopenal -ldl -lcurl
CFLAGS_linux=-w -g -pipe
CC_solaris=gcc
LIBS_solaris=-lm -lsocket -lX11 -lGL -lcurl -lopenal
CFLAGS_solaris=-w -g -pipe
CC_sunos=gcc
LIBS_sunos=-lm -lsocket -lX11 -lGL -lcurl -lopenal
CFLAGS_sunos=-w -g -pipe
CC_osx=gcc
LIBS_osx=-lcurl
LDFLAGS_osx=-framework Carbon -framework AGL -framework OpenAL -framework OpenGL
CFLAGS_osx=-w -g -pipe
CC_darwin=gcc
LIBS_darwin=-lcurl
LDFLAGS_darwin=-framework Carbon -framework AGL -framework OpenAL -framework OpenGL
CFLAGS_darwin=-w -g -pipe
BSDLIBS=-lcurl -lexecinfo -lopenal -lGL -lX11
CC_freebsd=gcc
LIBS_freebsd=$(BSDLIBS) -lm -lpthread
INCDIRS_freebsd=-I /usr/local/include -L /usr/Xlocal/lib
CFLAGS_freebsd=-w -g -pipe
CC_openbsd=gcc
LIBS_openbsd=$(BSDLIBS)
INCDIRS_openbsd=-isystem /usr/X11R6/include -isystem /usr/local/include
LDFLAGS_openbsd=-L /usr/X11R6/lib -L /usr/local/lib
CC_netbsd=gcc
LIBS_netbsd=$(BSDLIBS)
INCDIRS_netbsd=-I /usr/X11R7/include -I /usr/pkg/include
LDFLAGS_netbsd=-L /usr/X11R7/lib -L /usr/pkg/lib
ifeq ($(OS),Windows_NT)
DEL=del
@ -62,25 +69,32 @@ mingw:
$(MAKE) $(ENAME) PLAT=mingw -j$(JOBS)
solaris:
$(MAKE) $(ENAME) PLAT=solaris -j$(JOBS)
$(MAKE) $(ENAME) PLAT=sunos -j$(JOBS)
osx:
$(MAKE) $(ENAME) PLAT=osx -j$(JOBS)
$(MAKE) $(ENAME) PLAT=darwin -j$(JOBS)
freebsd:
$(MAKE) $(ENAME) PLAT=freebsd -j$(JOBS)
openbsd:
$(MAKE) $(ENAME) PLAT=openbsd -j$(JOBS)
netbsd:
$(MAKE) $(ENAME) PLAT=netbsd -j$(JOBS)
clean:
$(DEL) $(OBJECTS)
ns:
$(error Target platform not selected)
CC=$(CC_$(PLAT))
LIBS=$(LIBS_$(PLAT))
OEXT=$(OEXT_$(PLAT))
CFLAGS=$(CFLAGS_$(PLAT))
LDFLAGS=$(LDFLAGS_$(PLAT))
INCDIRS=$(INCDIRS_$(PLAT))
$(ENAME): $(OBJECTS)
$(CC) $(LDFLAGS) -o $@$(OEXT) $(OBJECTS) $(LIBS)
$(OBJECTS): %.o : %.c
$(CC) $(CFLAGS) -DCC_COMMIT_SHA=\"$(COMMITSHA)\" -c $< $(LIBS) -o $@
$(CC) $(CFLAGS) $(INCDIRS) -DCC_COMMIT_SHA=\"$(COMMITSHA)\" -c $< -o $@