From 01d9918ab62993b43e65a327cfb7f571983bd9f7 Mon Sep 17 00:00:00 2001 From: Walter Goossens Date: Tue, 10 May 2011 01:02:17 +0200 Subject: [PATCH] Alter Makefile to build seperate objects and remove inclusion of c file --- Makefile | 22 +++++++++++++--------- hairtunes.c | 2 +- shairport.c | 4 +--- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index e9f20685..64a3dc88 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,21 @@ -PKGFLAGS:=$(shell pkg-config --cflags --libs openssl ao) -CFLAGS:=-O2 -Wall -LDFLAGS:=-lm -lpthread - +CFLAGS:=-O2 -Wall $(shell pkg-config --cflags openssl ao) +LDFLAGS:=-lm -lpthread $(shell pkg-config --libs openssl ao) +OBJS=socketlib.o shairport.o alac.o hairtunes.o all: hairtunes shairport -hairtunes: hairtunes.c alac.c - $(CC) $(CFLAGS) hairtunes.c alac.c -o $@ $(PKGFLAGS) $(LDFLAGS) +hairtunes: hairtunes.c alac.o + $(CC) $(CFLAGS) -DHAIRTUNES_STANDALONE hairtunes.c alac.c -o $@ $(LDFLAGS) -shairport: socketlib.c shairport.c alac.c - $(CC) $(CFLAGS) alac.c socketlib.c shairport.c -o $@ $(PKGFLAGS) $(LDFLAGS) +shairport: $(OBJS) + $(CC) $(CFLAGS) $(OBJS) -o $@ $(LDFLAGS) clean: - -@rm -rf hairtunes shairport + -@rm -rf hairtunes shairport $(OBJS) + + +%.o: %.c + $(CC) $(CFLAGS) -c $< -o $@ + prefix=/usr/local install: hairtunes diff --git a/hairtunes.c b/hairtunes.c index f735f733..d4a9f441 100644 --- a/hairtunes.c +++ b/hairtunes.c @@ -235,7 +235,7 @@ int hairtunes_init(char *pAeskey, char *pAesiv, char *fmtpstr, int pCtrlPort, in return EXIT_SUCCESS; } -#ifndef DONT_USE_HAIRTUNES_MAIN +#ifdef HAIRTUNES_STANDALONE int main(int argc, char **argv) { char *hexaeskey = 0, *hexaesiv = 0; char *fmtpstr = 0; diff --git a/shairport.c b/shairport.c index eccbc01d..38bcbd8c 100644 --- a/shairport.c +++ b/shairport.c @@ -27,9 +27,7 @@ #include #include "socketlib.h" #include "shairport.h" - -#define DONT_USE_HAIRTUNES_MAIN -#include "hairtunes.c" // couldn't figure out how to allow both mains. +#include "hairtunes.h" #ifndef TRUE #define TRUE (-1)