basic makefiles are a doddle.... but there's a better way to sort it out if you plan to write gpl code or something in that vein, automake and autoconf:
http://sources.redhat.com/autobook/a...obook_toc.html
i did this for a project i'm working on called
acidrip and to make a whole distributable setup for a c program, i had to create two files, a configure.in:
Code:
dnl Process this file with autoconf to produce a configure script.
AC_INIT(lsdvd.c)
AM_INIT_AUTOMAKE(lsdvd, 0.3)
CFLAGS=-g
AC_PROG_CC
AC_CHECK_LIB(dvdread, DVDOpen, , AC_MSG_ERROR([libdvdread not found!]))
AC_MSG_CHECKING([for dvdread/ifo_read.h])
AC_TRY_COMPILE([#include <dvdread/ifo_read.h>], ,
AC_MSG_RESULT([yes]),
AC_MSG_RESULT([no])
AC_MSG_ERROR([Header files for dvdread not found]))
AC_OUTPUT(Makefile)
and a Makefile.am
Code:
bin_PROGRAMS = lsdvd
lsdvd_SOURCES = lsdvd.c
From this, you just need to run autoconf and automake and it will generate a full configure script and makefile and everything, you can then easily add on compatability checks, like i have in my configure.in program (the ac_try_compile block) that link i've given is what i used to get started, and it's really really easy once you suss out which way up is.