Makefile 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. CFLAGS-libos = -L../../../build/libos -I../../include
  2. special_executables = static pie
  3. c_executables = $(filter-out $(special_executables),$(patsubst %.c,%,$(wildcard *.c)))
  4. cxx_executables = $(patsubst %.cpp,%,$(wildcard *.cpp))
  5. target = $(special_executables) $(c_executables) $(cxx_executables) \
  6. manifest static.manifest pal pal_sec
  7. level = ../
  8. include ../Makefile
  9. %.manifest: %.manifest.template
  10. rm -rf $@
  11. cp $@.template $@
  12. ifeq ($(SYS),x86_64-linux-gnu)
  13. $(c_executables): %: %.c
  14. @echo [ $@ ]
  15. @$(CC) $(CFLAGS) $(if $(findstring .libos,$@),$(CFLAGS-libos),) -o $@ $< \
  16. $(shell echo $@ | sed 's/^[^\.]*//g' | sed 's/\./ -l/g')
  17. $(cxx_executables): %: %.cpp
  18. @echo [ $@ ]
  19. @$(CC) $(CFLAGS) -o $@ $< \
  20. $(shell echo $@ | sed 's/^[^\.]*//g' | sed 's/\./ -l/g')
  21. static: %: %.c
  22. @echo [ $@ ]
  23. @$(CC) $(CFLAGS) -o $@ -static $< \
  24. $(shell echo $@ | sed 's/^[^\.]*//g' | sed 's/\./ -l/g')
  25. pie: %: %.c
  26. @echo [ $@ ]
  27. @$(CC) $(CFLAGS) -fPIC --pie -o $@ $< \
  28. $(shell echo $@ | sed 's/^[^\.]*//g' | sed 's/\./ -l/g')
  29. .PHONY: pack
  30. pack: $(special_executables) $(c_executables) $(cxx_executables)
  31. tar -czf .packed/test.tar.gz $^
  32. else
  33. $(special_executables) $(c_executables) $(cxx_executables): .packed/test.tar.gz
  34. tar -xmozf $<
  35. endif