diff options
Diffstat (limited to '')
-rw-r--r-- | Makefile | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..724e119 --- /dev/null +++ b/Makefile @@ -0,0 +1,116 @@ +# Makefile for hax's string stuff +# +# Written by: Test_User <hax@andrewyu.org> +# +# This is free and unencumbered software released into the public +# domain. +# +# Anyone is free to copy, modify, publish, use, compile, sell, or +# distribute this software, either in source code form or as a compiled +# binary, for any purpose, commercial or non-commercial, and by any +# means. +# +# In jurisdictions that recognize copyright laws, the author or authors +# of this software dedicate any and all copyright interest in the +# software to the public domain. We make this dedication for the benefit +# of the public at large and to the detriment of our heirs and +# successors. We intend this dedication to be an overt act of +# relinquishment in perpetuity of all present and future rights to this +# software under copyright law. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. + +ORIGINAL_CFLAGS := $(CFLAGS) +ORIGINAL_LDFLAGS := $(LDFLAGS) + +INCLUDEFLAGS = + +LDFLAGS = + +.makeopts: + > .makeopts + printf '%s\n' 'LAST_SAFE_STACK = $(SAFE_STACK)' >> .makeopts + printf '%s\n' 'LAST_CFLAGS = $(ORIGINAL_CFLAGS)' >> .makeopts + printf '%s\n' 'LAST_LDFLAGS = $(ORIGINAL_LDFLAGS)' >> .makeopts + printf '%s\n' 'LAST_CC = $(CC)' >> .makeopts + +$(shell [ -e .makeopts ] || > .makeopts) + +include .makeopts + +rebuild = 0 + +# tabs not allowed :( +ifneq ($(SAFE_STACK),) +ifneq ($(SAFE_STACK),$(LAST_SAFE_STACK)) +rebuild = 1 +endif +else +SAFE_STACK := $(LAST_SAFE_STACK) +endif + +ifneq ($(ORIGINAL_CFLAGS),) +ifneq ($(ORIGINAL_CFLAGS),$(LAST_CFLAGS)) +rebuild = 1 +endif +else +ORIGINAL_CFLAGS := $(LAST_CFLAGS) +CFLAGS += $(LAST_CFLAGS) +endif + +ifneq ($(ORIGINAL_LDFLAGS),) +ifneq ($(ORIGINAL_LDFLAGS),$(LAST_LDFLAGS)) +rebuild = 1 +endif +else +ORIGINAL_LDFLAGS := $(LAST_LDFLAGS) +LDFLAGS += $(LAST_LDFLAGS) +endif + +ifneq ($(CC),) +ifneq ($(CC),$(LAST_CC)) +rebuild = 1 +endif +else +CC := $(LAST_CC) +endif + +ifeq ($(rebuild),1) +.PHONY: .makeopts +endif + +CFLAGS += $(INCLUDEFLAGS) -fPIC -fno-plt -D_REENTRANT -ggdb3 -Wall -Wextra -Wsign-conversion -Wno-unknown-warning-option -Wno-unused-parameter -Wno-implicit-fallthrough -Wno-alloc-size -std=gnu99 + +ifeq ($(SAFE_STACK),1) +CFLAGS += -fstack-check +endif + + + +DEPS = $(shell $(CC) $(CFLAGS) -M -MT $(1).$(2) $(1).c | sed 's_\\$$__') .makeopts Makefile + + +.PHONY: all clean +all: libhax_string_utils.a libhax_string_utils.so + +%.o: %.c + $(CC) $(CFLAGS) -c $< -o $@ + +lib%.so: %.o + $(LD) $(LDFLAGS) -shared $< -o $@ + +lib%.a: %.o + $(AR) rcs $@ $< + +$(call DEPS,hax_string_utils,o) + +clean: + for file in `find . -name '*.so'`; do $(RM) $$file; done + for file in `find . -name '*.o'`; do $(RM) $$file; done + for file in `find . -name '*.a'`; do $(RM) $$file; done |