Greetings fellow monks,
Too sick to be able to crawl to my classes I sat at my workbench and started hammering away at my latest obsession After devouring calcote fine autotools book I finally got it to work as I wanted it to (the obsession, not the book).
Alas as many of you may know trial and error is a bitch especially if your mind is deprived from his usual clarity by the wicked veils of sickness.

Pretty sure that by the end of my exhaustion induced nap with my cat I would have completely forgotten how I did it (and thanks to said veils I have not versionned correctly each trial) I set up to write the following script :

Given a path to your newly created c project folder and one to your c-tap-harness folder it will create a new project with the set of files needed by autotools.
Fellow monks that dabble in the Deep and Dark arts of C programming I give you those tools so you can use them or discard them as you see fit.

As always I am eager for ways to get better at perling so if you spot errors or ways to improve that script I am all electronic ears and shall follow up on your suggestions

Yours, still relatively coherent,

and now : create_c_project.pl:
Update: thanks for the good idea about filepath, I have updated the code and got rid of a silly bug related to the placement of AUTOMAKE_INIT and such things inside configure.ac

Yet Another update : fixed some issues and made the resulting project folder easier to work with (mainly by sprinkling it with symlinks and moving object files around)

And now the last update, I got everything working so make dist really distribute everything important

And the last update, promised, this time the template makefile works for distclean type commands

#!/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_test +s.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_CFL +AGS) # #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`;

In reply to create_c_project with tap harness by QuillMeantTen

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.