Subversion Repositories Kolibri OS

Rev

Rev 5496 | Rev 7475 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. # GNU Makefile
  2.  
  3. OUT := build
  4. GEN := generated
  5.  
  6. # --- Variables, Commands, etc... ---
  7.  
  8. default: all
  9. LDFLAGS = -Tinclude/scripts/menuetos_app_v01.ld -nostdlib -L include/lib
  10. CFLAGS += -Ifitz -Ipdf -Ixps -Iscripts  -fno-stack-protector -nostdinc -fno-builtin -m32 -I include -fno-pic
  11. LIBS += -lfreetype2 -lpng -ljbig2dec -ljpeg -lopenjpeg -lz -lm -lc
  12.  
  13. #include Makerules
  14. #include Makethird
  15.  
  16. THIRD_LIBS := $(FREETYPE_LIB)
  17. THIRD_LIBS += $(JBIG2DEC_LIB)
  18. THIRD_LIBS += $(JPEG_LIB)
  19. THIRD_LIBS += $(OPENJPEG_LIB)
  20. THIRD_LIBS += $(ZLIB_LIB)
  21.  
  22. ifeq "$(verbose)" ""
  23. QUIET_AR = @ echo ' ' ' ' AR $@ ;
  24. QUIET_CC = @ echo ' ' ' ' CC $@ ;
  25. QUIET_GEN = @ echo ' ' ' ' GEN $@ ;
  26. QUIET_LINK = @ echo ' ' ' ' LINK $@ ;
  27. QUIET_MKDIR = @ echo ' ' ' ' MKDIR $@ ;
  28. endif
  29.  
  30. CC_CMD = $(QUIET_CC) $(CC) $(CFLAGS) -o $@ -c $<
  31. AR_CMD = $(QUIET_AR) $(AR) cru $@ $^
  32. LINK_CMD = $(QUIET_LINK) ld $(LDFLAGS) -o $@ include/stub/crt0.o $^ build/snprintf.o $(LIBS)
  33. MKDIR_CMD = $(QUIET_MKDIR) mkdir -p $@
  34.  
  35. # --- Rules ---
  36.  
  37. $(OUT) $(GEN) :
  38.         $(MKDIR_CMD)
  39.  
  40. $(OUT)/%.a :
  41.         $(AR_CMD)
  42.  
  43. $(OUT)/% : $(OUT)/%.o
  44.         $(LINK_CMD)
  45.  
  46. $(OUT)/%.o : fitz/%.c fitz/fitz.h | $(OUT)
  47.         $(CC_CMD)
  48. $(OUT)/%.o : draw/%.c fitz/fitz.h | $(OUT)
  49.         $(CC_CMD)
  50. $(OUT)/%.o : pdf/%.c fitz/fitz.h pdf/mupdf.h | $(OUT)
  51.         $(CC_CMD)
  52. $(OUT)/%.o : xps/%.c fitz/fitz.h xps/muxps.h | $(OUT)
  53.         $(CC_CMD)
  54. $(OUT)/%.o : apps/%.c fitz/fitz.h pdf/mupdf.h xps/muxps.h | $(OUT)
  55.         $(CC_CMD)
  56. $(OUT)/%.o : scripts/%.c | $(OUT)
  57.         $(CC_CMD)
  58.  
  59. .PRECIOUS : $(OUT)/%.o # Keep intermediates from chained rules
  60.  
  61. # --- Fitz, MuPDF and MuXPS libraries ---
  62.  
  63. FITZ_LIB := $(OUT)/libfitz.a
  64. MUPDF_LIB := $(OUT)/libmupdf.a
  65. MUXPS_LIB := $(OUT)/libmuxps.a
  66.  
  67. FITZ_SRC := $(notdir $(wildcard fitz/*.c draw/*.c))
  68. MUPDF_SRC := $(notdir $(wildcard pdf/*.c))
  69. MUXPS_SRC := $(notdir $(wildcard xps/*.c))
  70.  
  71. $(FITZ_LIB) : $(addprefix $(OUT)/, $(FITZ_SRC:%.c=%.o))
  72. $(MUPDF_LIB) : $(addprefix $(OUT)/, $(MUPDF_SRC:%.c=%.o))
  73. $(MUXPS_LIB) : $(addprefix $(OUT)/, $(MUXPS_SRC:%.c=%.o))
  74.  
  75. libs: $(MUXPS_LIB) $(MUPDF_LIB) $(FITZ_LIB) $(THIRD_LIBS)
  76.         @ echo MuPDF/XPS and underlying libraries built
  77.  
  78. # --- Generated CMAP and FONT files ---
  79.  
  80. CMAPDUMP := scripts/cmapdump
  81. # FONTDUMP := scripts/fontdump
  82.  
  83. CMAP_CNS_SRC := $(wildcard cmaps/cns/*)
  84. CMAP_GB_SRC := $(wildcard cmaps/gb/*)
  85. CMAP_JAPAN_SRC := $(wildcard cmaps/japan/*)
  86. CMAP_KOREA_SRC := $(wildcard cmaps/korea/*)
  87. FONT_BASE14_SRC := $(wildcard fonts/*.cff)
  88. FONT_DROID_SRC := fonts/droid/DroidSans.ttf fonts/droid/DroidSansMono.ttf
  89. FONT_CJK_SRC := fonts/droid/DroidSansFallback.ttf
  90.  
  91. $(GEN)/cmap_cns.h : $(CMAP_CNS_SRC)
  92.         $(QUIET_GEN) ./$(CMAPDUMP) $@ $(CMAP_CNS_SRC)
  93. $(GEN)/cmap_gb.h : $(CMAP_GB_SRC)
  94.         $(QUIET_GEN) ./$(CMAPDUMP) $@ $(CMAP_GB_SRC)
  95. $(GEN)/cmap_japan.h : $(CMAP_JAPAN_SRC)
  96.         $(QUIET_GEN) ./$(CMAPDUMP) $@ $(CMAP_JAPAN_SRC)
  97. $(GEN)/cmap_korea.h : $(CMAP_KOREA_SRC)
  98.         $(QUIET_GEN) ./$(CMAPDUMP) $@ $(CMAP_KOREA_SRC)
  99.  
  100. $(GEN)/font_base14.h : $(FONT_BASE14_SRC)
  101.         $(QUIET_GEN) ./$(FONTDUMP) $@ $(FONT_BASE14_SRC)
  102. $(GEN)/font_droid.h : $(FONT_DROID_SRC)
  103.         $(QUIET_GEN) ./$(FONTDUMP) $@ $(FONT_DROID_SRC)
  104. $(GEN)/font_cjk.h : $(FONT_CJK_SRC)
  105.         $(QUIET_GEN) ./$(FONTDUMP) $@ $(FONT_CJK_SRC)
  106.  
  107. CMAP_HDR := $(addprefix $(GEN)/, cmap_cns.h cmap_gb.h cmap_japan.h cmap_korea.h)
  108. FONT_HDR := $(GEN)/font_base14.h $(GEN)/font_droid.h $(GEN)/font_cjk.h
  109.  
  110. ifeq "$(CROSSCOMPILE)" ""
  111. $(CMAP_HDR) : $(CMAPDUMP) | $(GEN)
  112. $(FONT_HDR) : $(FONTDUMP) | $(GEN)
  113. endif
  114.  
  115. generate: $(CMAP_HDR) $(FONT_HDR)
  116.  
  117. $(OUT)/pdf_cmap_table.o : $(CMAP_HDR)
  118. $(OUT)/pdf_fontfile.o : $(FONT_HDR)
  119. $(OUT)/cmapdump.o : pdf/pdf_cmap.c pdf/pdf_cmap_parse.c
  120.  
  121. # --- Tools and Apps ---
  122.  
  123. PDF_APPS := $(addprefix $(OUT)/, pdfdraw pdfclean pdfextract pdfinfo pdfshow)
  124. XPS_APPS := $(addprefix $(OUT)/, xpsdraw)
  125.  
  126. $(PDF_APPS) : $(MUPDF_LIB) $(FITZ_LIB) $(THIRD_LIBS)
  127. $(XPS_APPS) : $(MUXPS_LIB) $(FITZ_LIB) $(THIRD_LIBS)
  128.  
  129. MUPDF := $(OUT)/mupdf
  130. $(MUPDF) : $(MUXPS_LIB) $(MUPDF_LIB) $(FITZ_LIB) $(THIRD_LIBS)
  131. ifeq "$(NOX11)" ""
  132. $(MUPDF) : $(addprefix $(OUT)/, kos_main.o pdfapp.o)
  133.         $(LINK_CMD)
  134. endif
  135.  
  136. # --- Install ---
  137.  
  138. prefix ?= /usr/local
  139. bindir ?= $(prefix)/bin
  140. libdir ?= $(prefix)/lib
  141. incdir ?= $(prefix)/include
  142. mandir ?= $(prefix)/share/man
  143.  
  144. install: $(MUXPS_LIB) $(MUPDF_LIB) $(FITZ_LIB) $(PDF_APPS) $(XPS_APPS) $(MUPDF)
  145.         install -d $(bindir) $(libdir) $(incdir) $(mandir)/man1
  146.         install $(MUXPS_LIB) $(MUPDF_LIB) $(FITZ_LIB) $(libdir)
  147.         install fitz/fitz.h pdf/mupdf.h xps/muxps.h $(incdir)
  148.         install $(PDF_APPS) $(XPS_APPS) $(MUPDF) $(bindir)
  149.         install $(wildcard apps/man/*.1) $(mandir)/man1
  150.  
  151. # --- Clean and Default ---
  152.  
  153. all: $(THIRD_LIBS) $(FITZ_LIB) $(PDF_APPS) $(XPS_APPS) $(MUPDF)
  154.  
  155. clean:
  156.         rm -rf $(OUT)
  157. nuke:
  158.         rm -rf build/* $(GEN)
  159.  
  160. .PHONY: all clean nuke install
  161.