| 1 |
|
| 2 |
all: cfdg |
| 3 |
|
| 4 |
|
| 5 |
# |
| 6 |
# Dirs |
| 7 |
# |
| 8 |
|
| 9 |
OBJ_DIR = objs |
| 10 |
|
| 11 |
COMMON_DIR = src-common |
| 12 |
UNIX_DIR = src-unix |
| 13 |
DERIVED_DIR = $(OBJ_DIR) |
| 14 |
AGG_DIR = src-agg |
| 15 |
FFMPEG_DIR = src-ffmpeg |
| 16 |
|
| 17 |
SRC_DIRS = $(COMMON_DIR) $(UNIX_DIR) $(DERIVED_DIR) $(AGG_DIR)/src |
| 18 |
vpath %.cpp $(SRC_DIRS) |
| 19 |
vpath %.cfdg input |
| 20 |
|
| 21 |
INC_DIRS = $(COMMON_DIR) $(UNIX_DIR) $(DERIVED_DIR) $(COMMON_DIR)/agg-extras |
| 22 |
INC_DIRS += /usr/local/include |
| 23 |
|
| 24 |
# |
| 25 |
# Installation directories |
| 26 |
# |
| 27 |
|
| 28 |
prefix = /usr/local |
| 29 |
|
| 30 |
BIN_DIR = $(DESTDIR)$(prefix)/bin |
| 31 |
MAN_DIR = $(DESTDIR)$(prefix)/share/man |
| 32 |
|
| 33 |
# |
| 34 |
# Library directories for FFmpeg and libpng |
| 35 |
# |
| 36 |
|
| 37 |
LIB_DIRS = /usr/local/lib |
| 38 |
|
| 39 |
# |
| 40 |
# Sources and Objects |
| 41 |
# |
| 42 |
|
| 43 |
COMMON_SRCS = cfdg.cpp Rand64.cpp makeCFfilename.cpp \ |
| 44 |
cfdgimpl.cpp renderimpl.cpp builder.cpp shape.cpp \ |
| 45 |
variation.cpp tempfile.cpp commandLineSystem.cpp \ |
| 46 |
aggCanvas.cpp HSBColor.cpp SVGCanvas.cpp rendererAST.cpp \ |
| 47 |
primShape.cpp bounds.cpp shape.cpp shapeSTL.cpp tiledCanvas.cpp \ |
| 48 |
astexpression.cpp astreplacement.cpp pathIterator.cpp \ |
| 49 |
stacktype.cpp CmdInfo.cpp abstractPngCanvas.cpp ast.cpp \ |
| 50 |
prettyint.cpp |
| 51 |
|
| 52 |
UNIX_SRCS = pngCanvas.cpp posixSystem.cpp main.cpp posixTimer.cpp \ |
| 53 |
posixVersion.cpp |
| 54 |
|
| 55 |
DERIVED_SRCS = cfdg.tab.cpp lex.yy.cpp |
| 56 |
|
| 57 |
AGG_SRCS = agg_trans_affine.cpp agg_curves.cpp agg_vcgen_contour.cpp \ |
| 58 |
agg_vcgen_stroke.cpp agg_bezier_arc.cpp agg_color_rgba.cpp |
| 59 |
|
| 60 |
INPUT_SRCS = ciliasun_v2.cfdg demo1_v2.cfdg demo2_v2.cfdg funky_flower_v2.cfdg \ |
| 61 |
i_curves_v2.cfdg i_pix_v2.cfdg i_polygons_v2.cfdg lesson2_v2.cfdg \ |
| 62 |
lesson_v2.cfdg mtree_v2.cfdg octopi_v2.cfdg quadcity_v2.cfdg rose_v2.cfdg \ |
| 63 |
sierpinski_v2.cfdg snowflake_v2.cfdg tangle_v2.cfdg triples_v2.cfdg \ |
| 64 |
underground_v2.cfdg weighting_demo_v2.cfdg welcome_v2.cfdg ziggy_v2.cfdg \ |
| 65 |
ciliasun.cfdg demo1.cfdg demo2.cfdg funky_flower.cfdg i_curves.cfdg \ |
| 66 |
i_pix.cfdg i_polygons.cfdg lesson2.cfdg lesson.cfdg mtree.cfdg \ |
| 67 |
octopi.cfdg quadcity.cfdg rose.cfdg sierpinski.cfdg snowflake.cfdg \ |
| 68 |
tangle.cfdg triples.cfdg underground.cfdg weighting_demo.cfdg \ |
| 69 |
welcome.cfdg ziggy.cfdg |
| 70 |
|
| 71 |
|
| 72 |
LIBS = png m |
| 73 |
|
| 74 |
# Use the first one for clang and the second one for gcc |
| 75 |
ifeq ($(shell uname -s), Darwin) |
| 76 |
LIBS += c++ icucore |
| 77 |
else |
| 78 |
LIBS += stdc++ atomic icui18n icuuc icudata |
| 79 |
endif |
| 80 |
|
| 81 |
# |
| 82 |
# FFmpeg support |
| 83 |
# |
| 84 |
# Uncomment these lines to enable FFmpeg support |
| 85 |
# |
| 86 |
|
| 87 |
# COMMON_SRCS += ffCanvas.cpp |
| 88 |
# LIBS += avformat avcodec swscale swresample avutil z m x264 pthread dl |
| 89 |
|
| 90 |
# |
| 91 |
# Comment out this line to enable FFmpeg support |
| 92 |
# |
| 93 |
|
| 94 |
COMMON_SRCS += ffCanvasDummy.cpp |
| 95 |
|
| 96 |
SRCS = $(DERIVED_SRCS) $(COMMON_SRCS) $(UNIX_SRCS) |
| 97 |
|
| 98 |
# |
| 99 |
# Configuration for local AGG |
| 100 |
# |
| 101 |
#SRCS += $(AGG_SRCS) |
| 102 |
#INC_DIRS += $(AGG_DIR) $(AGG_DIR)/agg2 |
| 103 |
|
| 104 |
|
| 105 |
# |
| 106 |
# Configuration for system AGG |
| 107 |
# |
| 108 |
LIBS += agg |
| 109 |
|
| 110 |
|
| 111 |
OBJS = $(patsubst %.cpp,$(OBJ_DIR)/%.o,$(SRCS)) |
| 112 |
DEPS = $(patsubst %.o,%.d,$(OBJS)) |
| 113 |
|
| 114 |
LINKFLAGS += $(patsubst %,-L%,$(LIB_DIRS)) |
| 115 |
LINKFLAGS += $(patsubst %,-l%,$(LIBS)) |
| 116 |
LINKFLAGS += -fexceptions |
| 117 |
|
| 118 |
deps: $(OBJ_DIR) $(DEPS) |
| 119 |
|
| 120 |
ifneq ($(MAKECMDGOALS),clean) |
| 121 |
ifneq ($(MAKECMDGOALS),distclean) |
| 122 |
ifneq ($(MAKECMDGOALS),src-common/examples.h) |
| 123 |
include $(DEPS) |
| 124 |
endif |
| 125 |
endif |
| 126 |
endif |
| 127 |
|
| 128 |
$(OBJS): $(OBJ_DIR)/Sentry |
| 129 |
|
| 130 |
# |
| 131 |
# Executable |
| 132 |
# |
| 133 |
# Under Cygwin replace strip $@ with strip [email protected] |
| 134 |
|
| 135 |
cfdg: $(OBJS) |
| 136 |
$(LINK.o) $^ $(LINKFLAGS) -o $@ |
| 137 |
|
| 138 |
|
| 139 |
# |
| 140 |
# Derived |
| 141 |
# |
| 142 |
|
| 143 |
$(DERIVED_DIR)/lex.yy.cpp: $(COMMON_DIR)/cfdg.l |
| 144 |
flex -o $@ $^ |
| 145 |
|
| 146 |
$(DERIVED_DIR)/cfdg.tab.hpp: $(DERIVED_DIR)/cfdg.tab.cpp |
| 147 |
$(DERIVED_DIR)/location.hh: $(DERIVED_DIR)/cfdg.tab.cpp |
| 148 |
$(DERIVED_DIR)/cfdg.tab.cpp: $(COMMON_DIR)/cfdg.ypp $(OBJ_DIR)/Sentry |
| 149 |
bison -o $(DERIVED_DIR)/cfdg.tab.cpp $(COMMON_DIR)/cfdg.ypp |
| 150 |
|
| 151 |
$(OBJ_DIR)/lex.yy.o: $(DERIVED_DIR)/cfdg.tab.hpp |
| 152 |
|
| 153 |
src-common/examples.h: $(INPUT_SRCS) |
| 154 |
python3 makeexamples.py $(INPUT_SRCS) > src-common/examples.h |
| 155 |
|
| 156 |
# |
| 157 |
# Utility |
| 158 |
# |
| 159 |
|
| 160 |
.PHONY: clean distclean install uninstall |
| 161 |
clean : |
| 162 |
rm -f $(OBJ_DIR)/* |
| 163 |
rm -f cfdg |
| 164 |
|
| 165 |
distclean: clean |
| 166 |
rmdir $(OBJ_DIR) 2> /dev/null || true |
| 167 |
rm -fr output 2> /dev/null || true |
| 168 |
|
| 169 |
$(OBJ_DIR)/Sentry : |
| 170 |
mkdir -p $(OBJ_DIR) 2> /dev/null || true |
| 171 |
touch $@ |
| 172 |
|
| 173 |
install: cfdg cfdg.1 |
| 174 |
install -d $(BIN_DIR) $(MAN_DIR)/man1 |
| 175 |
install -m 755 cfdg $(BIN_DIR) |
| 176 |
install -m 644 cfdg.1 $(MAN_DIR)/man1 |
| 177 |
|
| 178 |
uninstall: |
| 179 |
-rm -f $(BIN_DIR)/cfdg |
| 180 |
-rm -f $(MAN_DIR)/man1/cfdg.1 |
| 181 |
|
| 182 |
# |
| 183 |
# Tests |
| 184 |
# |
| 185 |
|
| 186 |
.PHONY: test check |
| 187 |
test: cfdg |
| 188 |
./runtests.sh |
| 189 |
|
| 190 |
check: cfdg |
| 191 |
./runtests.sh |
| 192 |
|
| 193 |
# |
| 194 |
# Rules |
| 195 |
# |
| 196 |
|
| 197 |
CXXFLAGS += $(patsubst %,-I%,$(INC_DIRS)) |
| 198 |
CXXFLAGS += -O2 -Wall -Wextra -Wno-parentheses -std=c++17 |
| 199 |
CXXFLAGS += -g -D_GLIBCXX_USE_C99_MATH=1 |
| 200 |
CPPFLAGS += -DNDEBUG |
| 201 |
|
| 202 |
# Add this for clang |
| 203 |
ifeq ($(shell uname -s), Darwin) |
| 204 |
CXXFLAGS += -stdlib=libc++ |
| 205 |
|
| 206 |
# Uncomment this line to enable FFmpeg support on macos |
| 207 |
# LDFLAGS += -framework CoreFoundation -framework CoreVideo -framework CoreMedia -framework VideoToolbox |
| 208 |
endif |
| 209 |
|
| 210 |
$(OBJ_DIR)/%.o : %.cpp |
| 211 |
$(COMPILE.cpp) $(OUTPUT_OPTION) $< |
| 212 |
|
| 213 |
$(OBJ_DIR)/%.d : %.cpp $(OBJ_DIR)/location.hh |
| 214 |
mkdir -p $(OBJ_DIR) 2> /dev/null || true |
| 215 |
set -e; $(COMPILE.cpp) -MM $< \ |
| 216 |
| sed 's,\(.*\.o\)\( *:\),$(OBJ_DIR)/\1 $@\2,g' > $@; \ |
| 217 |
[ -s $@ ] || rm -f $@ |
| 218 |
|
| 219 |
$(OBJ_DIR)/cfdg.tab.d: |
| 220 |
mkdir -p $(OBJ_DIR) 2> /dev/null || true |
| 221 |
|
| 222 |
$(OBJ_DIR)/lex.yy.d: |
| 223 |
mkdir -p $(OBJ_DIR) 2> /dev/null || true |
| 224 |
|