diff options
author | Simponic <loganhunt@simponic.xyz> | 2021-12-04 13:34:49 -0700 |
---|---|---|
committer | Simponic <loganhunt@simponic.xyz> | 2021-12-04 13:34:49 -0700 |
commit | aa1d7c6e284cc0818325614391619f3ff13d3e94 (patch) | |
tree | 8a59a6b3e5aacb7f682756d3c7751f1d72e1d940 /openmp/Makefile | |
download | gol-aa1d7c6e284cc0818325614391619f3ff13d3e94.tar.gz gol-aa1d7c6e284cc0818325614391619f3ff13d3e94.zip |
Initial commit
Diffstat (limited to 'openmp/Makefile')
-rw-r--r-- | openmp/Makefile | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/openmp/Makefile b/openmp/Makefile new file mode 100644 index 0000000..8fefe22 --- /dev/null +++ b/openmp/Makefile @@ -0,0 +1,57 @@ +# This is some Makefile I've been using for projects for a while and can't find +# where I originally got it + +CC ?= gcc + +SRC_PATH = src +BUILD_PATH = build +BIN_PATH = $(BUILD_PATH)/bin + +BIN_NAME = gol + +SRC_EXT = c + +SOURCES = $(shell find $(SRC_PATH) -name '*.$(SRC_EXT)' | sort -k 1nr | cut -f2-) +OBJECTS = $(SOURCES:$(SRC_PATH)/%.$(SRC_EXT)=$(BUILD_PATH)/%.o) +DEPS = $(OBJECTS:.o=.d) + +COMPILE_FLAGS = -Wall -g -fopenmp -lm -std=c99 +INCLUDES = -I include/ +LIBS = -fopenmp -lm + +.PHONY: default_target +default_target: release + +.PHONY: release +release: dirs + @$(MAKE) all + +.PHONY: dirs +dirs: + @echo "Creating directories" + @mkdir -p $(dir $(OBJECTS)) + @mkdir -p $(BIN_PATH) + +.PHONY: clean +clean: + @echo "Deleting $(BIN_NAME) symlink" + @$(RM) $(BIN_NAME) + @echo "Deleting directories" + @$(RM) -r $(BUILD_PATH) + @$(RM) -r $(BIN_PATH) + +.PHONY: all +all: $(BIN_PATH)/$(BIN_NAME) + @echo "Making symlink: $(BIN_NAME) -> $<" + @$(RM) $(BIN_NAME) + @ln -s $(BIN_PATH)/$(BIN_NAME) $(BIN_NAME) + +$(BIN_PATH)/$(BIN_NAME): $(OBJECTS) + @echo "Linking: $@" + $(CC) $(OBJECTS) -o $@ ${LIBS} + +-include $(DEPS) + +$(BUILD_PATH)/%.o: $(SRC_PATH)/%.$(SRC_EXT) + @echo "Compiling: $< -> $@" + $(CC) $(COMPILE_FLAGS) $(INCLUDES) -MP -MMD -c $< -o $@ |