Makefile cleaning
authorPatrik Gornicz <Gornicz.P@gmail.com>
Sat, 16 May 2009 17:28:46 +0000 (13:28 -0400)
committerPatrik Gornicz <Gornicz.P@gmail.com>
Sat, 16 May 2009 17:28:46 +0000 (13:28 -0400)
Makefile

index 7058651..2cf55b0 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,12 +1,9 @@
 
-# set this on the command line to 1 to get a windows 32 build
-WIN32    := 0
+# set this on the command line to get a WIN32 or a FINAL build
+BUILD    := DEBUG
 
-# set this on the command line to 1 to get a final (none debug) build
-FINAL    := 0
 
-
-ifeq (${WIN32},1)
+ifeq (${BUILD},WIN32)
     LIBGL   := -lopengl32 -lglu32
     LIBSDL  := `/usr/mingw32/bin/sdl-config --libs`
 else
@@ -18,19 +15,21 @@ LIBS        := ${LIBSDL} ${LIBGL}
 OPTFLAGS := -O2
 DBGFLAGS := -ggdb
 PRFFLAGS := ${DBGFLAGS} -pg
+LIBFLAGS := -fPIC
 MYFLAGS  := -Wall -pedantic -ansi
 
-ifeq (${WIN32},1)
-    CXXFLAGS    := ${OPTFLAGS}
+CXXFLAGS := ${MYFLAGS} ${LIBFLAGS}
+ifeq (${BUILD},WIN32)
+    CXXFLAGS    += ${OPTFLAGS}
 else
-ifeq (${FINAL},1)
-    CXXFLAGS    := ${OPTFLAGS} -fPIC
+ifeq (${BUILD},FINAL)
+    CXXFLAGS    += ${OPTFLAGS}
 else
-    CXXFLAGS    := ${MYFLAGS} ${DBGFLAGS} -fPIC
+    CXXFLAGS    += ${DBGFLAGS}
 endif
 endif
 
-ifeq (${WIN32},1)
+ifeq (${BUILD},WIN32)
     CXX := mingw32-g++
 else
     CXX := g++
@@ -41,10 +40,10 @@ DIRS    := # := start
 SRCSDIR := src/
 SRCS    := # := start
 
-ifeq (${WIN32},1)
+ifeq (${BUILD},WIN32)
     OBJSDIR := objs-mingw32/
 else
-ifeq (${FINAL},1)
+ifeq (${BUILD},FINAL)
     OBJSDIR := objs/
 else
     OBJSDIR := objsd/
@@ -59,17 +58,17 @@ DEPS    := # := start
 DIRMK   := dir.mk
 include ${SRCSDIR}${DIRMK}
 
-ifeq (${WIN32},1)
+ifeq (${BUILD},WIN32)
     WORKINGDIR  := bin-mingw32/
 else
-ifeq (${FINAL},1)
+ifeq (${BUILD},FINAL)
     WORKINGDIR  := bin/
 else
     WORKINGDIR  := bind/
 endif
 endif
 
-ifeq (${WIN32},1)
+ifeq (${BUILD},WIN32)
     LINKERNAME  := pg.dll
     SONAME      := pg.dll
     REALNAME    := pg.dll
@@ -79,6 +78,8 @@ else
     REALNAME    := libpg.so.0.0
 endif
 
+LNKFLAGS := -shared -Wl,-soname,${SONAME}
+
 TARGETTMP   := ${OBJSDIR}${REALNAME}
 TARGET      := ${WORKINGDIR}${REALNAME}
 
@@ -93,7 +94,8 @@ BLDDIRS     += ${WORKINGDIR}
 INCDIRS     := ${SRCSDIR} inc/
 INCFLAGS    := $(addprefix -I, ${INCDIRS})
 
-ifeq (${WIN32},1)
+
+ifeq (${BUILD},WIN32)
     prefix      := /usr/mingw32
 else
     prefix      := /usr
@@ -102,7 +104,11 @@ exec_prefix := ${prefix}
 includedir  := ${prefix}/include
 libdir      := ${exec_prefix}/lib
 
-PRNTFMT := printf "%-5s: %s\n"
+ifeq (${BUILD},WIN32)
+    PRNTFMT := printf "%-12s: %s\n"
+else
+    PRNTFMT := printf "%-8s: %s\n"
+endif
 
 VERBOSE := 0
 
@@ -144,7 +150,7 @@ uninstall:
 # how to link the main target
 ${TARGETTMP}: ${OBJS}
        ${Q1}${PRNTFMT} "${CXX}" "$@"
-       ${Q2}${CXX} ${CXXFLAGS} -shared -Wl,-soname,${SONAME} -o $@ $^ ${LIBS}
+       ${Q2}${CXX} ${CXXFLAGS} ${LNKFLAGS} -o $@ $^ ${LIBS}
 
 # rule to copy tmp target to working directory
 ${TARGET}: ${TARGETTMP} | ${WORKINGDIR}