Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. # PIE executable, dynamically loaded shared library, shared glibc
  2. CC=gcc
  3. CPPFLAGS=-U_DEFAULT_SOURCE
  4. SO_CFLAGS=-Wall -Wextra -pedantic -std=c11 -m64 -march=x86-64 -mtune=generic -pipe -O3 -fPIC
  5. CFLAGS=-Wall -Wextra -pedantic -std=c11 -m64 -march=x86-64 -mtune=generic -pipe -O3 -fPIE
  6. SO_LDFLAGS=-fPIC
  7. LDFLAGS=-pie
  8. LIBS=-ldl
  9.  
  10. all: program
  11.  
  12. program: program.o libmodule.so
  13. $(CC) $(LDFLAGS) $< -o $@ $(LIBS)
  14.  
  15. program.o: program.c output.h sum.h
  16. $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
  17.  
  18. libmodule.so: output.o sum.o
  19. $(CC) $(SO_LDFLAGS) -shared -Wl,-soname,$@.1 -o $@.1.0 $^
  20. ln -sf $@.1.0 $@.1
  21. ln -sf $@.1 $@
  22.  
  23. output.o: output.c output.h
  24. $(CC) $(CPPFLAGS) $(SO_CFLAGS) -c $< -o $@
  25.  
  26. sum.o: sum.c sum.h
  27. $(CC) $(CPPFLAGS) $(SO_CFLAGS) -c $< -o $@
  28.  
  29. distclean: clean
  30. $(RM) program libmodule.so.1.0 libmodule.so.1 libmodule.so
  31.  
  32. clean:
  33. $(RM) program.o output.o sum.o
  34.  
  35. .PHONY: all distclean clean
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement