diff options
author | Danny Holman <dholman@gymli.org> | 2024-08-30 01:31:27 -0500 |
---|---|---|
committer | Danny Holman <dholman@gymli.org> | 2024-08-30 01:31:27 -0500 |
commit | 1ce6031a42d22a0f2be566e1873377ab2cda66c8 (patch) | |
tree | e1d38c3458a8202391cd1b017de0ae6bc0661ca7 /Makefile | |
parent | 6b13ea53aeedb646b082a13bf16f67f8556087ae (diff) |
Makefile: retool the build systemv0.55
Retool the build system to be more modular and more flexible. Move all
subsystems into separate directories and create make.config files that
will conditionally compile based on information from the root Makefile.
Signed-off-by: Danny Holman <dholman@gymli.org>
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 72 |
1 files changed, 51 insertions, 21 deletions
@@ -1,46 +1,76 @@ CC?=gcc +LD?=ld INCLUDE?=-Iinclude CFLAGS?=-O0 LDFLAGS?= -RENDER?=render-vulkan -PLATFORM?=linux +LIBS?= +PREFIX?=/usr/local/ + +HEADLESS?=0 +RENDER_API?=vulkan +NETWORK?=1 # -- Do not edit below this line -- -VERSION:="$(shell git describe --abbrev=4 --dirty --always --tags)" +MAJOR:=0 +MINOR:=55 +REV:= +VERSION:="$(MAJOR).$(MINOR)$(REV)" + +LIBRARY:=librune.so.$(MAJOR).$(MINOR) +SONAME:=librune.so.$(MAJOR) +SYMFILE:=librune.sym + +LIBDIR:=$(DESTDIR)$(PREFIX)lib/ +BINDIR:=$(DESTDIR)$(PREFIX)bin/ +INCLUDEDIR:=$(DESTDIR)$(PREFIX)include/rune/ + CC:=$(CC) INCLUDE:=$(INCLUDE) CFLAGS:=$(CFLAGS) $(INCLUDE) -Wall -Wextra -DVERSION=\"$(VERSION)\" -ggdb -fstack-protector-all -fPIC LDFLAGS:=$(LDFLAGS) -shared -COREDIR:=core -RENDERDIR:=$(RENDER) -ENGINE:=librune.so - -include $(COREDIR)/make.config $(RENDERDIR)/make.config +.PHONY: all check clean install +.SUFFIXES: .o .c -LDFLAGS:=$(LDFLAGS) $(RENDER_LDFLAGS) $(CORE_LDFLAGS) -LIBS:=$(LIBS) $(RENDER_LIBS) $(CORE_LIBS) -OBJS:=$(RENDER_OBJS) $(CORE_OBJS) +OBJS:=core/callbacks.o \ + core/init.o \ + core/logging.o \ -.PHONY: all clean install install-headers -.SUFFIXES: .o .c +-include graphics/make.config +-include sound/make.config +-include network/make.config -all: $(ENGINE) +all: $(LIBRARY) -$(ENGINE): $(OBJS) - @$(CC) -o $@ $(LIBS) $(LDFLAGS) $? +$(LIBRARY): $(OBJS) + @$(LD) -soname $(SONAME) -o $@ $(LIBS) $(LDFLAGS) $? @echo [LD] $@ - @objcopy --only-keep-debug $(ENGINE) $(ENGINE:.so=.sym) - @strip -s $(ENGINE) - @objcopy --add-gnu-debuglink=$(ENGINE:.so=.sym) $(ENGINE) - @echo [strip] $(ENGINE) + @objcopy --only-keep-debug $(LIBRARY) $(SYMFILE) + @objcopy --add-gnu-debuglink=$(SYMFILE) $(LIBRARY) + @strip -s $(LIBRARY) + @echo [strip] $(LIBRARY) .c.o: @$(CC) -MD -c $< -o $@ $(CFLAGS) $(INCLUDE) @echo [CC] $@ +check: + clean: - $(RM) $(OBJS) $(OBJS:o=.d) + $(RM) $(OBJS) $(OBJS:.o=.d) $(LIBRARY) $(SYMFILE) tags TAGS + +install: + install -d $(LIBDIR) + install -d $(BINDIR) + install -d $(INCLUDEDIR) + install -d $(INCLUDEDIR)$(RENDER_API) + install -p -m 644 include/rune/*.h $(INCLUDEDIR) + install -p -m 644 include/rune/$(RENDER_API)/*.h $(INCLUDEDIR)$(RENDER_API) + install -p -m 755 $(LIBRARY) $(LIBDIR) + ln -s $(LIBDIR)$(LIBRARY) $(LIBDIR)$(SONAME) + +tags: + ctags -R --kinds-c=+pLl --fields=+S include/ core/ render-vulkan/ -include $(OBJS:.o=.d) |