#!/usr/bin/perl use strict; use warnings; use Cwd; use File::Path qw(make_path remove_tree); if($#ARGV < 1 || $ARGV[0] =~ /(?:-h)|(?:--help)/){ print "this script requires two arguments :\n a path for the newly created c project\n a path to your c-tap-harness folder\n\n\n"; die; } my $folder = $ARGV[0]; my $ctap_folder_path = $ARGV[1]; my $starting_folder=getcwd(); mkdir $folder; chdir $folder; mkdir "tests"; `cp $ctap_folder_path/tests/runtests.c tests/`; `cp -r $ctap_folder_path/tests/tap tests/`; `touch NEWS README AUTHORS ChangeLog`; make_path('src/c','src/h','obj/src','obj/tests','bin','doc'); my $makefile_am = <<'END'; EXTRA_DIST=src doc tests obj AM_CFLAGS=-I$(abs_top_srcdir)/src/h AUTOMAKE_OPTIONS=subdir-objects check_PROGRAMS = tests/runtests #tests/exemple_test #executable file name of each test must be added to tests/TESTS #this setup allows you to use make distcheck as well as make distclean and #related commands tests_runtests_CPPFLAGS = -DSOURCE='"$(abs_top_srcdir)/tests"' \ -DBUILD='"$(abs_top_builddir)/tests"' check_LIBRARIES = tests/tap/libtap.a tests_tap_libtap_a_CPPFLAGS = -I$(abs_top_srcdir)/tests tests_tap_libtap_a_SOURCES = tests/tap/basic.c tests/tap/basic.h tests/tap/macros.h check-local:$(check_PROGRAMS) cd tests && ./runtests -l $(abs_top_srcdir)/tests/TESTS tests/runtests$(EXEEXT):tests/runtests.c gcc $^ -o tests/runtests #tests must be added this way: # # #tests/exemple_tests$(EXEEXT):$(abs_top_srcdir)/obj/tests/exemple_tests.o #obj/src/exemple_test.o\ # obj/src/basic.o # gcc -o tests/exemple_tests $^ #$(abs_top_srcdir)/obj/tests/exemple_tests.o: tests/exemple_tests.c # gcc -c $^ -o $(abs_top_srcdir)/obj/tests/exemple_tests.o $(AM_CFLAGS) # #normal files: # #obj/src/main.o:src/c/main.c # gcc -c $^ -o obj/src/main.o END open my $fh, '>','Makefile.am'; print $fh $makefile_am; close $fh; `autoscan`; open $fh,'<','configure.scan'; open my $ac,'>','configure.ac'; while(<$fh>){ my $line = $_; if($line =~ /\AAC_INIT/gxms){ $line =~ s/FULL-PACKAGE-NAME/$folder/; $line =~ s/VERSION/0.1/; $line =~ s/BUG-REPORT-ADDRESS/changeMeAtBugReportEmail/; print $ac $line; print $ac "AM_INIT_AUTOMAKE\nAC_PROG_RANLIB\n", } else{ print $ac $line; } } close $fh; close $ac; chdir 'tests'; `mv runtests.c ../src/tests/`; chdir 'tap'; my @file = glob "*.c"; foreach my $file (@file){ `gcc -c $file`; } chdir '../..'; `touch tests/TESTS`; unlink 'configure.scan'; `autoreconf -i`;