Makefile 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #
  2. # Makefile for compiling lgi testsuite support
  3. #
  4. # Author: Pavel Holejsovsky <pavel.holejsovsky@gmail.com>
  5. # License: MIT
  6. #
  7. HOST_OS = $(shell uname -s | tr A-Z a-z)
  8. ifneq ($(filter cygwin% msys% mingw%, $(HOST_OS)),)
  9. EXT = .dll
  10. PFX = cyg
  11. LIBFLAG = -shared
  12. else
  13. ifeq ($(HOST_OS),darwin)
  14. EXT = .so
  15. PFX = lib
  16. LIBFLAG = -bundle -undefined dynamic_lookup
  17. CCSHARED = -fno-common
  18. else
  19. EXT = .so
  20. PFX = lib
  21. LIBFLAG = -shared
  22. CCSHARED = -fPIC
  23. endif
  24. endif
  25. PKGS = gio-2.0 cairo cairo-gobject gobject-introspection-1.0 gmodule-2.0 libffi
  26. LUA = lua
  27. PKG_CONFIG = pkg-config
  28. ifndef CFLAGS
  29. ifndef COPTFLAGS
  30. CFLAGS = -Wall -g
  31. endif
  32. endif
  33. ALL_CFLAGS = $(CCSHARED) $(COPTFLAGS) $(LUA_CFLAGS) $(shell $(PKG_CONFIG) --cflags $(PKGS)) $(CFLAGS) -I .
  34. LIBS += $(shell $(PKG_CONFIG) --libs $(PKGS))
  35. ALL_LDFLAGS = $(LIBFLAG) $(LDFLAGS)
  36. DEPCHECK = .depcheck
  37. # Precondition check
  38. $(DEPCHECK) : Makefile
  39. $(PKG_CONFIG) --exists '$(PKGS) >= 0.10.8' --print-errors
  40. touch $@
  41. REGRESS = $(PFX)regress$(EXT)
  42. REGRESS_OBJS = regress.o
  43. .PHONY : all clean check
  44. all : Regress-1.0.typelib
  45. clean :
  46. rm -f $(REGRESS) $(REGRESS_OBJS) Regress-1.0.gir Regress-1.0.typelib
  47. check : all
  48. cd .. && LD_LIBRARY_PATH=tests:$$LD_LIBRARY_PATH \
  49. GI_TYPELIB_PATH=tests:$$GI_TYPELIB_PATH \
  50. LUA_PATH=./?.lua\;`$(LUA) -e "print(package.path)"` \
  51. LUA_CPATH=./?.so\;`$(LUA) -e "print(package.cpath)"` \
  52. $(LUA) tests/test.lua
  53. $(REGRESS) : regress.o
  54. $(CC) $(ALL_LDFLAGS) -o $@ regress.o $(LIBS)
  55. GIDATADIR = $(shell $(PKG_CONFIG) --variable=gidatadir gobject-introspection-1.0)/tests
  56. regress.o : $(GIDATADIR)/regress.c $(GIDATADIR)/regress.h $(DEPCHECK)
  57. $(CC) $(ALL_CFLAGS) -c -o $@ $<
  58. # Build .gir and .typelib
  59. Regress-1.0.gir : $(REGRESS)
  60. LDFLAGS="" CFLAGS="" \
  61. g-ir-scanner --warn-all --no-libtool --quiet --output=$@ \
  62. --namespace=Regress --nsversion=1.0 \
  63. --include=cairo-1.0 --include=Gio-2.0 \
  64. --library-path=/usr/lib --library-path=/usr/X11R6/lib \
  65. --library-path=/usr/local/lib \
  66. $(GIDATADIR)/regress.c $(GIDATADIR)/regress.h \
  67. -lregress
  68. Regress-1.0.typelib : Regress-1.0.gir
  69. g-ir-compiler --output=$@ $<