Makefile 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. include ../src/Makefile.Host
  2. CC = gcc
  3. CFLAGS = -Wall -O2 -std=c11 -fno-builtin -nostdlib \
  4. -I../include/pal -I../lib
  5. .PHONY: default
  6. default: all
  7. include ../src/Makefile.Test
  8. executables = HelloWorld File Failure Thread Fork Event Process Exception \
  9. Memory Pipe Tcp Udp Yield Broadcast Ipc Server Wait HandleSend \
  10. Select Segment Sleep Cpuid Pie
  11. manifests = manifest
  12. target = $(executables) $(manifests)
  13. graphene_lib = .lib/graphene-lib.a
  14. pal_lib = ../../Runtime/libpal-$(PAL_HOST).so
  15. headers = $(wildcard ../include/pal/*.h)
  16. .PHONY: all
  17. all: pal_loader $(call expand_target,$(target))
  18. ifeq ($(DEBUG),1)
  19. CC += -g
  20. endif
  21. export DEBUG
  22. ifeq ($(WERROR),1)
  23. CFLAGS += -Werror
  24. endif
  25. pal_loader:
  26. ln -sf ../../Runtime/pal_loader
  27. manifest: manifest.template
  28. cp -f $< $@
  29. %.manifest: %.manifest.template
  30. cp -f $< $@
  31. ifeq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
  32. $(executables): %: %.c $(graphene_lib) $(pal_lib) ../src/user_start.o
  33. @echo [ $@ ]
  34. @$(CC) $(CFLAGS) $(if $(filter Pie,$@),-fPIC -pie,) $^ -o $@
  35. .lib/host_endian.h: ../src/host/$(PAL_HOST)/host_endian.h
  36. @mkdir -p .lib
  37. cp -f $< $@
  38. $(graphene_lib): .lib/host_endian.h
  39. $(MAKE) -C ../lib target=$(abspath .lib)/
  40. else
  41. .IGNORE: $(executables)
  42. $(executables):
  43. endif
  44. .PHONY: clean
  45. clean:
  46. rm -rf pal_loader $(call expand_target,$(target)) .lib *.cached