#!/bin/zsh

set -e

# old demos, to ignore
rm -rf GraphicsView_Demo_with_dlls
rm -rf Geomview_Demo_with_dlls
rm -rf Mesh_2_Demo_with_dlls
rm -rf Interpolation_Demo_with_dlls
rm -rf Triangulation_3_Geomview_demos_Demo_with_dlls

# Demo to ignore (in favor of Polyhedron)
rm -rf Circular_kernel_3_Demo_with_dlls
rm -rf Surface_mesh_deformation_Demo_with_dlls

# CGAL<=3.7
pushd AABB_tree_Demo_with_dlls;                   zip -r ../AABB_demo.zip          *    ;      popd
pushd Alpha_shapes_3_Demo_with_dlls;              zip -r ../alpha_shape_3.zip      *    ;      popd
pushd Bounding_volumes_Demo_with_dlls;            zip -r ../bounding_volumes_2.zip *    ;      popd
pushd Circular_kernel_2_Demo_with_dlls;           zip -r ../circular_kernel.zip    *    ;      popd
pushd Periodic_3_triangulation_3_Demo_with_dlls;  zip -r ../periodic_3_triangulation_3.zip *;  popd
pushd Periodic_Lloyd_3_Demo_with_dlls;            zip -r ../periodic_3_lloyd.zip *;            popd
#pushd Polyhedron_Demo_with_dlls;                  zip -r ../polyhedron_3.zip *       ;      popd
pushd Segment_Delaunay_graph_2_Demo_with_dlls;    zip -r ../segment_voronoi_diagram_2.zip *;   popd
#pushd Surface_mesher_Demo_with_dlls;              zip -r ../surface_mesher.zip *;              popd
pushd Triangulation_2_Demo_with_dlls;
  zip -r ../regular_triangulation_2.zip Regular_triangulation_2.exe *.dll platforms;
  zip -r ../constrained_delaunay_triangulation_2.zip Constrained_Delaunay_triangulation_2.exe *.dll platforms;
  zip -r ../delaunay_triangulation_2.zip Delaunay_triangulation_2.exe *.dll platforms;
popd

# CGAL-3.8
pushd Largest_empty_rect_2_Demo_with_dlls;        zip -r ../largest_empty_rect_2.zip *;           popd
pushd Apollonius_graph_2_Demo_with_dlls;          zip -r ../apollonius_graph_2.zip *;             popd
pushd Stream_lines_2_Demo_with_dlls;              zip -r ../streamlines.zip *;                    popd
pushd Triangulation_3_Demo_with_dlls;             zip -r ../triangulation_3.zip *;                popd
#pushd Circular_kernel_3_Demo_with_dlls;           zip -r ../triangulation_3.zip *;                popd
pushd Alpha_shapes_2_Demo_with_dlls;              zip -r ../alpha_shapes_2.zip *;                 popd
pushd Generator_Demo_with_dlls;                   zip -r ../generator.zip *;                      popd
pushd L1_Voronoi_diagram_2_Demo_with_dlls;        zip -r ../l1_voronoi_diagram_2.zip *;           popd
pushd Snap_rounding_2_Demo_with_dlls;             zip -r ../snap_rounding_2.zip *;                popd
pushd Spatial_searching_2_Demo_with_dlls;         zip -r ../spatial_searching.zip *;              popd

# CGAL-4.0
pushd Linear_cell_complex_Demo_with_dlls;         zip -r ../linear_cell_complex_3.zip *;          popd

# CGAL-4.2 but was forgot -> published with 4.3
pushd Arrangement_on_surface_2_Demo_with_dlls;    zip -r ../arrangements_2.zip *;                 popd

# CGAL-4.5
pushd Periodic_2_triangulation_2_Demo_with_dlls;  zip -r ../Periodic_2_Delaunay_triangulation_2.zip *;
                                                                                     popd
# probably an error, in CGAL-4.5:
rm -rf Surface_mesh_deformation_Demo

# Demo not announced in the CGAL manual, from CGAL-3.8:
rm -rf Circular_kernel_3_Demo

# CGAL-4.6
pushd Polyline_simplification_2_Demo_with_dlls;   zip -r ../polyline_simplification_2.zip *;      popd

# CGAL-4.7
pushd Segment_Delaunay_graph_Linf_2_Demo_with_dlls; zip -r ../segment_voronoi_diagram_2.zip *;    popd

# CGAL-4.8
pushd Optimal_transportation_reconstruction_2_Demo_with_dlls; zip -r ../otr2.zip *;               popd

#missing demos
pushd Polygon_Demo_with_dlls; zip -r ../polygon.zip *;               popd
pushd Principal_component_analysis_Demo_with_dlls; zip -r ../pca.zip *;               popd
pushd Hyperbolic_triangulation_2_Demo_with_dlls; zip -r ../Hyperbolic_Delaunay_triangulation_2.zip *;               popd
pushd Periodic_4_hyperbolic_triangulation_2_Demo_with_dlls; zip -r ../Periodic_4_hyperbolic_Delaunay_triangulation_2.zip *;               popd

# CGAL-5.3
pushd Triangulation_on_sphere_2_Demo_with_dlls; zip -r ../triangulation_on_sphere_2.zip *;         popd

# CGAL-6.0
pushd Lab_Demo_with_dlls; zip -r ../CGALlab.zip *; popd
pushd Arrangement_on_surface_2_earth_Demo_with_dlls; zip -r ../arrangements_2_earth.zip *; popd

# check
echo CHECK now. The following lines should be empty.
for f in *zip; do unzip -qql $f; done | awk '{print $4}' >| done
for f in */**/*(.); do grep -qF ${f:t} done || ls $f; done
echo
