Subversion Repositories Kolibri OS

Rev

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

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