mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 23:04:08 +10:00
Toy now fits into the C spec. Fixed #158 Addendum: MacOS test caught an error: error: a function declaration without a prototype is deprecated in all versions of C That took 3 attempts to fix correctly. Addendum: 'No new line at the end of file' are you shitting me?
52 lines
1.3 KiB
Makefile
52 lines
1.3 KiB
Makefile
#compiler settings
|
|
CC=gcc
|
|
CFLAGS+=-std=c17 -g -Wall -Werror -Wextra -Wpedantic -Wformat=2
|
|
LIBS+=-lm -lToy
|
|
LDFLAGS+=-Wl,-rpath,'$$ORIGIN'
|
|
|
|
#directories
|
|
REPL_ROOTDIR=..
|
|
REPL_REPLDIR=.
|
|
REPL_SOURCEDIR=$(REPL_ROOTDIR)/source
|
|
|
|
REPL_OUTDIR=$(REPL_ROOTDIR)/out
|
|
REPL_OBJDIR=obj
|
|
|
|
#file names
|
|
REPL_REPLFILES=$(wildcard $(REPL_REPLDIR)/*.c)
|
|
REPL_OBJFILES=$(addprefix $(REPL_OBJDIR)/,$(notdir $(REPL_REPLFILES:.c=.o)))
|
|
REPL_TARGETNAME=repl.exe
|
|
|
|
#linker fix
|
|
LDFLAGS+=-L$(realpath $(REPL_OUTDIR))
|
|
|
|
#build the object files, compile the test cases, and run
|
|
all: build link
|
|
|
|
#targets for each step
|
|
.PHONY: build
|
|
build: $(REPL_OBJDIR) $(REPL_OBJFILES)
|
|
|
|
.PHONY: link
|
|
link: $(REPL_OUTDIR) $(REPL_OUTDIR)/$(REPL_TARGETNAME)
|
|
|
|
#util targets
|
|
$(REPL_OUTDIR):
|
|
mkdir $(REPL_OUTDIR)
|
|
|
|
$(REPL_OBJDIR):
|
|
mkdir $(REPL_OBJDIR)
|
|
|
|
#compilation steps
|
|
$(REPL_OBJDIR)/%.o: $(REPL_REPLDIR)/%.c
|
|
$(CC) -c -o $@ $< $(addprefix -I,$(REPL_REPLDIR)) $(addprefix -I,$(REPL_SOURCEDIR)) $(CFLAGS)
|
|
|
|
$(REPL_OUTDIR)/$(REPL_TARGETNAME): $(REPL_OBJFILES)
|
|
$(CC) -DTOY_IMPORT $(CFLAGS) -o $@ $(REPL_OBJFILES) $(LDFLAGS) $(LIBS)
|
|
ifeq ($(shell uname),Darwin) #dylib fix
|
|
otool -L $@
|
|
install_name_tool -add_rpath @executable_path/. $@
|
|
install_name_tool -change $(REPL_OUTDIR)/libToy.dylib @executable_path/libToy.dylib $@
|
|
otool -L $@
|
|
endif
|