diff --git a/makefile b/makefile index 5dd4732..ebcf371 100644 --- a/makefile +++ b/makefile @@ -1,24 +1,24 @@ -export OUTDIR = out +export TOY_OUTDIR = out -all: $(OUTDIR) repl +all: $(TOY_OUTDIR) repl -repl: $(OUTDIR) library +repl: $(TOY_OUTDIR) library $(MAKE) -C repl -repl-static: $(OUTDIR) static +repl-static: $(TOY_OUTDIR) static $(MAKE) -C repl -library: $(OUTDIR) +library: $(TOY_OUTDIR) $(MAKE) -C source library -static: $(OUTDIR) +static: $(TOY_OUTDIR) $(MAKE) -C source static -test: clean $(OUTDIR) +test: clean $(TOY_OUTDIR) $(MAKE) -C test -$(OUTDIR): - mkdir $(OUTDIR) +$(TOY_OUTDIR): + mkdir $(TOY_OUTDIR) .PHONY: clean diff --git a/repl/makefile b/repl/makefile index e6030e8..3bd4970 100644 --- a/repl/makefile +++ b/repl/makefile @@ -8,10 +8,10 @@ ODIR = obj SRC = $(wildcard *.c) OBJ = $(addprefix $(ODIR)/,$(SRC:.c=.o)) -OUT=../$(OUTDIR)/toyrepl +OUT=../$(TOY_OUTDIR)/toyrepl all: $(OBJ) - $(CC) -DTOY_IMPORT $(CFLAGS) -o $(OUT) $(OBJ) -L$(realpath $(shell pwd)/../$(OUTDIR)) $(LIBS) + $(CC) -DTOY_IMPORT $(CFLAGS) -o $(OUT) $(OBJ) -L$(realpath $(shell pwd)/../$(TOY_OUTDIR)) $(LIBS) $(OBJ): | $(ODIR) diff --git a/source/makefile b/source/makefile index 2eec327..8276fae 100644 --- a/source/makefile +++ b/source/makefile @@ -11,16 +11,16 @@ OBJ = $(addprefix $(ODIR)/,$(SRC:.c=.o)) OUTNAME=toy ifeq ($(findstring CYGWIN, $(shell uname)),CYGWIN) - LIBLINE =-Wl,--out-implib=../$(OUTDIR)/lib$(OUTNAME).dll.a -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--whole-archive $(OBJ) -Wl,--no-whole-archive - OUT=../$(OUTDIR)/$(OUTNAME).dll + LIBLINE =-Wl,--out-implib=../$(TOY_OUTDIR)/lib$(OUTNAME).dll.a -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--whole-archive $(OBJ) -Wl,--no-whole-archive + OUT=../$(TOY_OUTDIR)/$(OUTNAME).dll else ifeq ($(shell uname),Linux) #I can't get this working as a shared lib - LIBLINE=-Wl,--out-implib=../$(OUTDIR)/lib$(OUTNAME).a -Wl,--whole-archive $(OBJ) -Wl,--no-whole-archive - OUT=../$(OUTDIR)/$(OUTNAME) + LIBLINE=-Wl,--out-implib=../$(TOY_OUTDIR)/lib$(OUTNAME).a -Wl,--whole-archive $(OBJ) -Wl,--no-whole-archive + OUT=../$(TOY_OUTDIR)/$(OUTNAME) CFLAGS += -fPIC else ifeq ($(OS),Windows_NT) - LIBLINE =-Wl,--out-implib=../$(OUTDIR)/lib$(OUTNAME).dll.a -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--whole-archive $(OBJ) -Wl,--no-whole-archive - OUT=../$(OUTDIR)/$(OUTNAME).dll + LIBLINE =-Wl,--out-implib=../$(TOY_OUTDIR)/lib$(OUTNAME).dll.a -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--whole-archive $(OBJ) -Wl,--no-whole-archive + OUT=../$(TOY_OUTDIR)/$(OUTNAME).dll else @echo "Platform test failed - what platform is this?" exit 1 @@ -30,7 +30,7 @@ library: $(OBJ) $(CC) -DTOY_EXPORT $(CFLAGS) -shared -o $(OUT) $(LIBLINE) static: $(OBJ) - ar crs ../$(OUTDIR)/lib$(OUTNAME).a $(OBJ) + ar crs ../$(TOY_OUTDIR)/lib$(OUTNAME).a $(OBJ) $(OBJ): | $(ODIR) diff --git a/test/makefile b/test/makefile index 3ca95d4..80c0946 100644 --- a/test/makefile +++ b/test/makefile @@ -9,11 +9,11 @@ TARGETS = $(wildcard ../source/*.c) $(filter-out $(wildcard ../repl/*main.c),$(w TESTS = $(wildcard *.c) OBJ = $(addprefix $(ODIR)/,$(TARGETS:../source/%.c=%.o)) $(addprefix $(ODIR)/,$(TESTS:.c=.o)) -.PRECIOUS: $(TESTS:%.c=../$(OUTDIR)/%.exe) +.PRECIOUS: $(TESTS:%.c=../$(TOY_OUTDIR)/%.exe) -all: $(OBJ) $(TESTS:%.c=../$(OUTDIR)/%.exe) +all: $(OBJ) $(TESTS:%.c=../$(TOY_OUTDIR)/%.exe) -../$(OUTDIR)/%.exe: $(ODIR)/%.o +../$(TOY_OUTDIR)/%.exe: $(ODIR)/%.o @$(CC) -o $@ $< $(TARGETS:../source/%.c=$(ODIR)/%.o) $(CFLAGS) $(LIBS) ifeq ($(shell uname),Linux) valgrind --leak-check=full --track-origins=yes $@