From: Jérôme Benoit Date: Tue, 7 Mar 2017 19:27:44 +0000 (+0100) Subject: TP11 exo2: Makefile: Add a static binary target and some cleanups X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=5553a759119a264f4e395f5a269230d60e5ced93;p=TD_C.git TP11 exo2: Makefile: Add a static binary target and some cleanups Signed-off-by: Jérôme Benoit --- diff --git a/TP_11/exo2/Makefile b/TP_11/exo2/Makefile index 50191de..c986981 100644 --- a/TP_11/exo2/Makefile +++ b/TP_11/exo2/Makefile @@ -21,7 +21,7 @@ BUILD_TYPE=debug # 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 @@ -46,6 +46,7 @@ endif 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)) @@ -72,6 +73,10 @@ $(BINARY_NAME): $(OBJS) @$(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 $@ @@ -95,10 +100,11 @@ clean: @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