Skip to content

Instantly share code, notes, and snippets.

@wizzup
Last active April 4, 2019 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wizzup/1298a13da32ab80bff7ca2856e5e2b67 to your computer and use it in GitHub Desktop.
Save wizzup/1298a13da32ab80bff7ca2856e5e2b67 to your computer and use it in GitHub Desktop.
Hello world in C with GNU autotools
# กำหนด version ต่ำสุด ของ autoconf
AC_PREREQ([2.69])
# ตั้งชื่อ package, version และ ช่องทางสำหรับรายงาน bug
AC_INIT([hello], [0.0.1], [hello-bug@example.com])
# ตั้งค่าเริ่มต้น automake (foreign หมายถึงไม่ใช่ GNU project คือไม่ต้องมี README, INSTALL, ..)
AM_INIT_AUTOMAKE([foreign])
# บอก autoconf ให้สร้าง Makefile (จาก Makefile.in)
AC_CONFIG_FILES([Makefile])
# ตรวจสอบ compiler (C)่่
AC_PROG_CC
# สร้าง configure script และ Makefile
AC_OUTPUT
#include<stdio.h>
int main(void){
printf("Hello World\n");
}
# สร้าง binary ชื่อ hello
bin_PROGRAMS = hello
# สร้าง hello จาก main.c
hello_SOURCES = main.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment