Makefile 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. #
  2. # Makefile - Makefile of fped, the footprint editor
  3. #
  4. # Written 2009-2012, 2015 by Werner Almesberger
  5. # Copyright 2009-2012, 2015 by Werner Almesberger
  6. # Copyright 2016, Erich Heinzle (gEDA additions)
  7. #
  8. # This program is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation; either version 2 of the License, or
  11. # (at your option) any later version.
  12. #
  13. PREFIX ?= /usr/local
  14. UPLOAD = www-data@downloads.qi-hardware.com:werner/fped/
  15. OBJS = fped.o expr.o coord.o obj.o delete.o inst.o util.o error.o \
  16. unparse.o file.o dump.o kicad.o geda.o postscript.o gnuplot.o meas.o \
  17. layer.o overlap.o hole.o tsort.o bitset.o \
  18. cpp.o lex.yy.o y.tab.o \
  19. gui.o gui_util.o gui_style.o gui_inst.o gui_status.o gui_canvas.o \
  20. gui_tool.o gui_over.o gui_meas.o gui_frame.o gui_frame_drag.o
  21. XPMS = point.xpm delete.xpm delete_off.xpm \
  22. vec.xpm frame.xpm \
  23. line.xpm rect.xpm pad.xpm rpad.xpm hole.xpm arc.xpm circ.xpm \
  24. meas.xpm meas_x.xpm meas_y.xpm \
  25. stuff.xpm stuff_off.xpm meas_off.xpm \
  26. bright.xpm bright_off.xpm all.xpm all_off.xpm
  27. PNGS = intro-1.png intro-2.png intro-3.png intro-4.png intro-5.png \
  28. intro-6.png concept-inst.png
  29. SHELL = /bin/bash
  30. CPPFLAGS +=
  31. CFLAGS_GTK = `pkg-config --cflags gtk+-2.0`
  32. LIBS_GTK = `pkg-config --libs gtk+-2.0`
  33. CFLAGS_WARN = -Wall -Wshadow -Wmissing-prototypes \
  34. -Wmissing-declarations -Wno-format-zero-length
  35. CFLAGS += -g -std=gnu99 $(CFLAGS_GTK) -DCPP='"cpp"' \
  36. -DVERSION='"$(GIT_VERSION)$(GIT_STATUS)"' $(CFLAGS_WARN)
  37. SLOPPY = -Wno-unused -Wno-implicit-function-declaration \
  38. -Wno-missing-prototypes -Wno-missing-declarations
  39. LDFLAGS +=
  40. LDLIBS = -lm -lfl $(LIBS_GTK)
  41. YACC = bison -y
  42. YYFLAGS = -v
  43. GIT_VERSION:=$(shell git rev-parse HEAD | cut -c 1-7)
  44. GIT_STATUS:=$(shell [ -z "`git status -s -uno`" ] || echo +)
  45. MKDEP = $(DEPEND) $(1).c | \
  46. sed -e \
  47. '/^\(.*:\)\? */{p;s///;s/ *\\\?$$/ /;s/ */:\n/g;H;}' \
  48. -e '$${g;p;}' -e d >$(1).d; \
  49. [ "$${PIPESTATUS[*]}" = "0 0" ] || { rm -f $(1).d; exit 1; }
  50. # ----- Verbosity control -----------------------------------------------------
  51. CPP := $(CPP) # make sure changing CC won't affect CPP
  52. CC_normal := $(CC)
  53. YACC_normal := $(YACC)
  54. LEX_normal := $(LEX)
  55. DEPEND_normal := $(CPP) $(CFLAGS) -MM -MG
  56. CC_quiet = @echo " CC " $@ && $(CC_normal)
  57. YACC_quiet = @echo " YACC " $@ && $(YACC_normal)
  58. LEX_quiet = @echo " LEX " $@ && $(LEX_normal)
  59. GEN_quiet = @echo " GENERATE " $@ &&
  60. DEPEND_quiet = @$(DEPEND_normal)
  61. ifeq ($(V),1)
  62. CC = $(CC_normal)
  63. LEX = $(LEX_normal)
  64. YACC = $(YACC_normal)
  65. GEN =
  66. DEPEND = $(DEPEND_normal)
  67. else
  68. CC = $(CC_quiet)
  69. LEX = $(LEX_quiet)
  70. YACC = $(YACC_quiet)
  71. GEN = $(GEN_quiet)
  72. DEPEND = $(DEPEND_quiet)
  73. endif
  74. # ----- Rules -----------------------------------------------------------------
  75. .PHONY: all dep depend clean spotless
  76. .PHONY: install uninstall manual upload-manual man manps
  77. .PHONY: montage test tests valgrind
  78. .SUFFIXES: .fig .xpm .ppm
  79. # compile and generate dependencies, based on
  80. # http://scottmcpeak.com/autodepend/autodepend.html
  81. %.o: %.c
  82. $(CC) $(CPPFLAGS) $(CFLAGS) -c $*.c -o $*.o
  83. $(call MKDEP, $*)
  84. # generate 26x26 pixels icons, then drop the 1-pixel frame
  85. .fig.ppm:
  86. $(GEN) fig2dev -L ppm -Z 0.32 -S 4 $< | \
  87. convert -crop 24x24+1+1 - - >$@; \
  88. [ "$${PIPESTATUS[*]}" = "0 0" ] || { rm -f $@; exit 1; }
  89. # ppmtoxpm is very chatty, so we suppress its stderr
  90. .ppm.xpm:
  91. $(GEN) export TMP=_tmp$$$$; ppmcolormask white $< >$$TMP && \
  92. ppmtoxpm -name xpm_`basename $@ .xpm` -alphamask $$TMP \
  93. $< >$@ 2>/dev/null && rm -f $$TMP || \
  94. { rm -f $@ $$TMP; exit 1; }
  95. all: fped
  96. fped: $(OBJS)
  97. $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)
  98. lex.yy.c: fpd.l y.tab.h
  99. $(LEX) fpd.l
  100. lex.yy.o: lex.yy.c y.tab.h
  101. $(CC) -c $(CFLAGS) $(SLOPPY) lex.yy.c
  102. $(call MKDEP, lex.yy)
  103. y.tab.c y.tab.h: fpd.y
  104. $(YACC) $(YYFLAGS) -d fpd.y
  105. y.tab.o: y.tab.c
  106. $(CC) -c $(CFLAGS) $(SLOPPY) y.tab.c
  107. $(call MKDEP, y.tab)
  108. gui_tool.o gui.o: $(XPMS:%=icons/%)
  109. # ----- Upload the GUI manual -------------------------------------------------
  110. manual: $(XPMS:%=icons/%)
  111. for n in $(XPMS:%.xpm=%); do \
  112. convert icons/$$n.xpm manual/$$n.png || exit 1; done
  113. fig2dev -L png -S 4 manual/concept-inst.fig \
  114. >manual/concept-inst.png
  115. upload-manual: manual
  116. scp gui.html README $(UPLOAD)/
  117. scp $(XPMS:%.xpm=manual/%.png) $(PNGS:%=manual/%) \
  118. $(UPLOAD)/manual/
  119. # ---- Format the man page ----------------------------------------------------
  120. man:
  121. # less is for converting overstriking to bold
  122. groff -Tascii -mandoc fped.1 | less
  123. manps:
  124. groff -Tps -mandoc fped.1 | gv -
  125. # ----- Debugging help --------------------------------------------------------
  126. montage:
  127. montage -label %f -frame 3 __dbg????.png png:- | display -
  128. # ----- Dependencies ----------------------------------------------------------
  129. dep depend .depend:
  130. @echo 'no need to run "make depend" anymore' 1>&2
  131. -include $(OBJS:.o=.d)
  132. # ----- Tests -----------------------------------------------------------------
  133. test tests: all
  134. LANG= sh -c \
  135. 'passed=0 && cd test && \
  136. for n in [a-z]*; do \
  137. [ $$n != core ] && SCRIPT=$$n CWD_PREFIX=.. . ./$$n; done; \
  138. echo "Passed all $$passed tests"'
  139. valgrind:
  140. VALGRIND="valgrind -q" $(MAKE) tests
  141. # ----- Cleanup ---------------------------------------------------------------
  142. clean:
  143. rm -f $(OBJS) $(XPMS:%=icons/%) $(XPMS:%.xpm=icons/%.ppm)
  144. rm -f lex.yy.c y.tab.c y.tab.h y.output .depend $(OBJS:.o=.d)
  145. rm -f __dbg????.png _tmp* test/core
  146. spotless: clean
  147. rm -f fped
  148. # ----- Install / uninstall ---------------------------------------------------
  149. install: all
  150. mkdir -p $(DESTDIR)/$(PREFIX)/bin/
  151. install -m 755 fped $(DESTDIR)/$(PREFIX)/bin/
  152. uninstall:
  153. rm -f $(DESTDIR)/$(PREFIX)/bin/fped