1)src下删除helloword.c添加自己的程序
#ifndef STUDENT_H_ #define STUDENT_H_ typedef struct student{ int age; char name[20]; struct student *next; }STUDENT; #endif /* STUDENT_H_ */
#include<stdio.h> #include<stdlib.h> #include"student.h" STUDENT *head = NULL; void createList(){ STUDENT *tmp = head; int i; for(i = 0; i < 10; i++){ STUDENT *s = (STUDENT*)malloc(sizeof(STUDENT)); s->age = i; sprintf(s->name, "%d", 10000+i); s->next = NULL; tmp->next = s; tmp = s; } } void tranvseList(){ STUDENT* tmp = head->next; while(tmp != NULL){ printf("Name = %s, and Age = %d\n", tmp->name, tmp->age); tmp = tmp->next; } } int main(){ head = (STUDENT*)malloc(sizeof(STUDENT)); head->next = NULL; createList(); tranvseList(); return 0; }
2. 修改src下的Makefile.am
bin_PROGRAMS=exe1
exe1_SOURCES=student.h student.c
3.project下的configure.ac
AC_PREREQ(2.59)
AC_INIT(MyTest, 1.0)
AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE()
AC_PROG_CC
AC_CONFIG_FILES(Makefile src/Makefile)
AC_OUTPUT
4. project下的Makefile.am
SUBDIRS=src
若增加其他的代码包,修改以上几个文件就可以了。