diff --git a/Makefile b/Makefile index 4d78226..cb3cf9d 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,7 @@ INC_FLAGS := $(addprefix -I,$(INC_DIRS)) STATIC_LIB := $(LIB_DIR)/libresynthesizer.a +ASSET_DIR := assets EXAMPLE_DIR := examples EXAMPLES := $(EXAMPLE_DIR)/hello $(EXAMPLE_DIR)/ppm $(EXAMPLE_DIR)/painter @@ -41,33 +42,33 @@ $(BUILD_DIR)/%.o: %.c $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ # Build the example executables. -$(EXAMPLE_DIR)/hello: examples/hello.c $(STATIC_LIB) +$(EXAMPLE_DIR)/hello: $(EXAMPLE_DIR)/hello.c $(STATIC_LIB) @echo "\033[1;92mBuilding $@\033[0m" mkdir -p $(dir $@) - $(CC) $(CFLAGS) -o $@ examples/hello.c $(LDFLAGS) $(INC_FLAGS) $(STATIC_LIB) + $(CC) $(CFLAGS) -o $@ $(EXAMPLE_DIR)/hello.c $(LDFLAGS) $(INC_FLAGS) $(STATIC_LIB) -$(EXAMPLE_DIR)/ppm: examples/ppm.c $(STATIC_LIB) +$(EXAMPLE_DIR)/ppm: $(EXAMPLE_DIR)/ppm.c $(STATIC_LIB) @echo "\033[1;92mBuilding $@\033[0m" mkdir -p $(dir $@) - $(CC) $(CFLAGS) -o $@ examples/ppm.c $(LDFLAGS) $(INC_FLAGS) $(STATIC_LIB) + $(CC) $(CFLAGS) -o $@ $(EXAMPLE_DIR)/ppm.c $(LDFLAGS) $(INC_FLAGS) $(STATIC_LIB) -$(EXAMPLE_DIR)/painter: examples/painter.c $(STATIC_LIB) +$(EXAMPLE_DIR)/painter: $(EXAMPLE_DIR)/painter.c $(STATIC_LIB) @echo "\033[1;92mBuilding $@\033[0m" mkdir -p $(dir $@) - $(CC) $(CFLAGS) -o $@ examples/painter.c $(LDFLAGS) $(INC_FLAGS) $(STATIC_LIB) $(shell pkg-config --cflags --libs sdl2) + $(CC) $(CFLAGS) -o $@ $(EXAMPLE_DIR)/painter.c $(LDFLAGS) $(INC_FLAGS) $(STATIC_LIB) $(shell pkg-config --cflags --libs sdl2) # Run the executable(ppm) against the sample images with varying parameters. fuzz: $(EXAMPLE_DIR)/ppm @echo "\033[1;92mFuzzing...\033[0m" - mkdir -p out + mkdir -p $(EXAMPLE_DIR)/output @for number in 0 1 2 3 4 ; do \ for context in 0 1 2 3 4 5 6 7 8 ; do \ for neighbors in 9 64 ; do \ for probes in 64 256 ; do \ - ./examples/ppm \ - assets/source00$${number}.ppm \ - assets/mask00$${number}.ppm \ - out/result00$${number}"_"$${context}"_"$${neighbors}"_"$${probes}.ppm \ + $(EXAMPLE_DIR)/ppm \ + $(ASSET_DIR)/source00$${number}.ppm \ + $(ASSET_DIR)/mask00$${number}.ppm \ + $(EXAMPLE_DIR)/output/result00$${number}"_"$${context}"_"$${neighbors}"_"$${probes}.ppm \ $${context} $${neighbors} $${probes} ; \ done \ done \ @@ -76,10 +77,11 @@ fuzz: $(EXAMPLE_DIR)/ppm test: $(EXAMPLE_DIR)/hello @echo "\033[1;92mTesting...\033[0m" - @if ./examples/hello; then \ + @if $(EXAMPLE_DIR)/hello; then \ echo "\033[1;92mTest Passed!\033[0m"; \ else \ echo "\033[1;91mTest Failed!\033[0m"; \ + exit 1; \ fi .PHONY: clean test all diff --git a/examples/hello.c b/examples/hello.c index 39ec5b7..857cc00 100644 --- a/examples/hello.c +++ b/examples/hello.c @@ -67,5 +67,5 @@ int main() puts(enums[error]); - return EXIT_SUCCESS; + return error == IMAGE_SYNTH_SUCCESS ? EXIT_SUCCESS : EXIT_FAILURE; }