From 4117304567ceb9454599a4e2889f09443382f74a Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 4 Jan 2013 10:47:29 +0100 Subject: Make compilable throgh both c and c++ and linkable with both using debug.hpp if c++ app links with debug compield with c compiler. --- Makefile | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index c397c53..45b6460 100644 --- a/Makefile +++ b/Makefile @@ -1,29 +1,44 @@ include Makefile.files CFLAGS=-Werror -Wall -D_FORTIFY_SOURCE=2 -g -O2 +CXXFLAGS=$(CFLAGS) -all: complete complete-cpp simple syslog filter mutex minimal +all: complete obj simple syslog filter mutex minimal complete: gcc ${CFLAGS} ${DEBUG_SOURCES} main_complete.c -o debug-complete -DWITH_DBG_SYSLOG -DWITH_DBG_FILTER -DWITH_DBG_MUTEX + g++ ${CXXFLAGS} ${DEBUG_SOURCES} main_complete.c -o debug-complete -DWITH_DBG_SYSLOG -DWITH_DBG_FILTER -DWITH_DBG_MUTEX -complete-cpp: - g++ ${CFLAGS} ${DEBUG_SOURCES} main_complete.c -o debug-complete-cpp -DWITH_DBG_SYSLOG -DWITH_DBG_FILTER -DWITH_DBG_MUTEX +obj: +# Compile debug as c prog and link with c++ program (use debug.hpp) + g++ ${CXXFLAGS} main_simple.cc -c + gcc ${CFLAGS} debug.c -c + g++ main_simple.o debug.o -o debug-obj + +# Compile debug as c++ prog and link with c++ program + g++ ${CXXFLAGS} main_simple.c -c + g++ ${CXXFLAGS} debug.c -c + g++ main_simple.o debug.o -o debug-obj simple: gcc ${CFLAGS} debug.c main_simple.c -o debug-simple + g++ ${CXXFLAGS} debug.c main_simple.c -o debug-simple minimal: gcc ${CFLAGS} debug.c main_minimal.c -o debug-minimal + g++ ${CXXFLAGS} debug.c main_minimal.c -o debug-minimal syslog: gcc ${CFLAGS} debug.c debug_syslog.c main_syslog.c -o debug-syslog -DWITH_DBG_SYSLOG + g++ ${CXXFLAGS} debug.c debug_syslog.c main_syslog.c -o debug-syslog -DWITH_DBG_SYSLOG filter: gcc ${CFLAGS} debug.c debug_filter.c main_filter.c -o debug-filter -DWITH_DBG_FILTER + g++ ${CXXFLAGS} debug.c debug_filter.c main_filter.c -o debug-filter -DWITH_DBG_FILTER mutex: gcc ${CFLAGS} debug.c main_mutex.c -o debug-mutex -DWITH_DBG_MUTEX + g++ ${CXXFLAGS} debug.c main_mutex.c -o debug-mutex -DWITH_DBG_MUTEX clean: rm -f debug_{complete,complete-cpp,simple,syslog,filter,mutex,minimal} \ No newline at end of file -- cgit v1.2.3