# DO NOT CHANGE STUFF BEYOND THIS LINE
# ====================================
-all: $(BINARY_NAME) $(BINARY_NAME).dynamic $(BINARY_NAME).staticlocal
+all: $(BINARY_NAME) $(BINARY_NAME).static $(BINARY_NAME).staticlocal $(BINARY_NAME).dynamic
CC=gcc
LD=gcc
CFLAGS := -fPIC $(CFLAGS) $(WARN_FLAGS) $(STD_FLAG) $(OPTI_FLAG) $(DEBUG_FLAG)
LDFLAGS := $(LDFLAGS) $(STRIP_FLAG)
LIBLDFLAGS := -shared $(LDFLAGS)
+STATICLDFLAGS := -static $(LDFLAGS)
OBJDIR := $(BUILDDIR)/objs
$(shell mkdir -p $(OBJDIR))
@$(LD) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@
LOCALLDLIBS=-L. -ltpC
+$(BINARY_NAME).static: $(OBJDIR)/$(BINARY_NAME).o $(LIBRARY_NAME).a
+ @echo "[LD ] $@"
+ @$(LD) $(CFLAGS) $(STATICLDFLAGS) $^ $(LOCALLDLIBS) $(LDLIBS) -o $@
+
$(BINARY_NAME).staticlocal: $(OBJDIR)/$(BINARY_NAME).o $(LIBRARY_NAME).a
@echo "[LD ] $@"
@$(LD) $(CFLAGS) $(LDFLAGS) $^ $(LOCALLDLIBS) $(LDLIBS) -o $@
@echo "[CLN]"
-@rm -r $(BUILDDIR)
-@rm $(BINARY_NAME)
+ -@rm $(BINARY_NAME).static
-@rm $(BINARY_NAME).staticlocal
-@rm $(BINARY_NAME).dynamic
- -@rm $(LIBRARY_NAME).so
-@rm $(LIBRARY_NAME).a
+ -@rm $(LIBRARY_NAME).so
disassemble: $(BINARY_NAME)
objdump -d $< | less