Makefile 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. include ../src/Makefile.Host
  2. CC = gcc
  3. CFLAGS = -Wall -O2 -std=gnu99 -fgnu89-inline -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. pal_loader:
  23. ln -sf ../../Runtime/pal_loader
  24. manifest: manifest.template
  25. cp -f $< $@
  26. %.manifest: %.manifest.template
  27. cp -f $< $@
  28. ifeq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
  29. $(executables): %: %.c $(graphene_lib) $(pal_lib) ../src/user_start.o
  30. @echo [ $@ ]
  31. @$(CC) $(CFLAGS) $(if $(filter Pie,$@),-fPIC -pie,) $^ -o $@
  32. .lib/host_endian.h: ../src/host/$(PAL_HOST)/host_endian.h
  33. @mkdir -p .lib
  34. cp -f $< $@
  35. $(graphene_lib): .lib/host_endian.h
  36. $(MAKE) -C ../lib target=$(abspath .lib)/
  37. else
  38. .IGNORE: $(executables)
  39. $(executables):
  40. endif
  41. .PHONY: clean
  42. clean:
  43. rm -rf pal_loader $(call expand_target,$(target)) .lib *.cached